:root {
    /* Default Dark Theme (Flipbook) */
    --bg-body: #111;
    --bg-sidebar-start: #1a1a1a;
    --bg-sidebar-end: #2a2a2a;
    --text-nav: #ccc;
    --text-nav-hover: #fff;
    --text-nav-highlight: #fff;
    --bg-nav-highlight: linear-gradient(90deg, #2d2d2d 0%, #252525 100%);
    --bg-nav-highlight-hover: linear-gradient(90deg, #3a3a3a 0%, #2d2d2d 100%);
    --border-nav: #333;

    /* Page & Content */
    --bg-page: #fff;
    --text-main: #000;
    --text-muted: #555;
    --text-body: #ccc;
}

[data-theme="light"] {
    --bg-body: #f4f4f4;
    --bg-sidebar-start: #ffffff;
    --bg-sidebar-end: #e0e0e0;
    --text-nav: #444;
    --text-nav-hover: #000;
    --text-nav-highlight: #000;
    --bg-nav-highlight: linear-gradient(90deg, #e0e0e0 0%, #d0d0d0 100%);
    --bg-nav-highlight-hover: linear-gradient(90deg, #d0d0d0 0%, #c0c0c0 100%);
    --border-nav: #ccc;

    --text-body: #333;
    --text-muted: #666;
}

/* GENERAL & FONTS */
body {
    margin: 0;
    padding: 0;
    background-color: var(--bg-body);
    color: var(--text-body);
    font-family: 'Roboto', sans-serif;
    height: 100vh;
    width: 100vw;
    overflow: hidden;
    transition: background-color 0.3s ease;
}

/* CONTAINER SETUP */
.book-container {
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 5px;
    box-sizing: border-box;
}

h1,
h2,
h3 {
    font-family: 'Playfair Display', serif;
    font-weight: 400;
    margin: 0;
}

/* BOOK STRUCTURE */
.page {
    background-color: #fff;
    box-sizing: border-box;
    border-right: 1px solid #ddd;
    box-shadow: inset 3px 0 10px rgba(0, 0, 0, 0.05);
    overflow: hidden;
    overflow: hidden;
    /* Ensure text on pages takes priority over global theme text color */
    color: #000;
}

/* Force dark text for inputs and labels inside pages even in Dark Mode */
.page label,
.page input,
.page select,
.page textarea,
.page h2,
.page p,
.form-section-title {
    color: #000 !important;
    border-color: #ccc;
}

.page input,
.page textarea,
.page select {
    background: #fff !important;
    color: #000 !important;
    border: 1px solid #ccc !important;
}

.page input:focus,
.page textarea:focus,
.page select:focus {
    border-color: #333 !important;
}

.page-content {
    padding: 12px 10px;
    height: 100%;
    position: relative;
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
}

.no-padding {
    padding: 0;
}

.full-page-img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
    background-color: #fff;
}

/* PAGE NUMBERS */
.page-number {
    position: absolute;
    bottom: 10px;
    font-size: 12px;
    color: var(--text-muted);
    font-weight: bold;
    z-index: 10;
}

.page-number.left {
    left: 20px;
}

.page-number.right {
    right: 20px;
}

/* HEADER */
.header-section {
    border-bottom: 1px solid #000;
    padding-bottom: 5px;
    margin-bottom: 10px;
    flex-shrink: 0;
}

.header-section h2 {
    font-size: 0.9rem;
    letter-spacing: 2px;
    text-transform: uppercase;
    font-family: 'Roboto', sans-serif;
    font-weight: 400;
}

.header-section p {
    font-size: 0.6rem;
    color: var(--text-muted);
    margin-top: 3px;
}

/* FABRIC GRID */
.fabric-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(4, 1fr);
    gap: 2px;
    height: 100%;
    padding-bottom: 10px;
    align-content: start;
}

.fabric-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: start;
    width: 100%;
}

.swatch-img {
    width: 165px;
    height: 165px;
    border: 1px solid #000;
    object-fit: cover;
    margin-bottom: 3px;
}

.fabric-name {
    font-size: 0.6rem;
    font-weight: bold;
    margin-bottom: 4px;
    text-transform: uppercase;
    text-align: center;
    letter-spacing: 0.5px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 150px;
    color: #000 !important;
}

/* QTY SELECTOR */
.qty-selector {
    display: flex;
    align-items: center;
    border: 1px solid #ddd;
    padding: 2px 5px;
    background: white;
    margin-top: 2px;
}

.qty-btn {
    background: none;
    border: none;
    padding: 0 8px;
    cursor: pointer;
    font-size: 1.1rem;
    color: #999;
    line-height: 1;
    font-weight: 300;
}

.qty-btn:hover {
    color: #000;
}

.qty-val {
    padding: 0 5px;
    font-size: 0.95rem;
    font-weight: bold;
    min-width: 20px;
    text-align: center;
    color: var(--text-main);
}

/* --- ORDER SUMMARY --- */
#summary-list {
    /* Large scrolling area */
    height: 100%;
    overflow-y: auto;
    padding-right: 5px;
    /* Space for scrollbar */
    padding-bottom: 20px;
}

