/* ============================================================
   FotoDigital Phone Cover Editor - MediaClip Style
   ============================================================ */

:root {
    --cv-primary: #2196F3;
    --cv-primary-hover: #1976D2;
    --cv-danger: #e74c3c;
    --cv-topbar-bg: #263238;
    --cv-topbar-height: 56px;
    --cv-canvas-bg: #e8e8e8;
    --cv-panel-bg: #ffffff;
    --cv-border: #e0e0e0;
    --cv-text: #333333;
    --cv-text-light: #888888;
    --cv-font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --cv-radius: 8px;
}

/* ── Reset ── */
.cover-editor-page,
.cover-editor-page *,
.cover-editor-page *::before,
.cover-editor-page *::after {
    box-sizing: border-box !important;
}
.cover-editor-page {
    font-family: var(--cv-font) !important;
    margin: 0 !important;
    padding: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    overflow: hidden !important;
    display: flex !important;
    flex-direction: column !important;
    background: var(--cv-canvas-bg) !important;
    font-size: 13px !important;
    color: var(--cv-text) !important;
    line-height: 1.4 !important;
    letter-spacing: normal !important;
    min-height: 100vh !important;
    max-width: none !important;
}

/* Hide WP theme elements */
.cover-editor-page .wp-site-blocks,
.cover-editor-page .is-layout-constrained,
.cover-editor-page .is-layout-flow,
.cover-editor-page .has-global-padding,
.cover-editor-page > header,
.cover-editor-page > footer,
.cover-editor-page .wp-block-template-part,
.cover-editor-page .wp-block-navigation,
.cover-editor-page .wp-block-header,
.cover-editor-page .wp-block-footer {
    display: none !important;
}
.cover-editor-page a {
    text-decoration: none !important;
    color: inherit;
}
.cover-editor-page svg {
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* Fix admin bar offset */
html.admin-bar .cover-editor-page {
    height: calc(100vh - 32px) !important;
}


/* ══════════════════════════════════════════════════════════════
   TOP BAR
   ══════════════════════════════════════════════════════════════ */
.cv-topbar {
    height: var(--cv-topbar-height);
    background: var(--cv-topbar-bg);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    flex-shrink: 0;
    z-index: 100;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
    position: relative;
}

/* -- Left: Logo + product name -- */
.cv-topbar-left {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}
.cv-topbar-left img {
    max-height: 32px;
    width: auto;
    display: block;
}
.cv-topbar-left .cv-product-name {
    color: #ffffff;
    font-size: 14px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* -- Center: Model selector -- */
.cv-topbar-center {
    display: flex;
    align-items: center;
    gap: 10px;
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
}
.cv-topbar-center label {
    color: rgba(255, 255, 255, 0.7);
    font-size: 12px;
    font-weight: 500;
    white-space: nowrap;
}

/* -- Right: Price + CTA -- */
.cv-topbar-right {
    display: flex;
    align-items: center;
    gap: 16px;
}
.cv-topbar-price {
    color: #ffffff;
    font-size: 16px;
    font-weight: 700;
    white-space: nowrap;
}


/* ══════════════════════════════════════════════════════════════
   MODEL SELECTOR
   ══════════════════════════════════════════════════════════════ */
.cv-model-select {
    appearance: none;
    -webkit-appearance: none;
    background: rgba(255, 255, 255, 0.1);
    color: #ffffff;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: var(--cv-radius);
    padding: 8px 36px 8px 14px;
    font-size: 13px;
    font-family: var(--cv-font);
    font-weight: 500;
    cursor: pointer;
    outline: none;
    min-width: 200px;
    transition: background 0.2s, border-color 0.2s;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
}
.cv-model-select:hover {
    background-color: rgba(255, 255, 255, 0.18);
    border-color: rgba(255, 255, 255, 0.35);
}
.cv-model-select:focus {
    border-color: var(--cv-primary);
    box-shadow: 0 0 0 2px rgba(33, 150, 243, 0.3);
}
.cv-model-select option {
    background: #263238;
    color: #ffffff;
}


/* ══════════════════════════════════════════════════════════════
   ADD TO CART / BUY BUTTON
   ══════════════════════════════════════════════════════════════ */
.cv-btn-buy {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: var(--cv-danger);
    color: #ffffff;
    font-size: 13px;
    font-weight: 700;
    font-family: var(--cv-font);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 10px 24px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.2s, box-shadow 0.2s, transform 0.1s;
    white-space: nowrap;
}
.cv-btn-buy:hover {
    background: #c0392b;
    box-shadow: 0 2px 8px rgba(231, 76, 60, 0.4);
}
.cv-btn-buy:active {
    transform: scale(0.97);
}
.cv-btn-buy:disabled,
.cv-btn-buy.disabled {
    background: #9e9e9e;
    cursor: not-allowed;
    box-shadow: none;
    opacity: 0.7;
}
.cv-btn-buy:disabled:hover,
.cv-btn-buy.disabled:hover {
    background: #9e9e9e;
    box-shadow: none;
    transform: none;
}
.cv-btn-buy svg {
    width: 16px;
    height: 16px;
    stroke: #ffffff;
}


/* ══════════════════════════════════════════════════════════════
   MAIN AREA (3-column layout)
   ══════════════════════════════════════════════════════════════ */
.cv-main {
    flex: 1;
    display: flex;
    min-height: 0;
    overflow: hidden;
    background: var(--cv-canvas-bg);
}


/* ══════════════════════════════════════════════════════════════
   UPLOAD PANEL (Left)
   ══════════════════════════════════════════════════════════════ */
.cv-upload-panel {
    width: 260px;
    flex-shrink: 0;
    background: var(--cv-panel-bg);
    border-right: 1px solid var(--cv-border);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    padding: 20px 16px;
}
.cv-upload-panel h3 {
    font-size: 13px;
    font-weight: 700;
    color: var(--cv-text);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin: 0 0 14px 0;
    padding: 0;
}

/* Upload zone */
.cv-upload-zone {
    border: 2px dashed var(--cv-border);
    border-radius: var(--cv-radius);
    padding: 30px 16px;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    min-height: 180px;
    justify-content: center;
}
.cv-upload-zone:hover {
    border-color: var(--cv-primary);
    background: rgba(33, 150, 243, 0.04);
}
.cv-upload-zone.dragover {
    border-style: solid;
    border-color: var(--cv-primary);
    background: rgba(33, 150, 243, 0.08);
}
.cv-upload-zone .cv-upload-icon {
    width: 48px;
    height: 48px;
    color: var(--cv-text-light);
    transition: color 0.2s;
}
.cv-upload-zone:hover .cv-upload-icon {
    color: var(--cv-primary);
}
.cv-upload-zone .cv-upload-text {
    font-size: 13px;
    color: var(--cv-text-light);
    line-height: 1.5;
}
.cv-upload-zone .cv-upload-text strong {
    color: var(--cv-primary);
    font-weight: 600;
}
.cv-upload-zone .cv-upload-hint {
    font-size: 11px;
    color: #aaaaaa;
}

/* Upload zone - has photo state */
.cv-upload-zone.has-photo {
    border-style: solid;
    border-color: var(--cv-border);
    padding: 12px;
    min-height: 0;
}
.cv-upload-zone.has-photo:hover {
    border-color: var(--cv-primary);
}

/* Photo preview inside upload zone */
.cv-photo-preview {
    position: relative;
    width: 100%;
    border-radius: calc(var(--cv-radius) - 2px);
    overflow: hidden;
}
.cv-photo-preview img {
    width: 100%;
    height: auto;
    display: block;
    border-radius: calc(var(--cv-radius) - 2px);
}
.cv-photo-preview .cv-photo-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.2s;
    border-radius: calc(var(--cv-radius) - 2px);
}
.cv-photo-preview:hover .cv-photo-overlay {
    opacity: 1;
}
.cv-photo-overlay .cv-btn-change {
    background: #ffffff;
    color: var(--cv-text);
    font-size: 12px;
    font-weight: 600;
    font-family: var(--cv-font);
    border: none;
    border-radius: 6px;
    padding: 8px 16px;
    cursor: pointer;
    transition: background 0.2s;
}
.cv-photo-overlay .cv-btn-change:hover {
    background: #f0f0f0;
}

/* Hidden file input */
.cv-upload-panel input[type="file"] {
    display: none;
}


/* ══════════════════════════════════════════════════════════════
   CANVAS PREVIEW AREA (Center)
   ══════════════════════════════════════════════════════════════ */
/* Preview area: contains model image + phone frame + info */
.cv-preview-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 24px;
    min-width: 0;
    overflow: hidden;
    position: relative;
    gap: 16px;
}

