﻿/* --- Basic Reset & Mobile-First Styles --- */

#app-container {
    max-width: var(--wp--style--global--wide-size);
    height: 100%;
    display: flex;
    flex-direction: column;
    /* Mobile: Top-to-bottom */
    background: #fff;
    position: relative;
}

#canvas-container {
    position: relative;
    width: 100%;
    height: 100%;
    overflow: hidden;
    /* Prevents scrollbars if canvas is 1px too big */
}

#shoe-canvas {
    display: block;
    /* Removes default inline spacing */
    width: 100% !important;
    height: 100% !important;
    outline: none;
    cursor: grab;
}

#shoe-canvas.is-dragging {
    cursor: grabbing;
}

/* --- Sidebar: mobile-first --- */
#sidebar {
    /* Mobile: place in normal document flow under the canvas */
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

#sidebar-content {
    padding: 16px;
    overflow-y: auto;
    flex-grow: 1;
}

/* --- Sidebar Action Bar (bottom) --- */
#sidebar-action-bar {
    border-top: 1px solid #eee;
    padding: 12px;
    display: flex;
    gap: 8px;
    justify-content: space-between;
    align-items: center;
}

#sidebar-action-bar button {
    padding: 10px 12px;
    border-radius: 6px;
    border: 1px solid #ddd;
    background: #fff;
    cursor: pointer;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
}

#sidebar-action-bar button span {
    padding-left: 4px;
}

#btn-download-preview:hover {
    opacity: 0.95;
}

#btn-add-to-cart,
#btn-download-preview {
    background: #fff;
    color: #111;
}

.add-to-cart-container {
    display: flex;
    align-items: center;
    gap: 12px;
}



/* --- Mobile Menu Grid --- */
.mobile-menu-container {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    /* 2-column grid */
    gap: 10px;
}

.mobile-submenu-container {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.mobile-menu-button {
    padding: 14px 12px;
    background: #f9f9f9;
    border: 1px solid #eee;
    border-radius: 8px;
    text-align: center;
    /* Center text for grid */
    font-size: 14px;
    /* Slightly smaller for grid */
    font-weight: 500;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    /* Stack icon and text */
    justify-content: center;
    align-items: center;
    gap: 8px;
}

#btn-mobile-back {
    padding: 14px 12px;
    background: #f0f0f0;
    border: 1px solid #eee;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
}

.mobile-submenu-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}

.mobile-submenu-header h3 {
    margin: 0;
    font-size: 18px;
}

.cust-section {
    margin-bottom: 24px;
    border-bottom: 1px solid #eee;
    padding-bottom: 16px;
}

.cust-section:last-child {
    border-bottom: none;
    margin-bottom: 0;
}

.cust-section h3 {
    font-size: 16px;
    font-weight: 600;
    margin-top: 0;
    margin-bottom: 12px;
}

.color-swatches {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
}

.swatch-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    /* Space between swatch and name */
    cursor: pointer;
    transition: transform 0.1s ease;
}

.swatch-wrapper:hover {
    transform: scale(1.05);
}

.swatch-name {
    font-size: 12px;
    color: #555;
    text-align: center;
}

/* Desktop Swatch Size */
.color-swatch {
    width: 100%;
    height: 80px;
    border-radius: 4px;
    border: 2px solid #fff;
    box-shadow: 0 0 0 1px #ccc;
    background-color: #ffffff;
}

.logic-swatch {
    width: 100%;
    height: 80px;
    border-radius: 4px;
    border: 1px solid #ccc;
    background: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
}

/* Active State (applied to wrapper) */
.swatch-wrapper.active .color-swatch,
.swatch-wrapper.active .logic-swatch {
    box-shadow: 0 0 0 2px #096dd9;
}

.swatch-wrapper.active .swatch-name {
    font-weight: 600;
    color: #000;
}


/* --- View Controls (Left) --- */
#view-controls {
    height: 100%;
    position: absolute;
    left: 16px;
    top: 0px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: start;
    gap: 4px;
    z-index: 10;
}

#view-controls button,
.btn-back {
    display: inline-flex;
    align-items: center;
    flex: 0 0 auto;
    line-height: 0;
    width: auto;
    white-space: nowrap;
    background: rgba(255, 255, 255, 0.7);
    border: none;
    padding: 6px;
    border-radius: 4px;
    cursor: pointer;
    transition: transform 0.2s, color 0.2s;
    color: #333333;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.btn-back {
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
}

#view-controls button svg {
    width: 24px;
    height: 24px;
    stroke: currentColor;
    stroke-width: 2;
    fill: none;
}

#view-controls button:hover {
    transform: scale(1.1);
    color: #096dd9;
}

#view-controls button:disabled {
    opacity: 0.4;
    color: #aaa;
    cursor: not-allowed;
    transform: none;
}

