/**
 * LEUKHOUT.nl - Lightburn-style Editor CSS
 * Nieuwe editor layout met toolbar, sidebar, canvas en properties panel
 *
 * BREAKPOINTS (Tailwind-compatible):
 * - xs: max-width: 479px  (extra small phones)
 * - sm: max-width: 639px  (phones)
 * - md: max-width: 767px  (tablets portrait)
 * - lg: max-width: 1023px (tablets landscape)
 * - xl: max-width: 1279px (small desktops)
 *
 * MOBILE-FIRST APPROACH:
 * - Sidebar hidden on mobile (<768px)
 * - Floating toolbar as bottom bar on mobile
 * - Modals as bottom sheets on mobile
 * - Touch-friendly handle sizes (44-48px touch targets)
 */

/* ============================================================ */
/* LAYOUT CONTAINER                                             */
/* ============================================================ */

.editor-container {
    display: flex;
    flex-direction: column;
    /* Use dynamically measured header height (set by JS in base.html) */
    /* Falls back to CSS calc if JS hasn't run yet */
    --header-total-height: var(--real-header-height, calc(var(--banner-height-desktop, 48px) + 52px));
    /* Flexbox-based height: fills remaining viewport space */
    height: calc(100vh - var(--header-total-height));
    height: calc(100dvh - var(--header-total-height)); /* Dynamic viewport height - modern browsers */
    min-height: 0; /* Critical for flex children overflow */
    background: var(--bg-main);
    /* Safe area support for notch devices */
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
}

/* Main area uses grid with toolbar spanning full width */
.editor-main {
    display: grid;
    /* Sidebar breedte: improved clamp for better DPI scaling
       Min: 300px ensures readability, Max: 420px prevents too wide sidebar
       Using 25vw gives better proportions at intermediate resolutions */
    grid-template-columns: clamp(300px, 25vw, 420px) minmax(0, 1fr);
    grid-template-rows: auto auto 1fr;
    flex: 1;
    min-height: 0; /* Critical for grid children overflow */
    overflow: hidden;
}

/* Op extra brede schermen: sidebar mag breder */
@media (min-width: 1600px) {
    .editor-main {
        grid-template-columns: clamp(340px, 22vw, 480px) minmax(0, 1fr);
    }
}

/* ============================================================ */
/* LARGE SCREENS (2560px+, bijv. 1440p)                        */
/* ============================================================ */

@media (min-width: 2560px) {
    .editor-main {
        grid-template-columns: clamp(380px, 18vw, 500px) minmax(0, 1fr);
    }

    /* Grotere fonts voor leesbaarheid */
    .editor-sidebar .description {
        font-size: 1rem;
        line-height: 1.7;
    }

    .editor-sidebar h1 {
        font-size: 1.5rem;
    }

    .editor-sidebar .subtitle {
        font-size: 1.125rem;
    }

    .editor-sidebar .price {
        font-size: 1.375rem;
    }

    /* Toolbar buttons */
    .toolbar-btn {
        font-size: 0.9375rem;
        padding: 0.625rem 1rem;
    }

    .toolbar-btn svg {
        width: 20px;
        height: 20px;
    }

    .canvas-toolbar .toolbar-btn {
        padding: 0.5rem 0.75rem;
        font-size: 0.875rem;
    }

    .canvas-toolbar .toolbar-btn svg {
        width: 18px;
        height: 18px;
    }

    /* Product image kan groter */
    #product-image {
        max-height: calc(100vh - var(--real-header-height, 120px) - 160px);
        max-height: calc(100dvh - var(--real-header-height, 120px) - 160px);
    }

    /* Modals */
    .modal-content {
        max-width: 900px;
    }

    .modal-content h2 {
        font-size: 1.375rem;
    }

    /* Properties panel */
    .floating-toolbar button {
        min-width: 40px;
        min-height: 40px;
    }

    /* Inspirations carousel */
    .inspirations-carousel {
        gap: 1rem;
    }

    .inspiration-item {
        width: 130px;
        height: 130px;
    }
}

/* ============================================================ */
/* ULTRAWIDE SCREENS (3440px+, bijv. ultrawide 1440p)          */
/* ============================================================ */

@media (min-width: 3440px) {
    .editor-main {
        grid-template-columns: clamp(420px, 15vw, 560px) minmax(0, 1fr);
    }

    /* Nog grotere fonts */
    .editor-sidebar .description {
        font-size: 1.0625rem;
        line-height: 1.75;
    }

    .editor-sidebar h1 {
        font-size: 1.625rem;
    }

    .editor-sidebar .subtitle {
        font-size: 1.1875rem;
    }

    .editor-sidebar .price {
        font-size: 1.5rem;
    }

    /* Toolbar */
    .toolbar-btn {
        font-size: 1rem;
        padding: 0.75rem 1.125rem;
    }

    .toolbar-btn svg {
        width: 22px;
        height: 22px;
    }

    .canvas-toolbar .toolbar-btn {
        padding: 0.5rem 0.875rem;
        font-size: 0.9375rem;
    }

    .canvas-toolbar .toolbar-btn svg {
        width: 20px;
        height: 20px;
    }

    /* Product area groter */
    #product-image {
        max-height: calc(100vh - var(--real-header-height, 120px) - 120px);
        max-height: calc(100dvh - var(--real-header-height, 120px) - 120px);
    }

    /* Modals kunnen breder */
    .modal-content {
        max-width: 1000px;
    }

    .modal-content h2 {
        font-size: 1.5rem;
    }

    /* Icon grid in modal */
    .icon-grid {
        grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
        gap: 1rem;
    }

    /* Inspirations */
    .inspiration-item {
        width: 150px;
        height: 150px;
    }

    /* Specifications list */
    .specs-list {
        font-size: 0.9375rem;
    }

    .specs-list dt {
        font-size: 0.875rem;
    }
}

/* Toolbar spans full width */
.editor-toolbar {
    grid-column: 1 / -1;
}

/* Edit mode bar also spans full width */
.edit-mode-bar {
    grid-column: 1 / -1;
}

/* Sidebar in left column, spanning content row */
.editor-sidebar {
    grid-column: 1;
    grid-row: 3;
    min-height: 0; /* Nodig voor overflow in grid items */
}

/* Canvas column in right column, spanning content row */
.editor-canvas-column {
    grid-column: 2;
    grid-row: 3;
    display: flex;
    flex-direction: column;
    min-height: 0; /* Critical for flex children overflow in grid */
    overflow: hidden;
}

/* ============================================================ */
/* TOOLBAR                                                      */
/* ============================================================ */

.editor-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 52px;
    padding: 0 1rem;
    background: var(--bg-panel);
    border-bottom: 1px solid var(--border-soft);
    flex-shrink: 0;
    z-index: 100;
}

/* Terug knop */
.toolbar-back-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.875rem;
    border: none;
    background: transparent;
    border-radius: 0.375rem;
    cursor: pointer;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-main);
    text-decoration: none;
    transition: all 0.15s ease;
}

.toolbar-back-btn:hover {
    background: var(--bg-surface-light);
}

.toolbar-back-btn svg {
    width: 18px;
    height: 18px;
}

.toolbar-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.875rem;
    border: none;
    background: transparent;
    border-radius: 0.375rem;
    cursor: pointer;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-main);
    transition: all 0.15s ease;
}

.toolbar-btn:hover {
    background: var(--bg-surface-light);
}

.toolbar-btn.active {
    background: var(--accent-secondary);
    color: white;
}

.toolbar-btn svg {
    width: 18px;
    height: 18px;
}

.toolbar-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.toolbar-btn:disabled:hover {
    background: transparent;
}

.toolbar-separator {
    width: 1px;
    height: 24px;
    background: var(--border-color);
    margin: 0 0.25rem;
}