/* Model image preview (shown when a model has an image) */
.cv-model-preview {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    position: absolute;
    left: 24px;
    top: 50%;
    transform: translateY(-50%);
    max-width: 140px;
}
.cv-model-preview img {
    max-width: 120px;
    max-height: 240px;
    object-fit: contain;
    border-radius: var(--cv-radius);
    box-shadow: 0 2px 12px rgba(0,0,0,0.1);
    background: #fff;
    padding: 8px;
}
.cv-model-preview .cv-model-name {
    font-size: 12px;
    font-weight: 600;
    color: var(--cv-text);
    text-align: center;
}

/* Phone case frame - il bordo viene dall'SVG overlay */
.cv-phone-frame {
    position: relative;
    width: 280px;
    height: 550px;
    border-radius: 30px;
    border: none;
    background: #ffffff;
    box-shadow:
        0 6px 30px rgba(0, 0, 0, 0.2),
        0 2px 8px rgba(0, 0, 0, 0.1);
    overflow: visible;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: width 0.3s ease, height 0.3s ease, border-radius 0.3s ease, box-shadow 0.3s;
    flex-shrink: 0;
}
.cv-phone-frame:hover {
    box-shadow:
        0 10px 40px rgba(0, 0, 0, 0.25),
        0 3px 12px rgba(0, 0, 0, 0.12);
}
.cv-canvas-wrap {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}
.cv-phone-frame canvas {
    display: block;
}

