/* ===========================
   CUSTOMIZER 2.0 - COMPLETE CSS
   =========================== */

/* Global Reset for Customizer */
.cust-page {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 80px); /* Assuming header is 80px */
    height: calc(100dvh - 80px);
    margin-top: 80px;
    background: #f1f5f9;
    color: #1e293b;
    overflow: hidden; /* Prevent body scroll */
}

.cust-page *, .cust-page *::before, .cust-page *::after {
    box-sizing: border-box;
}

/* Modal Overlay */
.product-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(15, 23, 42, 0.8);
    backdrop-filter: blur(5px);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.product-modal {
    background: #ffffff;
    border-radius: 20px;
    width: 100%;
    max-width: 800px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    overflow: hidden;
}

.modal-header {
    padding: 20px 24px;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h2 {
    margin: 0;
    font-size: 20px;
    color: #0f172a;
}

.modal-close {
    background: transparent;
    border: none;
    font-size: 20px;
    color: #64748b;
    cursor: pointer;
    transition: 0.2s;
}

.modal-close:hover {
    color: #ef4444;
    transform: rotate(90deg);
}

.modal-body {
    padding: 24px;
    overflow-y: auto;
}

.modal-products-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 20px;
}

.modal-product-card {
    border: 2px solid #e2e8f0;
    border-radius: 12px;
    padding: 16px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    background: #f8fafc;
}

.modal-product-card:hover, .modal-product-card.active {
    border-color: #6366f1;
    background: #eef2ff;
    transform: translateY(-4px);
}

.modal-product-card i {
    font-size: 40px;
    color: #6366f1;
    margin-bottom: 12px;
    display: block;
}

.modal-product-card h3 {
    font-size: 15px;
    margin: 0 0 8px 0;
    color: #334155;
}

.modal-product-card p {
    margin: 0;
    font-size: 13px;
    color: #64748b;
    font-weight: 600;
}

/* ---- TOP TOOLBAR ---- */
.cust-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 48px;
    padding: 0 12px;
    background: #ffffff;
    border-bottom: 1px solid #e2e8f0;
    flex-shrink: 0;
    gap: 8px;
}

.cust-toolbar-left {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 800;
    font-size: 14px;
    color: #0f172a;
    white-space: nowrap;
}

.cust-toolbar-left i {
    color: #6366f1;
}

.cust-toolbar-center {
    display: flex;
    align-items: center;
    gap: 2px;
    overflow-x: auto;
    scrollbar-width: none; /* Firefox */
}

.cust-toolbar-center::-webkit-scrollbar {
    display: none;
}

.cust-toolbar-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.tb-btn {
    width: 32px;
    height: 32px;
    border: none;
    background: transparent;
    color: #64748b;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.15s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    flex-shrink: 0;
}

.tb-btn:hover {
    background: #eef2ff;
    color: #6366f1;
}

.tb-btn-danger:hover {
    background: #fef2f2;
    color: #ef4444;
}

.tb-sep {
    width: 1px;
    height: 20px;
    background: #e2e8f0;
    margin: 0 4px;
    flex-shrink: 0;
}

.mobile-panel-toggle {
    display: none; /* Only visible on mobile */
}

/* ---- WORKSPACE ---- */
.cust-workspace {
    display: flex;
    flex: 1;
    overflow: hidden;
    position: relative;
}

/* ---- LEFT SIDEBAR ---- */
.cust-sidebar {
    width: 72px;
    background: #ffffff;
    border-right: 1px solid #e2e8f0;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 12px 0;
    gap: 6px;
    flex-shrink: 0;
    z-index: 10;
}

.sb-btn {
    width: 56px;
    height: 56px;
    border-radius: 12px;
    background: transparent;
    border: none;
    color: #64748b;
    font-size: 20px;
    cursor: pointer;
    transition: all 0.15s;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
}

.sb-btn span {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.3px;
}

.sb-btn:hover, .sb-btn.active {
    background: #eef2ff;
    color: #6366f1;
}

/* ---- PROPERTIES PANEL (LEFT) ---- */
.cust-props {
    width: 220px;
    background: #ffffff;
    border-right: 1px solid #e2e8f0;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    flex-shrink: 0;
    overflow-y: auto;
    z-index: 9;
}

.prop-card {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 12px;
}