/* Terug tekst verbergen op kleine schermen */
@media (max-width: 480px) {
    .toolbar-back-text {
        display: none;
    }
}

.toolbar-right {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.toolbar-product-name {
    font-weight: 600;
    color: var(--text-main);
}

.toolbar-product-price {
    font-weight: 700;
    color: var(--accent-secondary);
}

/* ============================================================ */
/* VARIANT SELECTOR (sidebar & mobile)                          */
/* ============================================================ */

.variant-selector,
.mobile-variant-selector {
    margin: 0.5rem 0;
}

.variant-selector label,
.mobile-variant-selector label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: var(--text-main);
    font-size: 0.875rem;
}

.variant-select {
    width: 100%;
    padding: 0.625rem 0.875rem;
    border: 2px solid var(--border-medium);
    border-radius: 0.5rem;
    background: white;
    color: var(--text-main);
    font-size: 0.9375rem;
    cursor: pointer;
    transition: border-color 0.15s ease;
}

.variant-select:hover {
    border-color: var(--accent-secondary);
}

.variant-select:focus {
    outline: none;
    border-color: var(--accent-secondary);
    box-shadow: 0 0 0 3px var(--accent-primary-faint, rgba(217, 119, 6, 0.15));
}

/* ============================================================ */
/* EDIT MODE BAR                                                */
/* ============================================================ */

.edit-mode-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.625rem 1.5rem;
    /* Offset to align with canvas area (past sidebar) */
    padding-left: calc(280px + 1.5rem);
    background: linear-gradient(135deg, var(--accent-secondary), var(--accent-secondary));
    color: white;
    font-size: 0.875rem;
    flex-shrink: 0;
}

.edit-mode-bar.hidden {
    display: none;
}

.edit-mode-info {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 500;
}

.edit-mode-info svg {
    flex-shrink: 0;
}

.edit-mode-cancel {
    padding: 0.375rem 0.875rem;
    background: rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 0.375rem;
    color: white;
    font-size: 0.8125rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
}

.edit-mode-cancel:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* ============================================================ */
/* MAIN CONTENT AREA                                            */
/* ============================================================ */

/* .editor-main is now defined in LAYOUT CONTAINER section */

/* ============================================================ */
/* LEFT SIDEBAR                                                 */
/* ============================================================ */

.editor-sidebar {
    background: var(--bg-card);
    border-right: 1px solid var(--border-soft);
    overflow-y: auto; /* Sidebar scrolls independently */
    overflow-x: hidden;
    padding: 0.75rem;
    /* Critical for overflow to work in grid children */
    min-height: 0;
}

.editor-sidebar-content {
    /* Geen extra achtergrond/schaduw - sidebar is al wit */
    padding: 0.5rem;
}

.editor-sidebar h1 {
    font-size: 1.125rem;
    font-weight: 700;
    color: var(--text-main);
    margin: 0 0 0.25rem 0;
}

.editor-sidebar .price {
    font-size: 1rem;
    font-weight: 700;
    color: var(--accent-secondary);
    margin: 0 0 0.75rem 0;
}

.editor-sidebar .description {
    font-size: 0.8125rem;
    color: var(--text-sub);
    line-height: 1.5;
    /* Lange beschrijvingen krijgen scrollbalk */
    max-height: 60vh;
    overflow-y: auto;
    padding-bottom: 0.5rem;
}

.editor-sidebar .description p {
    margin: 0 0 0.5rem 0;
}

.editor-sidebar .specs {
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--border-soft);
}

.editor-sidebar .specs-title {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin: 0 0 0.5rem 0;
}

.editor-sidebar .specs-list {
    font-size: 0.875rem;
    color: var(--text-sub);
}

.editor-sidebar .specs-list li {
    margin-bottom: 0.25rem;
}

/* ============================================================ */
/* CANVAS AREA                                                  */
/* ============================================================ */

.editor-canvas-area {
    display: flex;
    flex-direction: column;
    flex: 1;
    background: var(--bg-main);
    overflow: hidden;
}

.canvas-container {
    flex: 1;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 0.75rem 1rem;
    overflow: auto;
    background: var(--bg-main);
}

/* Wrapper die toolbar en product bij elkaar houdt */
.canvas-content-wrapper {
    display: flex;
    flex-direction: column;
    max-width: 100%;
    max-height: 100%;
    padding: 1.5rem;
    border-radius: 0.75rem;
    /* Dambord patroon met transparante kleuren */
    background-image:
        linear-gradient(45deg, rgba(0,0,0,0.06) 25%, transparent 25%),
        linear-gradient(-45deg, rgba(0,0,0,0.06) 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, rgba(0,0,0,0.06) 75%),
        linear-gradient(-45deg, transparent 75%, rgba(0,0,0,0.06) 75%);
    background-size: 20px 20px;
    background-position: 0 0, 0 10px, 10px -10px, -10px 0px;
    background-color: var(--bg-panel);
}

/* ============================================================ */
/* CANVAS TOOLBAR - Edit controls boven het product             */
/* ============================================================ */

.canvas-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 40px;
    padding: 0 0.5rem;
    background: var(--bg-panel);
    border: 1px solid var(--border-soft);
    border-bottom: none;
    border-radius: 0.5rem 0.5rem 0 0;
    flex-shrink: 0;
}

.canvas-toolbar-left,
.canvas-toolbar-right {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.canvas-toolbar .toolbar-btn {
    padding: 0.375rem 0.625rem;
    font-size: 0.8125rem;
}

.canvas-toolbar .toolbar-btn svg {
    width: 16px;
    height: 16px;
}

/* ============================================================ */
/* CANVAS ACTIONS - Actieknoppen onder het product              */
/* ============================================================ */

.canvas-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 48px;
    padding: 0 0.5rem;
    background: var(--bg-panel);
    border: 1px solid var(--border-soft);
    border-top: none;
    border-radius: 0 0 0.5rem 0.5rem;
    flex-shrink: 0;
}

.canvas-actions-left,
.canvas-actions-right {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.canvas-actions .toolbar-btn {
    padding: 0.5rem 0.875rem;
    font-size: 0.875rem;
}

/* Speciale kleuren voor actieknoppen */
.canvas-actions .btn-cart {
    background: var(--accent-secondary);
    color: white;
}

.canvas-actions .btn-cart:hover {
    filter: brightness(1.05);
}

.canvas-actions .btn-laser {
    background: linear-gradient(135deg, var(--status-error), var(--status-danger));
    color: white;
}

.canvas-actions .btn-laser:hover {
    filter: brightness(1.1);
}

.canvas-actions .btn-dobot {
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    color: white;
}

.canvas-actions .btn-dobot:hover {
    filter: brightness(1.1);
}

.canvas-actions .btn-download {
    background: var(--accent-tertiary);
    color: white;
}

.canvas-actions .btn-download:hover {
    filter: brightness(1.05);
}

.canvas-actions .btn-inspire {
    background: var(--accent-tertiary, #8b5cf6);
    color: white;
}

.canvas-actions .btn-inspire:hover {
    filter: brightness(1.05);
}

.canvas-actions .btn-primary {
    background: var(--accent-tertiary);
    color: white;
}

.canvas-actions .btn-primary:hover {
    filter: brightness(1.05);
}

/* ============================================================ */
/* PREVIEW WRAPPER                                              */
/* ============================================================ */

.preview-wrapper {
    position: relative;
    display: inline-block;
    max-width: 100%;
    touch-action: none; /* Prevent browser gesture handling */
    max-height: 100%;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    border-radius: 0;
    /* overflow: visible om SVG overlay correct te tonen */
}

.preview-wrapper.text-mode {
    cursor: text;
}

#product-image {
    display: block;
    max-width: 100%;
    /* Use dynamic header height for accurate calculation */
    max-height: calc(100vh - var(--real-header-height, 120px) - 200px);
    max-height: calc(100dvh - var(--real-header-height, 120px) - 200px);
    height: auto;
}

/* When in cart edit mode, reduce image height to make room for edit bar */
.editor-container.cart-edit-mode #product-image {
    max-height: calc(100vh - var(--real-header-height, 120px) - 250px);
    max-height: calc(100dvh - var(--real-header-height, 120px) - 250px);
}