/* Custom Scrollbar for sleek look */
#summary-list::-webkit-scrollbar {
    width: 4px;
}

#summary-list::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 4px;
}

.summary-item-row {
    display: flex;
    align-items: center;
    border-bottom: 1px solid #eee;
    padding: 10px 0;
    /* More breathing room */
}

/* SUMMARY IMAGES - MUCH BIGGER NOW */
.summary-mini-img {
    width: 80px;
    /* Increased to 80px */
    height: 80px;
    /* Increased to 80px */
    border: 1px solid #ccc;
    object-fit: cover;
    margin-right: 15px;
    flex-shrink: 0;
    /* Prevent shrinking */
}

.summary-details {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.summary-name {
    font-size: 0.8rem;
    /* Bigger text */
    font-weight: bold;
    text-transform: uppercase;
    display: block;
    margin-bottom: 6px;
}

.summary-controls {
    display: flex;
    align-items: center;
}

.sm-btn {
    background: #eee;
    border: none;
    width: 24px;
    height: 24px;
    font-size: 14px;
    cursor: pointer;
    border-radius: 2px;
}

.sm-btn:hover {
    background: #ddd;
}

.sm-btn-remove {
    background: #ffebee;
    border: 1px solid #ffcdd2;
    color: #c62828;
    width: 24px;
    height: 24px;
    font-size: 16px;
    cursor: pointer;
    border-radius: 2px;
    margin-left: 15px;
    /* Spacing from the qty controls */
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.sm-btn-remove:hover {
    background: #ffcdd2;
    border-color: #ef9a9a;
}

.sm-val {
    font-size: 0.9rem;
    /* Bigger number */
    margin: 0 10px;
    font-weight: bold;
}

/* --- PLACE ORDER FORM (BIGGER & READABLE) --- */
.order-form {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 10px;
    height: 100%;
    overflow-y: auto;
    padding-right: 5px;
    padding-bottom: 20px;
}

/* Custom scrollbar for form */
.order-form::-webkit-scrollbar {
    width: 4px;
}

.order-form::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 4px;
}

/* Form Section Titles */
.form-section-title {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text-body);
    letter-spacing: 1.5px;
    margin-top: 12px;
    margin-bottom: 8px;
    padding-bottom: 5px;
    border-bottom: 2px solid var(--border-nav);
    text-transform: uppercase;
}

.order-form label {
    font-size: 0.65rem;
    font-weight: bold;
    color: var(--text-body);
    letter-spacing: 0.8px;
    margin-bottom: -2px;
}

.order-form input,
.order-form textarea,
.order-form select {
    border: 1px solid #ccc;
    background: #fdfdfd;
    color: #000;
    padding: 8px;
    font-family: 'Roboto', sans-serif;
    font-size: 0.8rem;
    outline: none;
    border-radius: 2px;
}

.order-form input:focus,
.order-form textarea:focus,
.order-form select:focus {
    border-color: #333;
    background: #fff;
    box-shadow: 0 0 5px rgba(0, 0, 0, 0.1);
}

