/* ============================================================
   CUSTOMIZER V2 - RESPONSIVE STYLES
   All rules are inside media queries, so the desktop layout
   (above 768px) is never affected.
   ============================================================ */

@media (max-width: 768px) {

    /* --- MAIN CONTAINER / POPUP --- */
    /* NOTE: display:flex is NOT forced here (JS sets it inline).
       A forced display:flex !important breaks jQuery .hide() because
       !important would override the inline display:none. */
    #designer-popup {
        top: 125px;
        height: calc(100% - 125px);
        flex-direction: column;
        overflow-y: auto !important;
        overscroll-behavior: contain !important;
        -webkit-overflow-scrolling: touch !important;
    }

    /* Old front-end X is replaced by the v2 header close button */
    #close-button {
        display: none !important;
    }

    #designer-content {
        padding: 0 8px !important;
        margin: 0 !important;
        max-width: 100vw !important;
    }

    /* --- APP LAYOUT: stack toolbar / panel above canvas --- */
    .app-content {
        flex-direction: column;
        width: 100%;
        max-width: 100%;
    }

    .left-toolbar {
        display: flex;
        width: 100%;
        flex-direction: row;
        flex-wrap: nowrap;
        justify-content: center;
        align-items: center;
        border-right: none;
        border-bottom: 1px solid #e2e8f0;
        padding: 4px;
        gap: 2px;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .left-toolbar .tool-button {
        min-width: 44px;
        min-height: 44px;
        width: auto;
        flex: 0 0 auto;
        padding: 6px;
    }

    .left-toolbar .tool-button svg {
        width: 20px;
        height: 20px;
    }

    .properties-panel {
        width: 100%;
        max-width: 100%;
        border-right: none;
        border-top: 1px solid #e2e8f0;
        overflow: visible;
    }

    .properties-panel-collapsed {
        width: 100% !important;
        min-width: 100% !important;
    }

    .panel-content {
        height: auto !important;
        max-height: 300px !important;
    }

    /* --- HEADER --- */
    .app-header {
        flex-wrap: wrap;
        padding: 6px 8px;
        gap: 6px;
    }

    .app-header h1 {
        font-size: 14px;
    }

    .header-actions {
        gap: 6px;
    }

    /* --- MENUBAR --- */
    .app-menubar {
        padding: 4px 6px;
        min-height: auto;
        border: 1px solid #ececec;
        border-radius: 10px;
    }

    .menubar-header {
        display: flex;
        width: 100%;
        align-items: center;
        justify-content: space-between;
        padding: 0 12px;
    }

    .menubar-properties {
        display: flex;
        align-items: center;
        flex-wrap: wrap;
        row-gap: 0.5rem;
        column-gap: 0.5rem;
    }

    .panel-content {
        height: fit-content !important;
    }

    .tool-button.active {
        color: #4f46e5;
        box-shadow: none;
    }

    .collapsed {
        height: 0;
        display: none;
    }

    /* --- CANVAS --- */
    #customizer-container .canvas-wrapper,
    #customizer-container .canvas-content,
    #customizer-container .canvas-content > .container,
    #customizer-container #canvasbox {
        width: 100% !important;
        max-width: 100% !important;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* One finger pans/scrolls; JS handles two-finger pinch zoom */
    #customizer-container .canvas-wrapper,
    #customizer-container #canvasbox {
        touch-action: pan-x pan-y;
    }

    /* IMAGES tab: product previews a bit bigger on mobile */
    #customizer-container #panel-default .front_back_image {
        max-width: 140px !important;
        max-height: 140px !important;
    }

    /* NOTE: the canvas size itself is adjusted in customizer.js
       (applyDesignZone) and is NOT forced via CSS, because that
       would desync Fabric's upper/lower canvas overlays. */
}

@media (max-width: 400px) {

    .app-header h1 {
        font-size: 12px;
    }

    .left-toolbar .tool-button {
        min-width: 40px;
        min-height: 40px;
    }
}