#preview-overlay {
    position: absolute;
    pointer-events: auto;
    touch-action: none;
    user-select: none;
    /* Position and size set by JavaScript */
}

#preview-overlay svg {
    overflow: visible;
    touch-action: none; /* Prevent browser handling of touch on SVG */
}

#preview-overlay svg .draggable-element {
    cursor: grab;
    transition: filter 0.15s ease;
    touch-action: none; /* Critical: prevent scroll/zoom on draggable elements */
}

#preview-overlay svg .draggable-element:hover {
    filter: drop-shadow(0 0 4px var(--accent-secondary));
}

#preview-overlay svg .draggable-element:active {
    cursor: grabbing;
}

/* Canvas Text Input Overlay */
.canvas-text-input {
    position: absolute;
    background: white;
    border: 2px solid var(--accent-secondary);
    border-radius: 0.25rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    padding: 0.375rem 0.5rem;
    min-width: 180px;
    z-index: 100;
    transform: translate(-50%, -50%);
}

.canvas-text-input.hidden {
    display: none;
}

.canvas-text-input input {
    border: none;
    outline: none;
    font-size: 14px;
    width: 100%;
    font-family: inherit;
    background: transparent;
}

.canvas-text-input input::placeholder {
    color: var(--text-muted);
}

/* Element selection indicators */
.preview-element {
    pointer-events: auto;
    cursor: move;
}

.preview-element.selected {
    outline: 2px solid var(--accent-secondary);
    outline-offset: 2px;
}

.preview-element:hover:not(.selected) {
    outline: 2px dashed var(--accent-secondary);
    outline-offset: 2px;
}

/* Anchor indicators - SVG circles */
.anchor-indicator {
    cursor: pointer;
    pointer-events: auto;
    transition: opacity 0.15s ease, filter 0.15s ease;
}

/* Hover effect via filter (works reliably on SVG elements) */
.anchor-indicator:hover {
    opacity: 1 !important;
    filter: drop-shadow(0 0 4px #d97706) drop-shadow(0 0 8px #fbbf24);
}

/* During drag mode, make anchor overlay always visible */
.anchor-overlay {
    pointer-events: auto;
}

/* Pulse animation for available anchors during drag */
.anchor-overlay .anchor-indicator:not([opacity="0.2"]) {
    animation: anchorGlow 1.2s ease-in-out infinite;
}

@keyframes anchorGlow {
    0%, 100% {
        opacity: 0.6;
        filter: none;
    }
    50% {
        opacity: 1;
        filter: drop-shadow(0 0 3px #d97706);
    }
}

/* Anchor pulse animation (legacy) */
@keyframes anchorPulse {
    0%, 100% { opacity: 0.6; }
    50% { opacity: 1; }
}

.anchor-pulse {
    animation: anchorPulse 0.8s ease-in-out infinite;
}

/* ============================================================ */
/* PROPERTIES PANEL                                             */
/* ============================================================ */

.properties-panel {
    background: white;
    border-top: 1px solid var(--border-soft);
    padding: 1rem 1.5rem;
    flex-shrink: 0;
    overflow-x: auto;
}

.properties-panel.hidden {
    display: none;
}

.properties-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
}

.properties-title {
    font-weight: 600;
    color: var(--text-main);
    font-size: 0.875rem;
}

.properties-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 1.5rem;
    align-items: flex-start;
}

.property-group {
    min-width: 150px;
}

.property-group.wide {
    min-width: 250px;
    flex: 1;
}

.property-group label {
    display: block;
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.03em;
    margin-bottom: 0.375rem;
}

.property-group input[type="text"],
.property-group select {
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border-soft);
    border-radius: 0.375rem;
    font-size: 0.875rem;
    background: white;
    transition: border-color 0.15s;
}

.property-group input[type="text"]:focus,
.property-group select:focus {
    outline: none;
    border-color: var(--accent-secondary);
}

.slider-with-value {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.slider-with-value input[type="range"] {
    flex: 1;
    height: 4px;
    border-radius: 2px;
    background: var(--border-soft);
    -webkit-appearance: none;
    appearance: none;
}

.slider-with-value input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--accent-secondary);
    cursor: pointer;
    border: 2px solid white;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.slider-with-value .value {
    min-width: 40px;
    text-align: right;
    font-size: 0.875rem;
    color: var(--text-sub);
    font-weight: 500;
}

.rotation-buttons {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.rotation-buttons button {
    padding: 0.375rem 0.625rem;
    border: 1px solid var(--border-soft);
    border-radius: 0.25rem;
    background: white;
    font-size: 0.75rem;
    cursor: pointer;
    transition: all 0.15s;
}

.rotation-buttons button:hover {
    background: var(--bg-surface-light);
    border-color: var(--accent-secondary);
}

.rotation-buttons span {
    min-width: 40px;
    text-align: center;
    font-size: 0.875rem;
}

.btn-flip {
    padding: 0.375rem 0.75rem;
    border: 1px solid var(--border-soft);
    border-radius: 0.25rem;
    background: white;
    font-size: 0.8125rem;
    cursor: pointer;
    transition: all 0.15s;
}

.btn-flip:hover {
    background: var(--bg-surface-light);
}

.btn-flip.active {
    background: var(--accent-secondary);
    color: white;
    border-color: var(--accent-secondary);
}

.btn-delete-prop {
    padding: 0.375rem;
    border: 1px solid var(--status-error-soft);
    border-radius: 0.25rem;
    background: var(--status-error-soft);
    color: var(--status-danger);
    cursor: pointer;
    transition: all 0.15s;
}

.btn-delete-prop:hover {
    background: var(--status-error-soft);
    border-color: var(--status-error);
}

.btn-delete-prop svg {
    width: 16px;
    height: 16px;
}

/* ============================================================ */
/* ACTIONS BAR                                                  */
/* ============================================================ */

.editor-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 72px;
    padding: 0 1.5rem;
    background: white;
    border-top: 1px solid var(--border-soft);
    flex-shrink: 0;
    /* Ensure footer is always visible */
    position: relative;
    z-index: 50;
}

.actions-left {
    display: flex;
    gap: 0.75rem;
}

.actions-right {
    display: flex;
    gap: 0.75rem;
}

.btn-action {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.25rem;
    border: none;
    border-radius: 0.5rem;
    font-size: 0.9375rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
}

.btn-action svg {
    width: 18px;
    height: 18px;
}

.btn-secondary {
    background: var(--bg-panel);
    color: var(--text-sub);
    border: 1px solid var(--border-soft);
}

.btn-secondary:hover {
    background: var(--bg-surface-light);
    color: var(--text-main);
}

.btn-primary {
    background: var(--accent-tertiary);
    color: white;
}

.btn-primary:hover {
    filter: brightness(1.05);
}

.btn-laser {
    background: linear-gradient(135deg, var(--status-error), var(--status-danger));
    color: var(--text-invert);
}

.btn-laser:hover {
    filter: brightness(1.1);
}

.btn-download {
    background: var(--accent-tertiary);
    color: white;
}

.btn-download:hover {
    filter: brightness(1.05);
}

.btn-dobot {
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    color: white;
}

.btn-dobot:hover {
    filter: brightness(1.1);
}