.order-form select {
    cursor: pointer;
    appearance: none;
    color: #000;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23333' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 8px center;
    padding-right: 30px;
}

/* Two-column layout for state/postal code */
.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.form-col {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.submit-btn {
    background-color: #222;
    color: white;
    border: none;
    padding: 12px;
    margin-top: 15px;
    font-size: 0.85rem;
    letter-spacing: 2px;
    cursor: pointer;
    text-transform: uppercase;
    font-weight: bold;
    border-radius: 2px;
    transition: all 0.3s ease;
}

.submit-btn:hover {
    background-color: #555;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}


/* --- NAVIGATION SIDEBAR --- */
#nav-toggle {
    position: fixed;
    top: 20px;
    left: 20px;
    z-index: 1000;
    background: linear-gradient(135deg, var(--bg-sidebar-start) 0%, var(--bg-sidebar-end) 100%);
    color: var(--text-nav-hover);
    border: none;
    padding: 12px 18px;
    font-size: 1.3rem;
    cursor: pointer;
    border-radius: 6px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    transition: all 0.3s ease;
}

#nav-toggle:hover {
    background: linear-gradient(135deg, var(--bg-sidebar-end) 0%, var(--bg-sidebar-start) 100%);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4);
}

#nav-sidebar {
    position: fixed;
    top: 0;
    left: -260px;
    /* Hidden by default */
    width: 250px;
    height: 100vh;
    background: linear-gradient(180deg, var(--bg-sidebar-start) 0%, var(--bg-sidebar-end) 100%);
    z-index: 999;
    box-shadow: 4px 0 20px rgba(0, 0, 0, 0.5);
    transition: left 0.4s ease;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

#nav-sidebar.open {
    left: 0;
}

.nav-menu {
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
    margin-top: 70px;
}

.nav-menu h3 {
    padding: 0 20px 12px;
    border-bottom: 2px solid var(--border-nav);
    margin-bottom: 15px;
    color: var(--text-nav-hover);
    font-size: 1rem;
    letter-spacing: 2px;
    font-weight: 600;
    flex-shrink: 0;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.nav-menu ul {
    list-style: none;
    padding: 0;
    margin: 0;
    overflow-y: auto;
    flex-grow: 1;
    padding-bottom: 20px;
}

/* Scrollbar styling for nav menu */
.nav-menu ul::-webkit-scrollbar {
    width: 8px;
}

.nav-menu ul::-webkit-scrollbar-track {
    background: var(--bg-sidebar-start);
}

.nav-menu ul::-webkit-scrollbar-thumb {
    background: #555;
    border-radius: 4px;
}

.nav-menu ul::-webkit-scrollbar-thumb:hover {
    background: #777;
}

.nav-menu li {
    padding: 14px 20px;
    cursor: pointer;
    font-size: 1rem;
    color: var(--text-nav);
    border-bottom: 1px solid var(--border-nav);
    transition: all 0.3s ease;
    font-weight: 500;
    letter-spacing: 0.5px;
}

.nav-menu li:hover {
    background: var(--bg-nav-highlight-hover);
    color: var(--text-nav-hover);
    padding-left: 28px;
    border-left: 4px solid #d4af37;
}

.nav-menu li.highlight {
    font-weight: 700;
    color: var(--text-nav-highlight);
    background: var(--bg-nav-highlight);
    border-left: 3px solid #4a9eff;
}

.nav-menu li.highlight:hover {
    background: var(--bg-nav-highlight-hover);
    border-left: 4px solid #6bb3ff;
}

/* TERMS & CONDITIONS PAGE */
.tcs-content {
    font-size: 0.7rem;
    line-height: 1.35;
    text-align: left;
    color: #222;
    overflow-y: auto;
    height: 100%;
    padding-bottom: 10px;
    padding-right: 5px;
}

.tcs-content::-webkit-scrollbar {
    width: 3px;
}

.tcs-content::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 2px;
}