/* --- Desktop Layout (min-width: 769px) --- */
@media (min-width: 769px) {

    body,
    html {
        display: flex;
        justify-content: center;
        align-items: center;
    }

    #app-container {
        /* Use most of the viewport width on desktop while keeping a small page margin */
        height: 80vh;
        flex-direction: row;
        /* Side-by-side */
        overflow: hidden;
    }

    #canvas-container {
        flex-grow: 1;
        flex-basis: 0;
    }

    /* Ensure the canvas fills the entire canvas container on desktop so it isn't narrow */
    #canvas-container {
        height: 100%;
        min-height: 0;
        display: flex;
        align-items: stretch;
    }

    /* Higher-specificity selector to avoid needing !important */
    #app-container #canvas-container>#shoe-canvas,
    #app-container #canvas-container canvas {
        width: 100%;
        height: 100%;
        display: block;
        object-fit: cover;
    }

    /* Desktop: fix the sidebar to the right and restore canvas margin */
    #sidebar {
        display: flex;
        width: 420px;
        flex-direction: column;
        z-index: 50;
    }

    /* Ensure mobile-only UI is hidden on desktop widths */
    .mobile-menu-container,
    .mobile-submenu-container,
    #btn-mobile-back {
        display: none;
    }
}

.customizer-title {
    padding: .25em;
    margin: 0px;
}


/* Loader Container */
#customizer-loader {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.8);
    /* Semi-transparent white */
    z-index: 50;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    transition: opacity 0.3s ease;
    pointer-events: none;
    /* Let clicks pass through when fading out */
}

#customizer-loader.hidden {
    opacity: 0;
    pointer-events: none;
}

/* Spinner Animation */
.loader-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #e0e0e0;
    border-top: 4px solid #333;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 10px;
}

#loader-text {
    font-family: sans-serif;
    font-size: 14px;
    color: #333;
    font-weight: 600;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

/* ── Viewer-only mode ──────────────────────────────────────────────────────
 *
 * The outer wrapper uses WooCommerce's own gallery CSS classes, so the
 * theme's column layout positions it correctly. We only need to give the
 * canvas a height and hide the sidebar shell.
 * ─────────────────────────────────────────────────────────────────────── */

.psc-viewer-only #app-container {
    display: block;
    width: 100%;
    height: 500px;
}

/* The base #canvas-container rule already sets width/height 100% */

.psc-viewer-only #btn-undo,
.psc-viewer-only #btn-redo {
    display: none;
}

.psc-viewer-only #sidebar.psc-hidden {
    display: none;
}



/* ── Share Modal ──────────────────────────────────────────────────────────── */

#share-modal {
    display: none;
    position: fixed;
    z-index: 100000;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    align-items: center;
    justify-content: center;
}

#share-modal.active {
    display: flex;
}

.share-modal-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    cursor: pointer;
}

.share-modal-content {
    position: relative;
    z-index: 1;
    background: white;
    border-radius: 12px;
    max-width: 480px;
    width: 90%;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
    overflow: hidden;
}

.share-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 1px solid #eee;
}

.share-modal-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
}

.share-modal-close {
    background: none;
    border: none;
    font-size: 28px;
    cursor: pointer;
    color: #999;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.share-modal-close:hover {
    color: #333;
}

.share-modal-body {
    padding: 20px;
    overflow-y: auto;
    overflow-x: hidden;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.share-preview {
    width: 100%;
    aspect-ratio: 1 / 1;
    background: #f5f5f5;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid #eee;
}

.share-preview img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.share-option label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: #888;
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.share-link-container {
    display: flex;
    gap: 8px;
}

#share-link-input {
    flex: 1;
    padding: 10px 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 13px;
    font-family: monospace;
    background: #f9f9f9;
    color: #333;
}

/* --- Watermark / Branding --- */
.dprcu-watermark {
    position: absolute;
    bottom: 12px;
    right: 12px;
    opacity: 0.5;
    transition: opacity 0.3s ease;
    z-index: 10;
    background-color: black;
}

.dprcu-watermark:hover {
    opacity: 0.7;
}

.dprcu-watermark a {
    padding: 4px 8px;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    font-size: 14px;
    text-decoration: none;
}

.dprcu-watermark img {
    max-width: 100px !important;
    max-height: 40px;
    width: auto;
    height: auto;
    display: block;
}

.btn-link-copy {
    padding: 10px 16px;
    background: #096dd9;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    font-size: 13px;
    white-space: nowrap;
    flex-shrink: 0;
}

.btn-link-copy:hover {
    background: #0753c3;
}

.share-buttons {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
}