.btn-inspire {
    background: var(--accent-tertiary, #8b5cf6);
    color: white;
}

.btn-inspire:hover {
    filter: brightness(1.05);
}

.btn-cart {
    background: var(--accent-secondary);
    color: white;
    padding: 0.75rem 1.5rem;
}

.btn-cart:hover {
    filter: brightness(1.05);
}

.btn-action:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ============================================================ */
/* ICON MODAL                                                   */
/* ============================================================ */

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 1rem;
}

.modal-overlay.hidden {
    display: none;
}

.modal-content {
    background: white;
    border-radius: 0.75rem;
    max-width: 640px;
    max-height: 80vh;
    width: 100%;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.modal-header {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border-soft);
    flex-shrink: 0;
}

/* Draggable modal header styling */
.modal-header-draggable {
    cursor: grab;
    user-select: none;
}

.modal-header-draggable:active {
    cursor: grabbing;
}

/* Visuele drag handle indicator */
.modal-header-draggable::before {
    content: '';
    position: absolute;
    left: 50%;
    top: 0.5rem;
    transform: translateX(-50%);
    width: 40px;
    height: 4px;
    background: var(--border-soft);
    border-radius: 2px;
    opacity: 0.6;
    transition: opacity 0.15s;
}

.modal-header-draggable:hover::before {
    opacity: 1;
    background: var(--text-muted);
}

/* Modal tijdens drag */
.modal-dragging {
    transition: none !important;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.35);
}

.modal-header h2 {
    font-size: 1.125rem;
    font-weight: 600;
    margin: 0;
}

.modal-close {
    padding: 0.375rem;
    border: none;
    background: transparent;
    border-radius: 0.25rem;
    cursor: pointer;
    color: var(--text-muted);
    transition: all 0.15s;
}

.modal-close:hover {
    background: var(--bg-panel);
    color: var(--text-main);
}

.modal-close svg {
    width: 20px;
    height: 20px;
}

.modal-filters {
    display: flex;
    gap: 0.75rem;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border-soft);
    flex-shrink: 0;
}

.modal-filters input,
.modal-filters select {
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border-soft);
    border-radius: 0.375rem;
    font-size: 0.875rem;
}

.modal-filters input {
    flex: 1;
}

.modal-filters input:focus,
.modal-filters select:focus {
    outline: none;
    border-color: var(--accent-secondary);
}

.modal-body {
    flex: 1;
    overflow-y: auto;
    padding: 1rem 1.5rem;
}

.icon-grid-modal {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    gap: 0.75rem;
}

.icon-btn-modal {
    aspect-ratio: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 0.5rem;
    border: 1px solid var(--border-soft);
    border-radius: 0.5rem;
    background: white;
    cursor: pointer;
    transition: all 0.15s;
}

.icon-btn-modal:hover {
    border-color: var(--accent-secondary);
    background: var(--bg-surface-light);
}

.icon-btn-modal.selected {
    border-color: var(--accent-secondary);
    background: var(--status-warning-soft);
}

.icon-btn-modal img,
.icon-btn-modal .icon-thumb {
    width: 40px;
    height: 40px;
    object-fit: contain;
}

.icon-btn-modal .icon-thumb svg {
    width: 100%;
    height: 100%;
    display: block;
}

.icon-btn-modal span {
    font-size: 0.625rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
    text-align: center;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 100%;
}

/* ============================================================ */
/* SHAPE MODAL                                                  */
/* ============================================================ */

/* Shape modal moet groter zijn dan standaard sm */
#shape-modal .modal-content {
    max-width: 600px;
    width: 95vw;
}

#shape-modal .modal-body {
    max-height: 70vh;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 1rem;
}

.shape-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.75rem;
}

.shape-btn {
    aspect-ratio: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 0.75rem;
    border: 2px solid var(--border-soft);
    border-radius: 0.75rem;
    background: white;
    cursor: pointer;
    transition: all 0.15s;
}

.shape-btn:hover {
    border-color: var(--accent-secondary);
    background: var(--bg-surface-light);
    transform: scale(1.05);
}

.shape-btn:active {
    transform: scale(0.98);
}

.shape-btn svg {
    color: var(--text-main);
}

.shape-btn .shape-name {
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-top: 0.5rem;
    text-align: center;
}

/* ============================================================ */
/* BORDER MODAL                                                 */
/* ============================================================ */

/* Border modal moet groter zijn dan standaard sm */
#border-modal .modal-content {
    max-width: 600px;
    width: 95vw;
}

#border-modal .modal-content {
    display: flex;
    flex-direction: column;
    max-height: 85vh;
}

#border-modal .modal-body {
    flex: 1;
    min-height: 0;
    max-height: none;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 1rem;
}

.border-grid {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.border-section-header {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-main);
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border-soft);
}

.border-items-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.75rem;
}

.border-btn {
    aspect-ratio: 1.5;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 0.5rem;
    border: 2px solid var(--border-soft);
    border-radius: 0.75rem;
    background: white;
    cursor: pointer;
    transition: all 0.15s;
}

.border-btn:hover {
    border-color: var(--accent-secondary);
    background: var(--bg-surface-light);
    transform: scale(1.02);
}

.border-btn:active {
    transform: scale(0.98);
}

.border-btn.selected {
    border-color: var(--accent-primary);
    background: var(--accent-primary-faint);
}

.border-btn .border-preview {
    width: 100%;
    height: 60px;
    object-fit: contain;
    overflow: hidden;
}

.border-btn .border-preview svg {
    width: 100%;
    height: 100%;
    display: block;
}

.border-btn .border-name {
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-top: 0.5rem;
    text-align: center;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 100%;
}

.btn-remove-border {
    padding: 0.75rem 1rem;
    border: 2px solid var(--status-error);
    border-radius: 0.5rem;
    background: transparent;
    color: var(--status-error);
    cursor: pointer;
    font-weight: 500;
    transition: all 0.15s;
}

.btn-remove-border:hover {
    background: var(--status-error);
    color: white;
}

/* Border controls (aantal en grootte sliders) - sticky footer */
#border-modal .border-controls {
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border-soft);
    background: var(--bg-secondary);
}

.border-control-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.border-control-row label {
    flex: 0 0 70px;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.border-control-row input[type="range"] {
    flex: 1;
    height: 6px;
    -webkit-appearance: none;
    appearance: none;
    background: var(--border-soft);
    border-radius: 3px;
    cursor: pointer;
}

.border-control-row input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--accent-primary);
    cursor: pointer;
    border: 2px solid white;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.border-control-row input[type="range"]::-moz-range-thumb {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--accent-primary);
    cursor: pointer;
    border: 2px solid white;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.border-control-row span {
    flex: 0 0 30px;
    text-align: right;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-primary);
}

.border-control-row input[type="range"]:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.border-control-row input[type="range"]:disabled + span {
    opacity: 0.4;
}

/* Border action buttons */
.border-action-buttons {
    display: flex;
    gap: 0.75rem;
    margin-top: 0.5rem;
}

.btn-border-action {
    flex: 1;
    padding: 0.75rem 1rem;
    border-radius: 0.5rem;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
    border: 1px solid var(--border-soft);
}

.btn-border-clear {
    background: white;
    color: var(--text-secondary);
}