.tcs-content strong {
    display: block;
    margin-top: 8px;
    margin-bottom: 1px;
    font-size: 0.75rem;
    font-weight: 800;
    color: #000;
    text-transform: uppercase;
    border-bottom: 1px solid #eee;
    padding-bottom: 1px;
}

/* ADMIN LINK */
.nav-menu li.admin-link {
    background: linear-gradient(135deg, #d4af37 0%, #f4e4a6 100%);
    color: #000;
    font-weight: bold;
    margin-top: 15px;
    border-top: 2px solid #c9a02c;
    border-left: none;
    box-shadow: 0 2px 8px rgba(212, 175, 55, 0.3);
}

.nav-menu li.admin-link:hover {
    background: linear-gradient(135deg, #c9a02c 0%, #d4af37 100%);
    padding-left: 28px;
    border-left: 4px solid #fff;
    box-shadow: 0 4px 12px rgba(212, 175, 55, 0.5);
}

.nav-menu li.admin-link a {
    color: #000;
    text-decoration: none;
    display: block;
}

/* Language Toggle */
.lang-toggle {
    display: flex;
    gap: 5px;
    padding: 15px 20px;
    border-bottom: 2px solid #eee;
    margin-bottom: 10px;
    flex-shrink: 0;
}

.lang-btn {
    flex: 1;
    padding: 8px 12px;
    background: #f4f4f4;
    border: 1px solid #ddd;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 500;
    color: #555;
    transition: all 0.3s ease;
}

.lang-btn:hover {
    background: #e8e8e8;
}

.lang-btn.active {
    background: #222;
    color: #fff;
    border-color: #222;
}

/* Navigation Logo */
.nav-logo {
    padding: 25px 20px;
    text-align: center;
    border-bottom: 2px solid #444;
    margin-bottom: 15px;
    background: linear-gradient(180deg, #0a0a0a 0%, #1a1a1a 100%);
    flex-shrink: 0;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.5);
}

.logo-img {
    max-width: 180px;
    height: auto;
    display: block;
    margin: 0 auto;
    filter: brightness(1.1);
}

/* LIGHTBOX STYLES */
.lightbox-overlay {
    display: none;
    /* Hidden by default */
    position: fixed;
    z-index: 2000;
    /* On top of everything */
    padding-top: 50px;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0, 0, 0, 0.9);
    /* Black w/ opacity */
}

.lightbox-content {
    margin: auto;
    display: block;
    width: 80%;
    max-width: 700px;
    max-height: 80vh;
    object-fit: contain;
    animation-name: zoom;
    animation-duration: 0.3s;
}

@keyframes zoom {
    from {
        transform: scale(0)
    }

    to {
        transform: scale(1)
    }
}

.lightbox-close {
    position: absolute;
    top: 15px;
    right: 35px;
    color: #f1f1f1;
    font-size: 40px;
    font-weight: bold;
    transition: 0.3s;
    cursor: pointer;
}

.lightbox-close:hover,
.lightbox-close:focus {
    color: #bbb;
    text-decoration: none;
    cursor: pointer;
}

/* Response for smaller screens */
@media only screen and (max-width: 700px) {
    .lightbox-content {
        width: 100%;
    }
}

/* Zoom Icon on Patterns */
.zoom-icon {
    position: absolute;
    top: 5px;
    right: 5px;
    background: rgba(255, 255, 255, 0.7);
    border-radius: 50%;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 14px;
    color: #333;
    z-index: 5;
    transition: all 0.2s ease;
}

.zoom-icon:hover {
    background: rgba(255, 255, 255, 0.9);
    transform: scale(1.1);
}

/* INPUT ERROR STATE */
.input-error {
    border: 2px solid #ff4444 !important;
    background-color: #ffe6e6 !important;
    transition: all 0.3s ease;
}

.input-error:focus {
    border-color: #cc0000 !important;
    box-shadow: 0 0 5px rgba(204, 0, 0, 0.3) !important;
}

/* --- ENHANCED LIGHTBOX STYLES --- */
.lightbox-overlay {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0, 0, 0, 0.85);
    /* Darker backdrop */
    backdrop-filter: blur(5px);
}