/* Placeholder overlay */
.cv-placeholder {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 32px;
    color: var(--cv-text-light);
    pointer-events: none;
    z-index: 2;
}
.cv-placeholder h3 {
    font-size: 16px;
    font-weight: 600;
    margin: 12px 0 4px;
    color: var(--cv-text);
}
.cv-placeholder p {
    font-size: 13px;
    margin: 0;
}
.cv-placeholder-icon {
    opacity: 0.3;
}

/* Mockup SVG overlay inside phone frame */
#cover-mockup-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 10;
    transition: opacity 0.3s ease;
}
#cover-mockup-overlay svg {
    width: 100%;
    height: 100%;
    display: block;
    /* Reset global SVG styles that would break mockup rendering */
    fill: initial;
    stroke: initial;
    stroke-width: initial;
    stroke-linecap: initial;
    stroke-linejoin: initial;
}

/* Model info below the frame */
.cv-model-info {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 8px 20px;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(4px);
    border-radius: 20px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}
.cv-model-info-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--cv-text);
}
.cv-model-info-size {
    font-size: 11px;
    color: var(--cv-text-light);
}


/* ══════════════════════════════════════════════════════════════
   TOOLS PANEL (Right)
   ══════════════════════════════════════════════════════════════ */
.cv-tools-panel {
    width: 220px;
    flex-shrink: 0;
    background: var(--cv-panel-bg);
    border-left: 1px solid var(--cv-border);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    padding: 0;
}

/* Section inside tools panel */
.cv-tools-section {
    padding: 16px;
    border-bottom: 1px solid var(--cv-border);
}
.cv-tools-section:last-child {
    border-bottom: none;
}
.cv-tools-section h4 {
    font-size: 11px;
    font-weight: 700;
    color: var(--cv-text-light);
    text-transform: uppercase;
    letter-spacing: 0.8px;
    margin: 0 0 12px 0;
    padding: 0;
}