.btn-border-clear:hover {
    background: var(--status-error-faint, #fef2f2);
    border-color: var(--status-error);
    color: var(--status-error);
}

.btn-border-apply {
    background: var(--accent-primary);
    color: white;
    border-color: var(--accent-primary);
}

.btn-border-apply:hover {
    background: var(--accent-primary-dark, #b45309);
}

/* ============================================================ */
/* HELP MODAL                                                   */
/* ============================================================ */

.help-modal-body {
    padding: 1.25rem 1.5rem;
}

/* Markdown content styling in help modal */
.help-content h1 {
    display: none; /* Hide h1 - already shown in modal header */
}

.help-content h2 {
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--text-main);
    margin: 1.25rem 0 0.375rem 0;
}

.help-content h2:first-of-type {
    margin-top: 0;
}

.help-content p {
    font-size: 0.875rem;
    line-height: 1.5;
    color: var(--text-secondary);
    margin: 0 0 0.5rem 0;
}

.help-content p:last-child {
    margin-bottom: 0;
}

.help-content ul,
.help-content ol {
    font-size: 0.875rem;
    line-height: 1.5;
    color: var(--text-secondary);
    margin: 0 0 0.75rem 0;
    padding-left: 1.5rem;
}

.help-content li {
    margin-bottom: 0.25rem;
}

/* ============================================================ */
/* TEXT MODAL                                                   */
/* ============================================================ */

.modal-content-sm {
    max-width: 440px;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border-soft);
    background: var(--bg-panel);
}

.btn-modal-primary,
.btn-modal-secondary {
    padding: 0.625rem 1.25rem;
    border-radius: 0.375rem;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
}

.btn-modal-primary {
    background: var(--accent-secondary);
    color: white;
    border: none;
}

.btn-modal-primary:hover {
    filter: brightness(1.05);
}

.btn-modal-secondary {
    background: white;
    color: var(--text-sub);
    border: 1px solid var(--border-soft);
}

.btn-modal-secondary:hover {
    background: var(--bg-panel);
}

.text-modal-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
}

.form-group label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.form-group input[type="text"],
.form-group select,
.form-group textarea {
    padding: 0.625rem 0.875rem;
    border: 1px solid var(--border-soft);
    border-radius: 0.375rem;
    font-size: 0.9375rem;
    background: white;
    transition: border-color 0.15s;
}

.form-group textarea {
    resize: vertical;
    min-height: 4.5rem;
    line-height: 1.4;
    font-family: inherit;
}

.form-group input[type="text"]:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--accent-secondary);
}

.form-hint {
    font-size: 0.6875rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.text-preview-box {
    background: var(--bg-main);
    border: 1px solid var(--border-soft);
    border-radius: 0.375rem;
    padding: 1.5rem;
    min-height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.text-preview-box span {
    color: var(--text-main);
    text-align: center;
    word-break: break-word;
    white-space: pre-wrap;
    line-height: 1.3;
    width: 100%;
}

/* Alignment button group in text modal */
.align-button-group {
    display: flex;
    gap: 0;
    border: 1px solid var(--border-soft);
    border-radius: 0.375rem;
    overflow: hidden;
    width: fit-content;
}

.align-option {
    width: 40px;
    height: 36px;
    border: none;
    background: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-sub);
    transition: all 0.15s;
    border-right: 1px solid var(--border-soft);
}

.align-option:last-child {
    border-right: none;
}

.align-option:hover {
    background: var(--bg-surface-light);
    color: var(--text-main);
}

.align-option.active {
    background: var(--accent-secondary);
    color: white;
}

.align-option svg {
    width: 18px;
    height: 18px;
}

/* ============================================================ */
/* SELECTION OVERLAY & RESIZE HANDLES                           */
/* ============================================================ */

.selection-overlay {
    position: absolute;
    pointer-events: none;
    z-index: 50;
}

.selection-overlay.hidden {
    display: none;
}

.selection-box {
    position: relative;
    border: 2px solid var(--accent-secondary);
    border-radius: 2px;
    pointer-events: none;
}

/* Resize handles - on edge midpoints */
/* Touch-friendly with larger invisible touch area */
.resize-handle {
    position: absolute;
    width: 12px;
    height: 12px;
    background: white;
    border: 2px solid var(--accent-secondary);
    border-radius: 2px;
    pointer-events: all;
    z-index: 51;
    transition: background-color 0.15s, transform 0.15s;
}

/* Larger touch area via pseudo-element */
.resize-handle::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 44px;
    height: 44px;
    /* Transparent but clickable */
}

/* Even larger on touch devices */
@media (pointer: coarse) {
    .resize-handle {
        width: 14px;
        height: 14px;
    }

    .resize-handle::before {
        width: 48px;
        height: 48px;
    }
}

.resize-handle-n {
    top: -7px;
    left: 50%;
    transform: translateX(-50%);
    cursor: ns-resize;
}

.resize-handle-s {
    bottom: -7px;
    left: 50%;
    transform: translateX(-50%);
    cursor: ns-resize;
}

.resize-handle-e {
    right: -7px;
    top: 50%;
    transform: translateY(-50%);
    cursor: ew-resize;
}

.resize-handle-w {
    left: -7px;
    top: 50%;
    transform: translateY(-50%);
    cursor: ew-resize;
}

/* Slightly offset on touch devices */
@media (pointer: coarse) {
    .resize-handle-n { top: -9px; }
    .resize-handle-s { bottom: -9px; }
    .resize-handle-e { right: -9px; }
    .resize-handle-w { left: -9px; }
}

.resize-handle:hover,
.resize-handle:active {
    background: var(--accent-secondary);
    transform: scale(1.15);
}

.resize-handle-n:hover,
.resize-handle-n:active,
.resize-handle-s:hover,
.resize-handle-s:active {
    transform: translateX(-50%) scale(1.15);
}

.resize-handle-e:hover,
.resize-handle-e:active,
.resize-handle-w:hover,
.resize-handle-w:active {
    transform: translateY(-50%) scale(1.15);
}

/* Rotation handles - on corners */
/* Touch-friendly with larger invisible touch area */
.rotate-handle {
    position: absolute;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: all;
    cursor: grab;
    z-index: 52;
    color: var(--accent-secondary);
    opacity: 0.8;
    transition: opacity 0.15s, color 0.15s, transform 0.15s;
}

/* Larger touch area via pseudo-element */
.rotate-handle::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 44px;
    height: 44px;
}

/* Even larger on touch devices */
@media (pointer: coarse) {
    .rotate-handle {
        width: 28px;
        height: 28px;
    }

    .rotate-handle::before {
        width: 48px;
        height: 48px;
    }

    .rotate-handle svg {
        width: 18px;
        height: 18px;
    }
}

.rotate-handle:hover,
.rotate-handle:active {
    opacity: 1;
    color: var(--accent-secondary);
    transform: scale(1.1);
}

.rotate-handle:active {
    cursor: grabbing;
}

.rotate-handle-nw {
    top: -22px;
    left: -22px;
}

.rotate-handle-ne {
    top: -22px;
    right: -22px;
}

.rotate-handle-sw {
    bottom: -22px;
    left: -22px;
}

.rotate-handle-se {
    bottom: -22px;
    right: -22px;
}

/* Slightly more offset on touch devices */
@media (pointer: coarse) {
    .rotate-handle-nw { top: -26px; left: -26px; }
    .rotate-handle-ne { top: -26px; right: -26px; }
    .rotate-handle-sw { bottom: -26px; left: -26px; }
    .rotate-handle-se { bottom: -26px; right: -26px; }
}

/* ============================================================ */
/* INLINE TEXT INPUT                                            */
/* ============================================================ */

.inline-text-input {
    position: absolute;
    z-index: 60;
    pointer-events: all;
}

.inline-text-input.hidden {
    display: none;
}

.inline-text-input input {
    border: 2px solid var(--accent-secondary);
    border-radius: 3px;
    padding: 2px 6px;
    background: rgba(255, 255, 255, 0.95);
    outline: none;
    min-width: 100px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.inline-text-input input:focus {
    border-color: var(--accent-secondary);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent-secondary) 20%, transparent);
}

/* ============================================================ */
/* FLOATING TOOLBAR                                             */
/* ============================================================ */

.floating-toolbar {
    position: absolute;
    z-index: 100;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.375rem 0.625rem;
    background: white;
    border: 1px solid var(--border-soft);
    border-radius: 0.5rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    pointer-events: all;
}