.price-card {
    text-align: center;
    background: linear-gradient(135deg, #eef2ff, #faf5ff);
    border-color: #c7d2fe;
}

.prop-price {
    font-size: 24px;
    font-weight: 900;
    color: #0f172a;
}

.prop-price + small {
    color: #94a3b8;
    font-size: 12px;
}

.prop-label {
    display: block;
    font-size: 12px;
    font-weight: 700;
    color: #475569;
    margin-bottom: 8px;
}

.prop-label small {
    color: #94a3b8;
    font-weight: 500;
}

/* Quantity */
.qty-row {
    display: flex;
    align-items: center;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    overflow: hidden;
    background: #fff;
}

.qty-btn {
    width: 36px;
    height: 36px;
    background: #f1f5f9;
    border: none;
    cursor: pointer;
    font-size: 16px;
    color: #475569;
    font-weight: 700;
}

.qty-btn:hover {
    background: #e2e8f0;
}

.qty-input {
    flex: 1;
    border: none;
    text-align: center;
    font-weight: 700;
    font-size: 15px;
    outline: none;
    background: transparent;
    color: #0f172a;
    width: 100%;
}

.qty-input::-webkit-outer-spin-button,
.qty-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
}

/* Color */
.color-row {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.cr-dot {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    cursor: pointer;
    border: 2px solid #e2e8f0;
    transition: all 0.15s;
}

.cr-dot:hover { transform: scale(1.15); }

.cr-dot.active {
    border-color: #6366f1;
    box-shadow: 0 0 0 3px rgba(99,102,241,0.2);
    transform: scale(1.1);
}

/* Toggle */
.tgl {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 22px;
}
.tgl input { opacity: 0; width: 0; height: 0; }
.tgl-slider {
    position: absolute;
    cursor: pointer;
    inset: 0;
    background: #cbd5e1;
    border-radius: 22px;
    transition: 0.3s;
}
.tgl-slider::before {
    content: "";
    position: absolute;
    width: 16px;
    height: 16px;
    left: 3px;
    bottom: 3px;
    background: #fff;
    border-radius: 50%;
    transition: 0.3s;
}
.tgl input:checked + .tgl-slider { background: #6366f1; }
.tgl input:checked + .tgl-slider::before { transform: translateX(22px); }

/* Actions */
.cust-action-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 16px;
    border-radius: 12px;
    font-weight: 800;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
    width: 100%;
    border: none;
}

.cust-action-btn.primary {
    background: #6366f1;
    color: #fff;
    box-shadow: 0 4px 12px rgba(99,102,241,0.3);
}
.cust-action-btn.primary:hover {
    background: #4f46e5;
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(99,102,241,0.4);
}

/* ---- MAIN STAGE ---- */
.cust-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 24px;
    overflow-y: auto;
    min-width: 0;
    background: #eef2f7;
    position: relative;
}

/* LIVE PREVIEW */
.live-preview-section {
    flex-shrink: 0;
    margin-bottom: 20px;
    width: 100%;
}

.live-preview-wrapper {
    display: flex;
    justify-content: center;
    gap: 30px;
    flex-wrap: wrap;
}

.preview-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.preview-svg-container {
    width: 200px;
    height: 200px;
    display: flex;
    align-items: center;
    justify-content: center;
    filter: drop-shadow(0 4px 12px rgba(0,0,0,0.08));
}

.preview-svg-container svg {
    max-width: 100%;
    max-height: 100%;
}

.preview-label {
    font-size: 13px;
    font-weight: 700;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* DESIGN CANVAS */
.design-canvas-wrap {
    position: relative;
    flex: 1;
    min-height: 400px;
    background: #ffffff;
    border: 2px solid #cbd5e1;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 10px 30px rgba(0,0,0,0.05);
    margin: 0 auto;
    width: 100%;
    max-width: 900px; /* Limits max stretch */
    display: flex;
}

.zone-guides {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    pointer-events: none;
    z-index: 0;
}

.zone-guides .zone {
    flex: 1;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    padding-bottom: 20px;
    border-right: 1px dashed rgba(148,163,184,0.4);
}

.zone-guides .zone:last-child {
    border-right: none;
}

.zone-guides .zone span {
    font-size: 4vw; /* Responsive font */
    font-weight: 900;
    color: rgba(203,213,225,0.3);
    letter-spacing: 4px;
    user-select: none;
}

/* Fabric canvas container overrides */
.design-canvas-wrap .canvas-container {
    position: relative !important;
    z-index: 1;
    width: 100% !important;
    height: 100% !important;
}

.design-canvas-wrap canvas {
    width: 100% !important;
    height: 100% !important;
}

/* ---- RIGHT PANEL (Layers & Settings) ---- */
.cust-props-right {
    width: 260px;
    background: #ffffff;
    border-left: 1px solid #e2e8f0;
    padding: 16px;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    overflow-y: auto;
    z-index: 9;
}

.right-panel-section {
    display: flex;
    flex-direction: column;
}

.panel-title {
    font-size: 15px;
    font-weight: 800;
    color: #0f172a;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.panel-title i {
    color: #6366f1;
}

/* Layers */
.layers-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 250px;
    overflow-y: auto;
}