/* -- Zoom slider -- */
.cv-zoom-row {
    display: flex;
    align-items: center;
    gap: 10px;
}
.cv-zoom-row input[type="range"] {
    flex: 1;
    -webkit-appearance: none;
    appearance: none;
    height: 4px;
    background: var(--cv-border);
    border-radius: 2px;
    outline: none;
    cursor: pointer;
}
.cv-zoom-row input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 16px;
    height: 16px;
    background: var(--cv-primary);
    border-radius: 50%;
    border: 2px solid #ffffff;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
    cursor: pointer;
    transition: background 0.15s, transform 0.15s;
}
.cv-zoom-row input[type="range"]::-webkit-slider-thumb:hover {
    background: var(--cv-primary-hover);
    transform: scale(1.15);
}
.cv-zoom-row input[type="range"]::-moz-range-thumb {
    width: 16px;
    height: 16px;
    background: var(--cv-primary);
    border-radius: 50%;
    border: 2px solid #ffffff;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
    cursor: pointer;
}
.cv-zoom-value {
    font-size: 12px;
    font-weight: 600;
    color: var(--cv-text);
    min-width: 38px;
    text-align: center;
    background: #f5f5f5;
    border-radius: 4px;
    padding: 3px 6px;
}

/* -- Rotate buttons -- */
.cv-rotate-row {
    display: flex;
    gap: 8px;
}
.cv-btn-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border: 1px solid var(--cv-border);
    border-radius: var(--cv-radius);
    background: #ffffff;
    color: var(--cv-text);
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
    font-family: var(--cv-font);
}
.cv-btn-icon:hover {
    background: #f5f5f5;
    border-color: var(--cv-primary);
    color: var(--cv-primary);
}
.cv-btn-icon:active {
    background: #eeeeee;
}
.cv-btn-icon svg {
    width: 18px;
    height: 18px;
}

/* -- Center / reset button -- */
.cv-btn-outline {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    width: 100%;
    padding: 9px 14px;
    border: 1px solid var(--cv-border);
    border-radius: var(--cv-radius);
    background: #ffffff;
    color: var(--cv-text);
    font-size: 12px;
    font-weight: 600;
    font-family: var(--cv-font);
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.cv-btn-outline:hover {
    background: #f5f5f5;
    border-color: var(--cv-primary);
    color: var(--cv-primary);
}
.cv-btn-outline:active {
    background: #eeeeee;
}
.cv-btn-outline svg {
    width: 14px;
    height: 14px;
}

/* -- Background color swatches -- */
.cv-color-swatches {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 6px;
    margin-bottom: 10px;
}
.cv-color-swatch {
    width: 100%;
    aspect-ratio: 1;
    border-radius: 6px;
    border: 2px solid transparent;
    cursor: pointer;
    transition: border-color 0.15s, transform 0.15s;
    outline: none;
    padding: 0;
}
.cv-color-swatch:hover {
    transform: scale(1.12);
    border-color: rgba(0, 0, 0, 0.15);
}
.cv-color-swatch.active {
    border-color: var(--cv-primary);
    box-shadow: 0 0 0 2px rgba(33, 150, 243, 0.3);
}
/* White swatch needs a visible border */
.cv-color-swatch[data-color="#ffffff"],
.cv-color-swatch[data-color="white"] {
    border-color: var(--cv-border);
}

/* Custom color picker */
.cv-color-custom {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 4px;
}
.cv-color-custom label {
    font-size: 11px;
    color: var(--cv-text-light);
    white-space: nowrap;
}
.cv-color-custom input[type="color"] {
    -webkit-appearance: none;
    appearance: none;
    width: 32px;
    height: 32px;
    border: 1px solid var(--cv-border);
    border-radius: 6px;
    cursor: pointer;
    padding: 2px;
    background: #ffffff;
}
.cv-color-custom input[type="color"]::-webkit-color-swatch-wrapper {
    padding: 0;
}
.cv-color-custom input[type="color"]::-webkit-color-swatch {
    border: none;
    border-radius: 4px;
}


/* ══════════════════════════════════════════════════════════════
   LOADING OVERLAY
   ══════════════════════════════════════════════════════════════ */
.cv-loading {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    z-index: 9999;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.25s, visibility 0.25s;
}
.cv-loading.active {
    opacity: 1;
    visibility: visible;
}
.cv-loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(255, 255, 255, 0.2);
    border-top-color: #ffffff;
    border-radius: 50%;
    animation: cv-spin 0.8s linear infinite;
}
.cv-loading-text {
    color: #ffffff;
    font-size: 14px;
    font-weight: 500;
}