.floating-toolbar.hidden {
    display: none;
}

.floating-font-select {
    padding: 0.25rem 0.5rem;
    border: 1px solid var(--border-soft);
    border-radius: 0.25rem;
    font-size: 0.8125rem;
    background: white;
    cursor: pointer;
    max-width: 120px;
}

.floating-font-select:focus {
    outline: none;
    border-color: var(--accent-secondary);
}

.floating-size-control {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    border: 1px solid var(--border-soft);
    border-radius: 0.25rem;
    overflow: hidden;
}

.size-btn {
    width: 24px;
    height: 24px;
    border: none;
    background: white;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-sub);
    transition: all 0.15s;
}

.size-btn:hover {
    background: var(--bg-surface-light);
    color: var(--text-main);
}

.size-display {
    min-width: 36px;
    text-align: center;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-main);
}

.floating-align-control {
    display: flex;
    align-items: center;
    border: 1px solid var(--border-soft);
    border-radius: 0.25rem;
    overflow: hidden;
}

.align-btn {
    width: 26px;
    height: 24px;
    border: none;
    background: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-sub);
    transition: all 0.15s;
    border-right: 1px solid var(--border-soft);
}

.align-btn:last-child {
    border-right: none;
}

.align-btn:hover {
    background: var(--bg-surface-light);
    color: var(--text-main);
}

.align-btn.active {
    background: var(--accent-secondary);
    color: white;
}

.align-btn svg {
    width: 14px;
    height: 14px;
}

.floating-rotate,
.floating-flip {
    width: 28px;
    height: 28px;
    border: none;
    background: transparent;
    border-radius: 0.25rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-sub);
    transition: all 0.15s;
}

.floating-rotate:hover,
.floating-flip:hover {
    background: var(--bg-surface-light);
    color: var(--text-main);
}

.floating-rotate svg,
.floating-flip svg {
    width: 16px;
    height: 16px;
}

.floating-delete {
    width: 28px;
    height: 28px;
    border: none;
    background: transparent;
    border-radius: 0.25rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--status-danger);
    transition: all 0.15s;
}

.floating-delete:hover {
    background: var(--status-error-soft);
}

.floating-delete svg {
    width: 16px;
    height: 16px;
}

/* ============================================================ */
/* FULLSCREEN MODE                                              */
/* ============================================================ */

.editor-container.fullscreen {
    position: fixed;
    inset: 0;
    z-index: 9999;
    height: 100vh;
    height: 100dvh;
}

/* Hide header when editor is in fullscreen mode */
body:has(.editor-container.fullscreen) .site-header,
body:has(.editor-container.fullscreen) .site-nav-bar {
    display: none;
}

.editor-container.fullscreen .editor-sidebar {
    display: none;
}

.editor-container.fullscreen .editor-main {
    grid-template-columns: 1fr;
}

.editor-container.fullscreen .editor-canvas-column {
    grid-column: 1;
}

.editor-container.fullscreen .canvas-container {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    /* Use flex: 1 instead of fixed vh calculation */
    flex: 1;
    min-height: 0;
}

.editor-container.fullscreen .preview-wrapper {
    max-height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.editor-container.fullscreen #product-image {
    max-height: calc(100vh - 140px);
    max-height: calc(100dvh - 140px);
    max-width: calc(100vw - 2rem);
    width: auto;
    height: auto;
    object-fit: contain;
}

/* ============================================================ */
/* MOBILE PRODUCT INFO - Base styles                            */
/* These must be defined BEFORE the responsive media queries    */
/* ============================================================ */

.mobile-product-info {
    display: none; /* Hidden on desktop (>1024px) */
}

/* Base styles for mobile product info components -
   These apply whenever .mobile-product-info is visible */
.mobile-product-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
}

.mobile-product-title {
    flex: 1;
    min-width: 0; /* Allow text truncation */
}

.mobile-product-title h1 {
    font-size: 1.125rem;
    font-weight: 600;
    margin: 0;
    color: var(--text-main);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.mobile-product-price {
    font-size: 1rem;
    font-weight: 600;
    color: var(--accent-secondary);
}

.mobile-info-toggle {
    flex-shrink: 0;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    background: var(--bg-main);
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
}

.mobile-info-toggle:hover,
.mobile-info-toggle:focus {
    background: var(--bg-surface-light);
    color: var(--text-main);
}

.mobile-info-toggle[aria-expanded="true"] {
    background: var(--accent-secondary);
    color: white;
}

.mobile-product-description {
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--border-soft);
    font-size: 0.9375rem;
    line-height: 1.6;
    color: var(--text-sub);
    max-height: none;
    overflow: visible;
}

.mobile-product-description.hidden {
    display: none;
}

.mobile-product-description p {
    margin: 0 0 0.5rem 0;
}

.mobile-product-description p:last-child {
    margin-bottom: 0;
}

/* Mobile variant selector styling */
.mobile-variant-selector {
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--border-soft);
}

/* ============================================================ */
/* RESPONSIVE                                                   */
/* ============================================================ */

@media (max-width: 1024px) {
    .editor-sidebar {
        display: none;
    }

    .editor-main {
        grid-template-columns: 1fr;
    }

    /* Canvas column spans full width when sidebar hidden */
    .editor-canvas-column {
        grid-column: 1;
    }

    .edit-mode-bar {
        padding-left: 1.5rem;
    }

    /* Show mobile product info when sidebar is hidden (768px - 1024px) */
    .mobile-product-info {
        display: block;
        background: var(--bg-card);
        border-bottom: 1px solid var(--border-soft);
        padding: 0.75rem 1rem;
    }
}