.share-btn {
    padding: 10px 16px;
    border: 1px solid #ddd;
    border-radius: 6px;
    background: white;
    cursor: pointer;
    font-weight: 500;
    font-size: 13px;
    transition: all 0.15s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.share-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.share-btn-facebook {
    color: #1877f2;
    border-color: #1877f2;
}

.share-btn-facebook:hover {
    background: #f0f2f5;
}

.share-btn-twitter {
    color: #1da1f2;
    border-color: #1da1f2;
}

.share-btn-twitter:hover {
    background: #f7f9fa;
}

.share-btn-linkedin {
    color: #0a66c2;
    border-color: #0a66c2;
}

.share-btn-linkedin:hover {
    background: #f3f6f8;
}

.share-btn-pinterest {
    color: #e60023;
    border-color: #e60023;
}

.share-btn-pinterest:hover {
    background: #fff5f5;
}

.btn-download-image {
    width: 100%;
    padding: 12px;
    background: #f5f5f5;
    border: 1px solid #ddd;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 500;
    font-size: 13px;
    transition: background 0.15s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    color: #333;
}

.btn-download-image svg {
    width: 16px;
    height: 16px;
    stroke: currentColor;
    stroke-width: 2;
    fill: none;
}

.btn-download-image:hover {
    background: #e8e8e8;
}

@media (max-width: 768px) {
    .share-modal-content {
        max-width: 100%;
        width: 100%;
        border-radius: 16px 16px 0 0;
        max-height: 90vh;
        position: fixed;
        bottom: 0;
        left: 0;
    }

    #share-modal.active {
        align-items: flex-end;
    }

    .share-buttons {
        grid-template-columns: 1fr;
    }
}

/* --- Help Modal --- */
#help-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.5);
    z-index: 9999;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
}

#help-modal.active {
    opacity: 1;
    pointer-events: auto;
}

.help-modal-content {
    position: relative;
    z-index: 1;
    background: white;
    border-radius: 12px;
    max-width: 500px;
    width: 90%;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
    overflow: hidden;
}

.help-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 1px solid #eee;
}

.help-modal-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
}

.help-modal-close {
    background: none;
    border: none;
    font-size: 28px;
    cursor: pointer;
    color: #999;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.help-modal-close:hover {
    color: #333;
}

.help-modal-body {
    padding: 20px;
    overflow-y: auto;
    flex-grow: 1;
}

.shortcuts-section {
    margin-bottom: 24px;
}

.shortcuts-section:last-child {
    margin-bottom: 0;
}

.shortcuts-section h4 {
    margin: 0 0 12px 0;
    font-size: 14px;
    font-weight: 600;
    color: #333;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.shortcut-item {
    display: flex;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid #f0f0f0;
    gap: 8px;
}

.shortcut-item:last-child {
    border-bottom: none;
}

.shortcut-item kbd:first-of-type {
    margin-left: auto;
}

.shortcut-keys {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 0;
}

.shortcut-icon {
    width: 20px;
    height: 20px;
    stroke: currentColor;
    stroke-width: 2;
    fill: none;
    color: #666;
    flex-shrink: 0;
}

kbd {
    background: #f9f9f9;
    border: 1px solid #ccc;
    border-radius: 3px;
    padding: 3px 6px;
    font-family: monospace;
    font-size: 12px;
    font-weight: 600;
    color: #333;
    box-shadow: 0 1px 0 rgba(0, 0, 0, 0.1), inset 0 1px 0 rgba(255, 255, 255, 0.8);
    display: inline-block;
    margin: 0 2px;
}

.kbd-plus {
    margin: 0 4px;
    color: #333;
    font-size: 11px;
    font-weight: 600;
}

.shortcut-desc {
    flex-grow: 0;
    padding: 0 8px;
    font-size: 13px;
    color: #666;
}

.help-modal-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    cursor: pointer;
}

@media (max-width: 768px) {
    .help-modal-content {
        max-width: 100%;
        width: 100%;
        border-radius: 16px 16px 0 0;
        max-height: 90vh;
        position: fixed;
        bottom: 0;
        left: 0;
    }

    #help-modal.active {
        align-items: flex-end;
    }

    .shortcut-key {
        font-size: 10px;
        padding: 3px 6px;
    }

    .shortcut-desc {
        font-size: 12px;
    }

    .shortcut-icon {
        width: 18px;
        height: 18px;
    }

    kbd {
        font-size: 11px;
        padding: 2px 5px;
    }

    /* Make canvas square on mobile: use aspect-ratio so it stays width x width */
    #canvas-container {
        margin-right: 0;
        margin-bottom: 0;
    }

    #shoe-canvas {
        aspect-ratio: 1 / 1.5;
        width: 100%;
        height: auto;
    }

    #sidebar-content {
        padding: 8px;
        overflow: auto;
    }

    #sidebar-action-bar {
        justify-content: space-between;
    }

    /* Larger swatch sizes for the mobile bottom bar */
    #sidebar-content .color-swatch {
        height: 100px;
    }

    #sidebar-content .logic-swatch {
        height: 100px;
    }

    #sidebar-content .swatch-name {
        font-size: 13px;
    }

    #view-controls {
        left: 4px;
    }

    .color-swatches{
        grid-template-columns: repeat(3, 1fr);
    }
}