.lightbox-content {
    background-color: #fff;
    margin: 5% auto;
    /* 15% from the top and centered */
    padding: 0;
    border: 1px solid #888;
    width: 90%;
    max-width: 900px;
    height: auto;
    max-height: 90vh;
    border-radius: 4px;
    position: relative;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
}

.lightbox-close {
    color: #aaa;
    position: absolute;
    top: 10px;
    right: 20px;
    font-size: 35px;
    font-weight: bold;
    z-index: 10;
    cursor: pointer;
    line-height: 1;
}

.lightbox-close:hover,
.lightbox-close:focus {
    color: #000;
    text-decoration: none;
    cursor: pointer;
}

.lightbox-body {
    display: flex;
    height: 100%;
    overflow: hidden;
}

.lightbox-image-container {
    flex: 6;
    /* 60% with */
    background: #f5f5f5;
    display: flex;
    justify-content: center;
    align-items: center;
    border-right: 1px solid #eee;
    padding: 20px;
}

.lightbox-image-container img {
    max-width: 100%;
    max-height: 80vh;
    /* Keep it within view */
    object-fit: contain;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

.lightbox-details {
    flex: 4;
    /* 40% width */
    padding: 40px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

/* Lightbox Typography */
.lightbox-details h2 {
    font-family: 'Playfair Display', serif;
    font-size: 2rem;
    margin-bottom: 5px;
    color: #000;
}

.pattern-id {
    color: #888;
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 30px;
    border-bottom: 1px solid #eee;
    padding-bottom: 15px;
}

/* Stock Status Colors */
.lb-stock-info {
    margin-bottom: 30px;
    background: #fafafa;
    padding: 15px;
    border-radius: 4px;
}

#lb-stock-status {
    font-weight: bold;
    font-size: 1.1rem;
    display: block;
    margin-bottom: 5px;
}

.status-in-stock {
    color: #2e7d32;
}

.status-low-stock {
    color: #f57c00;
}

.status-out-of-stock {
    color: #c62828;
}

.stock-detail {
    font-size: 0.85rem;
    color: #666;
    margin: 0;
}

/* Big Qty Selector */
.lb-controls {
    margin-bottom: 20px;
}

.lb-controls label {
    display: block;
    font-size: 0.9rem;
    color: #333;
    margin-bottom: 8px;
    font-weight: 500;
}

.qty-selector.large {
    display: inline-flex;
    padding: 5px;
    border: 2px solid #000;
}

.qty-selector.large .qty-btn {
    font-size: 1.5rem;
    width: 40px;
    height: 40px;
    color: #000;
}

.qty-selector.large .qty-val {
    font-size: 1.5rem;
    min-width: 60px;
    line-height: 40px;
}

.lb-instruction {
    font-size: 0.8rem;
    color: #999;
    font-style: italic;
    margin-top: auto;
    /* Push to bottom */
}

/* Mobile Responsiveness for Lightbox */
@media (max-width: 768px) {
    .lightbox-body {
        flex-direction: column;
        overflow-y: auto;
    }

    .lightbox-image-container {
        flex: none;
        height: 300px;
        padding: 0;
    }

    .lightbox-image-container img {
        width: 100%;
        height: 100%;
        object-fit: cover;
    }

    .lightbox-details {
        flex: none;
        padding: 20px;
    }

    .lightbox-content {
        margin: 0;
        width: 100%;
        height: 100%;
        max-height: 100%;
        border-radius: 0;
    }

    .lightbox-close {
        color: #000;
        background: rgba(255, 255, 255, 0.8);
        width: 40px;
        height: 40px;
        border-radius: 50%;
        text-align: center;
        line-height: 40px;
        top: 10px;
        right: 10px;
    }
}

/* --- OUT OF STOCK BADGE --- */
.fabric-item.out-of-stock .swatch-img {
    opacity: 0.5;
    filter: grayscale(100%);
    cursor: not-allowed;
}

.out-of-stock-overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.7);
    color: #fff;
    padding: 5px 10px;
    font-size: 0.75rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 1px;
    pointer-events: none;
    white-space: nowrap;
    z-index: 5;
}