@media (max-width: 767px) {
    /* Hide fullscreen button on mobile - not useful */
    #btn-fullscreen {
        display: none !important;
    }

    /* Main toolbar compacter */
    .editor-toolbar {
        height: auto;
        padding: 0.5rem 0.75rem;
        gap: 0.5rem;
    }

    .toolbar-right {
        gap: 0.5rem;
    }

    .toolbar-back-btn span {
        display: none;
    }

    .toolbar-product-name {
        font-size: 0.8125rem;
        max-width: 120px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .toolbar-product-price {
        font-size: 0.875rem;
    }

    /* Canvas toolbar compacter */
    .canvas-toolbar {
        height: 36px;
        padding: 0 0.375rem;
    }

    .canvas-toolbar .toolbar-btn span {
        display: none;
    }

    .canvas-toolbar .toolbar-btn {
        padding: 0.5rem;
        min-width: 36px;
        min-height: 36px;
    }

    /* Canvas area */
    .canvas-container {
        padding: 0.75rem;
    }

    #product-image {
        max-height: calc(100vh - 240px);
    }

    /* When in cart edit mode, reduce image height further */
    .editor-container.cart-edit-mode #product-image {
        max-height: calc(100vh - 290px);
    }

    /* Edit mode bar */
    .edit-mode-bar {
        padding: 0.5rem 0.75rem;
        font-size: 0.8125rem;
    }

    .edit-mode-info span {
        display: none;
    }

    .edit-mode-info::after {
        content: 'Bewerkmodus';
    }

    /* Canvas actions - ensure buttons fit on smaller screens */
    .canvas-actions {
        flex-wrap: wrap;
        height: auto;
        gap: 0.375rem;
    }

    .canvas-actions-left,
    .canvas-actions-right {
        flex-wrap: wrap;
    }

    .canvas-actions .toolbar-btn span {
        display: none;
    }

    /* Properties panel */
    .properties-panel {
        padding: 0.75rem 1rem;
    }

    .properties-grid {
        gap: 0.75rem;
    }

    .property-group {
        min-width: 100%;
    }

    /* Actions bar */
    .editor-actions {
        height: auto;
        padding: 0.75rem 1rem;
        gap: 0.5rem;
    }

    .actions-left {
        display: none;
    }

    .actions-right {
        width: 100%;
        flex-direction: row;
    }

    .btn-action {
        flex: 1;
        padding: 0.875rem 1rem;
        font-size: 0.875rem;
    }

    .btn-action span {
        display: none;
    }

    .btn-cart span,
    .btn-laser span,
    .btn-download span,
    .btn-inspire span {
        display: inline;
    }

    /* Modals */
    .modal-content {
        margin: 0.5rem;
        max-height: calc(100vh - 1rem);
        border-radius: 0.5rem;
    }

    .modal-header {
        padding: 0.75rem 1rem;
    }

    .modal-header h2 {
        font-size: 1rem;
    }

    .modal-filters {
        flex-direction: column;
        padding: 0.75rem 1rem;
        gap: 0.5rem;
    }

    .modal-body {
        padding: 0.75rem 1rem;
    }

    .icon-grid-modal {
        grid-template-columns: repeat(auto-fill, minmax(70px, 1fr));
        gap: 0.5rem;
    }

    .icon-btn-modal {
        padding: 0.375rem;
    }

    .icon-btn-modal img,
    .icon-btn-modal .icon-thumb {
        width: 32px;
        height: 32px;
    }

    .icon-btn-modal span {
        font-size: 0.5625rem;
    }

    .modal-footer {
        padding: 0.75rem 1rem;
    }

    /* Text modal */
    .form-row {
        grid-template-columns: 1fr;
    }

    /* Floating toolbar compacter */
    .floating-toolbar {
        padding: 0.25rem 0.5rem;
        gap: 0.375rem;
    }

    .floating-font-select {
        max-width: 100px;
        font-size: 0.75rem;
        padding: 0.1875rem 0.375rem;
    }

    .size-btn {
        width: 28px;
        height: 28px;
    }

    .size-display {
        min-width: 32px;
        font-size: 0.6875rem;
    }

    .floating-delete,
    .floating-rotate,
    .floating-flip {
        width: 28px;
        height: 28px;
    }

    /* Selection handles groter voor touch */
    .resize-handle {
        width: 14px;
        height: 14px;
    }

    .resize-handle-n { top: -7px; }
    .resize-handle-s { bottom: -7px; }
    .resize-handle-e { right: -7px; }
    .resize-handle-w { left: -7px; }

    /* Rotation handles groter voor touch */
    .rotate-handle {
        width: 24px;
        height: 24px;
    }

    .rotate-handle-nw { top: -22px; left: -22px; }
    .rotate-handle-ne { top: -22px; right: -22px; }
    .rotate-handle-sw { bottom: -22px; left: -22px; }
    .rotate-handle-se { bottom: -22px; right: -22px; }
}

/* Extra small screens */
@media (max-width: 480px) {
    .editor-toolbar {
        padding: 0.375rem 0.5rem;
    }

    .toolbar-product-name {
        max-width: 80px;
        font-size: 0.75rem;
    }

    .toolbar-product-price {
        font-size: 0.8125rem;
    }

    .canvas-container {
        padding: 0.5rem;
    }

    #product-image {
        max-height: calc(100vh - 200px);
    }

    .editor-actions {
        padding: 0.5rem 0.75rem;
    }

    .btn-action {
        padding: 0.75rem 0.875rem;
    }

    .icon-grid-modal {
        grid-template-columns: repeat(auto-fill, minmax(60px, 1fr));
    }
}

/* ============================================================ */
/* MOBILE LAYOUT - Additional mobile styles                     */
/* ============================================================ */

@media (max-width: 767px) {
    /* Smaller text on actual mobile devices */
    .mobile-product-title h1 {
        font-size: 1rem;
    }

    .mobile-product-price {
        font-size: 0.875rem;
    }

    .mobile-product-description {
        font-size: 0.875rem;
        line-height: 1.5;
    }

    /* Allow scrolling on mobile - description above, editor below */
    .editor-container {
        /* Use dynamically measured header height, fallback to mobile estimate */
        --header-total-height: var(--real-header-height, calc(var(--banner-height-mobile, 36px) + 48px));
        height: auto;
        min-height: calc(100dvh - var(--header-total-height));
        overflow-y: auto;
        overflow-x: hidden;
    }

    /* Switch to single column layout */
    .editor-main {
        display: flex;
        flex-direction: column;
        grid-template-columns: 1fr; /* Override grid */
        overflow: visible;
    }

    /* Hide sidebar on mobile - functionality via toolbar buttons */
    .editor-sidebar {
        display: none;
    }

    /* Canvas column takes full width */
    .editor-canvas-column {
        grid-column: 1 / -1;
        flex: none; /* Don't flex - natural height */
        min-height: auto;
        overflow: visible;
    }

    /* Optimize canvas container */
    .canvas-container {
        padding: 0.5rem;
        align-items: center;
        justify-content: center;
    }

    .canvas-content-wrapper {
        padding: 0.5rem;
        max-width: 100%;
    }

    /* Maximize product image */
    #product-image {
        max-height: calc(100dvh - var(--real-header-height, 80px) - 140px);
        max-width: 100%;
        object-fit: contain;
    }

    /* When in cart edit mode, reduce image height further */
    .editor-container.cart-edit-mode #product-image {
        max-height: calc(100dvh - var(--real-header-height, 80px) - 200px);
    }

    /* Toolbar adjustments for mobile */
    .editor-toolbar {
        height: 48px;
        padding: 0 0.75rem;
    }

    .toolbar-back-text {
        display: none;
    }

    /* Canvas toolbar compact on mobile */
    .canvas-toolbar {
        height: 44px;
        padding: 0 0.5rem;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .canvas-toolbar .toolbar-btn {
        min-width: 44px;
        min-height: 44px;
        padding: 0.5rem;
    }

    .canvas-toolbar .toolbar-btn span {
        display: none; /* Hide text labels on mobile */
    }

    /* Action buttons (Winkelwagen/Opslaan) */
    .canvas-actions {
        min-height: 56px;
        height: auto;
        padding: 0.5rem;
        padding-bottom: max(0.5rem, env(safe-area-inset-bottom));
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    .canvas-actions-left,
    .canvas-actions-right {
        flex-wrap: wrap;
        justify-content: center;
    }

    .canvas-actions .toolbar-btn {
        min-height: 48px;
        padding: 0.75rem 1rem;
    }

    /* Hide text labels on action buttons on mobile, show only icons */
    .canvas-actions .toolbar-btn span {
        display: none;
    }

    /* ============================================================ */
    /* FLOATING TOOLBAR AS BOTTOM BAR ON MOBILE                     */
    /* Shows rotate, flip, delete actions when element is selected  */
    /* ============================================================ */

    .floating-toolbar {
        position: fixed !important;
        bottom: env(safe-area-inset-bottom, 0);
        left: 0;
        right: 0;
        transform: none !important;
        border-radius: 1rem 1rem 0 0;
        justify-content: space-around;
        padding: 0.5rem 1rem;
        padding-bottom: max(0.5rem, env(safe-area-inset-bottom));
        background: var(--bg-surface);
        box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
        z-index: 200;
    }

    /* Hide font selector and size controls on mobile - keep only action buttons */
    .floating-toolbar .floating-font-select,
    .floating-toolbar .floating-size-control,
    .floating-toolbar .floating-align-control {
        display: none !important;
    }

    /* Make action buttons larger for touch */
    .floating-toolbar button {
        min-height: 48px;
        min-width: 48px;
        padding: 0.75rem;
    }

    .floating-toolbar .floating-rotate,
    .floating-toolbar .floating-flip,
    .floating-toolbar .floating-delete {
        display: flex !important;
        align-items: center;
        justify-content: center;
    }

    /* Override the .hidden class when element is selected -
       toolbar should show as bottom bar on mobile */
    .floating-toolbar:not(.hidden) {
        display: flex !important;
    }

    /* ============================================================ */
    /* MODALS AS BOTTOM SHEETS ON MOBILE                            */
    /* ============================================================ */

    .modal-overlay {
        align-items: flex-end;
        padding: 0;
    }

    .modal-content {
        max-width: 100%;
        max-height: 85vh;
        margin: 0;
        border-radius: 1.5rem 1.5rem 0 0;
        animation: slideUpModal 0.25s ease;
    }

    /* Swipe handle indicator - op mobiel geen horizontale drag */
    .modal-header {
        position: relative;
        padding-top: 1.25rem;
    }

    .modal-header-draggable {
        cursor: default;
    }

    .modal-header::before,
    .modal-header-draggable::before {
        content: '';
        position: absolute;
        top: 0.5rem;
        left: 50%;
        transform: translateX(-50%);
        width: 36px;
        height: 4px;
        background: var(--border-soft);
        border-radius: 2px;
        opacity: 1;
    }

    /* Reset horizontal position on mobile - modals are bottom sheets */
    .modal-content {
        transform: none !important;
    }

    .modal-body {
        max-height: calc(85vh - 140px);
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    .modal-footer {
        padding: 0.75rem 1rem;
        padding-bottom: max(0.75rem, env(safe-area-inset-bottom));
    }

    /* Touch-friendly modal buttons */
    .btn-modal-primary,
    .btn-modal-secondary,
    .modal-footer button {
        min-height: 48px;
        padding: 0.75rem 1.5rem;
    }

    /* Icon grid responsive for mobile */
    .icon-grid-modal {
        grid-template-columns: repeat(auto-fill, minmax(72px, 1fr));
        gap: 0.5rem;
    }

    .icon-btn-modal {
        min-height: 72px;
    }
}

/* ============================================================ */
/* VIRTUAL KEYBOARD OPEN STATE                                   */
/* ============================================================ */

body.keyboard-open .floating-toolbar {
    /* Hide floating toolbar when keyboard is open */
    display: none;
}

body.keyboard-open .canvas-actions {
    /* Hide action buttons when keyboard is open */
    display: none;
}

body.keyboard-open .editor-container {
    /* Allow scrolling when keyboard is open */
    overflow: auto;
}

body.keyboard-open .editor-canvas-column {
    /* Remove bottom padding for floating toolbar */
    padding-bottom: 0;
}

/* Inline text input positioning when keyboard is open */
body.keyboard-open .inline-text-input {
    position: fixed;
    bottom: calc(10vh + env(safe-area-inset-bottom));
    left: 50%;
    transform: translateX(-50%);
    width: 90%;
    max-width: 400px;
    z-index: 300;
}

/* ============================================================ */
/* CUTOUT MODAL                                                 */
/* ============================================================ */

/* Tab navigation */
.cutout-tabs {
    display: flex;
    border-bottom: 2px solid var(--border-soft);
    padding: 0 1.5rem;
    gap: 0;
}

.cutout-tab {
    padding: 0.625rem 1.25rem;
    border: none;
    background: transparent;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-sub);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: all 0.15s;
}

.cutout-tab:hover {
    color: var(--text-main);
}

.cutout-tab.active {
    color: var(--accent-secondary);
    border-bottom-color: var(--accent-secondary);
    font-weight: 600;
}

.cutout-tab-content {
    padding: 1rem 1.5rem;
}

/* Text form */
.cutout-text-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.cutout-text-input-group,
.cutout-font-group {
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
}

.cutout-text-input-group label,
.cutout-font-group label {
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--text-sub);
}