.layer-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.15s;
    font-size: 14px;
    color: #475569;
    font-weight: 600;
}

.layer-item:hover {
    background: #eef2ff;
    border-color: #c7d2fe;
}

.layer-item.active {
    background: #6366f1;
    color: #ffffff;
    border-color: #6366f1;
}

.layer-name {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.layer-delete {
    color: #ef4444;
    cursor: pointer;
    opacity: 0.5;
    font-size: 16px;
}
.layer-item.active .layer-delete {
    color: #ffffff;
}
.layer-delete:hover {
    opacity: 1;
}

.empty-layers {
    padding: 20px;
    text-align: center;
    font-size: 14px;
    color: #94a3b8;
    background: #f8fafc;
    border: 1px dashed #cbd5e1;
    border-radius: 8px;
}

/* Settings Controls */
.setting-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 16px;
}

.setting-group label {
    font-size: 13px;
    font-weight: 700;
    color: #475569;
}

.color-picker-input {
    width: 100%;
    height: 40px;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    cursor: pointer;
    padding: 2px;
}

.styled-select {
    width: 100%;
    padding: 10px;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    font-size: 14px;
    color: #0f172a;
    background: #ffffff;
    outline: none;
    font-family: inherit;
}

.styled-select:focus {
    border-color: #6366f1;
}

.text-format-btns {
    display: flex;
    gap: 8px;
}

.fmt-btn {
    flex: 1;
    height: 36px;
    background: #f1f5f9;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    cursor: pointer;
    color: #475569;
    transition: all 0.15s;
    font-size: 15px;
}

.fmt-btn:hover { background: #e2e8f0; }
.fmt-btn.active {
    background: #6366f1;
    color: #ffffff;
    border-color: #6366f1;
}

.styled-range {
    width: 100%;
    accent-color: #6366f1;
}

/* ---- RESPONSIVE MOBILE FIXES ---- */
@media (max-width: 1024px) {
    /* Tablet */
    .cust-props-right, .cust-props {
        width: 200px;
    }
}

@media (max-width: 768px) {
    /* Mobile Phone */
    .cust-toolbar-right .mobile-panel-toggle {
        display: inline-flex;
    }

    /* Modals for Panels on Mobile */
    .cust-props, .cust-props-right {
        position: fixed;
        top: auto;
        bottom: 0;
        left: 0;
        width: 100%;
        height: 60vh;
        border-top: 2px solid #e2e8f0;
        border-right: none;
        border-left: none;
        border-radius: 20px 20px 0 0;
        box-shadow: 0 -10px 40px rgba(0,0,0,0.1);
        transform: translateY(100%);
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        z-index: 1000;
        padding: 24px;
    }

    .cust-props.show, .cust-props-right.show {
        transform: translateY(0);
    }

    /* A close handle for mobile panels */
    .cust-props::before, .cust-props-right::before {
        content: "";
        position: absolute;
        top: 10px;
        left: 50%;
        transform: translateX(-50%);
        width: 40px;
        height: 5px;
        background: #cbd5e1;
        border-radius: 10px;
    }

    .cust-workspace {
        flex-direction: column;
    }

    .cust-sidebar {
        width: 100%;
        flex-direction: row;
        height: 60px;
        padding: 0 12px;
        overflow-x: auto;
        border-right: none;
        border-bottom: 1px solid #e2e8f0;
        justify-content: flex-start;
        z-index: 5;
    }

    .sb-btn {
        width: 48px;
        height: 48px;
        font-size: 18px;
        flex-shrink: 0;
    }
    
    .sb-btn span { display: none; }

    .cust-main {
        padding: 12px;
        padding-bottom: 80px; /* Space for add to cart button at bottom */
    }

    .preview-svg-container {
        width: 120px;
        height: 120px;
    }

    .zone-guides .zone span {
        font-size: 6vw;
    }
    
    /* Sticky add to cart on mobile */
    .mobile-floating-cart {
        position: fixed;
        bottom: 20px;
        left: 50%;
        transform: translateX(-50%);
        width: 90%;
        z-index: 99;
    }
}

/* Hide footer globally for customizer */
.cust-page ~ .footer { display: none; }