@keyframes cv-spin {
    to { transform: rotate(360deg); }
}


/* ══════════════════════════════════════════════════════════════
   GENERIC UTILITIES
   ══════════════════════════════════════════════════════════════ */
.cv-hidden {
    display: none !important;
}
.cv-sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* General button reset */
.cover-editor-page button {
    font-family: var(--cv-font);
}


/* ══════════════════════════════════════════════════════════════
   SCROLLBAR STYLING (panels)
   ══════════════════════════════════════════════════════════════ */
.cv-upload-panel::-webkit-scrollbar,
.cv-tools-panel::-webkit-scrollbar {
    width: 5px;
}
.cv-upload-panel::-webkit-scrollbar-track,
.cv-tools-panel::-webkit-scrollbar-track {
    background: transparent;
}
.cv-upload-panel::-webkit-scrollbar-thumb,
.cv-tools-panel::-webkit-scrollbar-thumb {
    background: #cccccc;
    border-radius: 3px;
}
.cv-upload-panel::-webkit-scrollbar-thumb:hover,
.cv-tools-panel::-webkit-scrollbar-thumb:hover {
    background: #aaaaaa;
}


/* ══════════════════════════════════════════════════════════════
   RESPONSIVE - Tablet (under 1024px)
   ══════════════════════════════════════════════════════════════ */
@media (max-width: 1024px) {
    .cv-main {
        flex-direction: column;
    }

    .cv-upload-panel {
        width: 100%;
        flex-shrink: 0;
        border-right: none;
        border-bottom: 1px solid var(--cv-border);
        padding: 12px 16px;
        flex-direction: row;
        align-items: center;
        gap: 12px;
        overflow-y: visible;
        overflow-x: auto;
    }
    .cv-upload-panel h3 {
        margin: 0;
        white-space: nowrap;
    }
    .cv-upload-zone {
        min-height: 0;
        padding: 12px 20px;
        flex-direction: row;
        min-width: 200px;
    }
    .cv-upload-zone .cv-upload-icon {
        width: 28px;
        height: 28px;
    }

    .cv-preview-area {
        flex: 1;
        padding: 16px;
    }

    .cv-tools-panel {
        width: 100%;
        flex-shrink: 0;
        border-left: none;
        border-top: 1px solid var(--cv-border);
        flex-direction: row;
        overflow-y: visible;
        overflow-x: auto;
        padding: 0;
    }
    .cv-tools-section {
        border-bottom: none;
        border-right: 1px solid var(--cv-border);
        min-width: 160px;
        padding: 12px 16px;
    }
    .cv-tools-section:last-child {
        border-right: none;
    }

    /* Topbar adjustments */
    .cv-topbar-center {
        position: static;
        transform: none;
    }
    .cv-model-select {
        min-width: 150px;
    }
}


/* ══════════════════════════════════════════════════════════════
   RESPONSIVE - Mobile (under 768px)
   ══════════════════════════════════════════════════════════════ */
@media (max-width: 768px) {
    :root {
        --cv-topbar-height: 48px;
    }

    .cv-topbar {
        padding: 0 12px;
        gap: 8px;
    }
    .cv-topbar-left .cv-product-name {
        display: none;
    }
    .cv-topbar-center {
        position: static;
        transform: none;
    }
    .cv-topbar-center label {
        display: none;
    }
    .cv-model-select {
        min-width: 120px;
        font-size: 12px;
        padding: 6px 30px 6px 10px;
    }
    .cv-topbar-price {
        font-size: 14px;
    }
    .cv-btn-buy {
        padding: 8px 14px;
        font-size: 11px;
    }

    /* Panels full-width, stacked */
    .cv-upload-panel {
        flex-direction: column;
        align-items: stretch;
        padding: 12px;
    }
    .cv-upload-zone {
        flex-direction: column;
        min-width: 0;
    }

    .cv-preview-area {
        padding: 12px;
    }

    .cv-tools-panel {
        flex-direction: column;
    }
    .cv-tools-section {
        border-right: none;
        border-bottom: 1px solid var(--cv-border);
        min-width: 0;
        width: 100%;
    }
    .cv-tools-section:last-child {
        border-bottom: none;
    }
}