.cutout-text-input {
    padding: 0.625rem 0.875rem;
    border: 1px solid var(--border-soft);
    border-radius: 0.375rem;
    font-size: 0.9375rem;
    background: white;
    resize: vertical;
    transition: border-color 0.15s;
}

.cutout-text-input:focus {
    outline: none;
    border-color: var(--accent-secondary);
}

.cutout-font-select {
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border-soft);
    border-radius: 0.375rem;
    font-size: 0.875rem;
    background: white;
    cursor: pointer;
}

.cutout-font-select:focus {
    outline: none;
    border-color: var(--accent-secondary);
}

/* Text preview */
.cutout-text-preview {
    background: var(--bg-surface-light);
    border: 1px solid var(--border-soft);
    border-radius: 0.5rem;
    padding: 0.75rem;
    min-height: 60px;
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
}

.cutout-text-preview-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 500;
}

.cutout-text-preview-content {
    font-size: 1.25rem;
    color: #FF0000;
    word-break: break-word;
    min-height: 1.5em;
}

/* Apply button */
.btn-cutout-apply {
    background: var(--accent-secondary);
    color: white;
    border: none;
    padding: 0.625rem 1.25rem;
    border-radius: 0.375rem;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
    align-self: flex-end;
}

.btn-cutout-apply:hover:not(:disabled) {
    filter: brightness(1.05);
}

.btn-cutout-apply:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* Shape grid item - cutout shapes show with red accent */
#cutout-shape-grid .icon-btn-modal.selected {
    border-color: #FF0000;
    background: rgba(255, 0, 0, 0.05);
}

/* ============================================================ */
/* DARK MODE (optional, for future)                             */
/* ============================================================ */

@media (prefers-color-scheme: dark) {
    /* Dark mode styles kunnen hier toegevoegd worden */
}

/* ============================================================ */
/* ANIMATIONS                                                   */
/* ============================================================ */

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideUpModal {
    from {
        transform: translateY(100%);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.modal-overlay {
    animation: fadeIn 0.15s ease;
}

.modal-content {
    animation: slideUp 0.2s ease;
}

/* Modal met opgeslagen positie: geen slide animatie (voorkomt flash) */
.modal-content[style*="translateX"] {
    animation: fadeIn 0.15s ease;
}

.properties-panel:not(.hidden) {
    animation: slideUp 0.15s ease;
}

/* ============================================================ */
/* TEKSTVELDEN MODE - Simplified text input fields              */
/* ============================================================ */

/* Desktop: tekstvelden naast preview (row layout) */
.tekstvelden-mode .canvas-container {
    flex-direction: row;
    align-items: flex-start;
    gap: 1.5rem;
}

/* Preview behoudt natuurlijke grootte, tekstvelden krijgen vaste breedte */
.tekstvelden-mode .canvas-content-wrapper {
    flex: none;
    min-width: 0;
}

.tekstvelden-panel {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    padding: 1.25rem;
    background: var(--bg-panel, #f8f8f8);
    border-radius: 8px;
    width: 280px;
    flex-shrink: 0;
}

.tekstveld-group {
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
}

.tekstveld-label {
    font-weight: 600;
    font-size: 0.875rem;
    color: var(--text-main, #333);
}

.tekstveld-input-row {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.tekstveld-input {
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border-color, #ddd);
    border-radius: 6px;
    font-size: 1rem;
    background: var(--bg-main, #fff);
    color: var(--text-main, #333);
    transition: border-color 0.2s;
    box-sizing: border-box;
}

.tekstveld-input:focus {
    outline: none;
    border-color: var(--accent-primary, #2563eb);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.tekstveld-font-select {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid var(--border-color, #ddd);
    border-radius: 6px;
    font-size: 0.875rem;
    background: var(--bg-main, #fff);
    color: var(--text-main, #333);
    box-sizing: border-box;
}

.tekstveld-hint {
    font-size: 0.75rem;
    color: var(--text-muted, #999);
}

/* Mobile: tekstvelden onder preview (column layout) */
@media (max-width: 767px) {
    .tekstvelden-mode .canvas-container {
        flex-direction: column;
        align-items: stretch;
    }

    .tekstvelden-panel {
        width: 100%;
    }
}
