:root {
    /* Fonts */
    --font-heading: 'Playfair Display', serif;
    --font-body: 'Lato', sans-serif;

    /* Light Theme (Default - "Daylight Gallery") */
    --bg-color: #faf9f6;
    /* Off-white / Eggshell */
    --text-color: #2c2c2c;
    --primary-color: #d4af37;
    /* Gold */
    --secondary-color: #999;
    --accent-color: #2c2c2c;
    /* Strong contrast for buttons */
    --card-bg: #ffffff;
    --border-color: #e5e5e5;
    --overlay-color: rgba(255, 255, 255, 0.9);
}

[data-theme="dark"] {
    /* Dark Theme (Default - "Midnight Gallery") */
    --bg-color: #121212;
    /* Deep Black/Gray */
    --text-color: #e0e0e0;
    --primary-color: #d4af37;
    /* Gold remains as luxury accent */
    --secondary-color: #666;
    --accent-color: #ffffff;
    --card-bg: #1e1e1e;
    --border-color: #333;
    --overlay-color: rgba(0, 0, 0, 0.9);
}

/* Global Reset */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font-body);
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.6;
    transition: background-color 0.3s ease, color 0.3s ease;
}

h1,
h2,
h3,
h4,
h5,
h6 {
    font-family: var(--font-heading);
    color: var(--text-color);
    font-weight: 700;
}

a {
    text-decoration: none;
    color: inherit;
    transition: color 0.2s;
}

ul {
    list-style: none;
}

img {
    max-width: 100%;
    display: block;
}

/* Utilities */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

.btn {
    display: inline-block;
    padding: 12px 24px;
    background: var(--primary-color);
    color: #fff;
    font-family: var(--font-body);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    border: none;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn:hover {
    background: var(--text-color);
    color: var(--bg-color);
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--text-color);
    color: var(--text-color);
}

.btn-outline:hover {
    background: var(--text-color);
    color: var(--bg-color);
}

/* Layout - Header */
header {
    padding: 20px 0;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    font-family: var(--font-heading);
    font-size: 1.8rem;
    color: var(--primary-color);
}

nav ul {
    display: flex;
    gap: 20px;
}

nav a {
    font-weight: 700;
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 1px;
}

nav a:hover {
    color: var(--primary-color);
}

/* Layout - Footer */
footer {
    background: var(--card-bg);
    padding: 40px 0;
    margin-top: 60px;
    border-top: 1px solid var(--border-color);
    text-align: center;
    font-size: 0.9rem;
    color: var(--secondary-color);
}

/* Components - Product Card */
.product-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 30px;
    margin: 40px 0;
}

.product-card {
    background: var(--card-bg);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    cursor: pointer;
}

.product-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.1);
}

.product-image {
    aspect-ratio: 4/5;
    background: #eee;
    overflow: hidden;
}

.product-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.5s ease;
}

.product-card:hover .product-image img {
    transform: scale(1.05);
}

.product-info {
    padding: 15px;
    text-align: center;
}

.product-title {
    font-size: 1.1rem;
    margin-bottom: 5px;
}

.product-price {
    color: var(--primary-color);
    font-weight: 700;
}

/* 3D Gallery Container */
#gallery-container {
    width: 100%;
    height: 80vh;
    background: #000;
    position: relative;
    overflow: hidden;
}

/* Admin Styles (Scoped if possible, or loaded separately) */
.admin-container {
    display: flex;
    min-height: 100vh;
}

.admin-sidebar {
    width: 250px;
    background: var(--text-color);
    color: var(--bg-color);
    padding: 20px;
}

.admin-sidebar a {
    display: block;
    padding: 10px;
    color: #aaa;
}

.admin-sidebar a:hover,
.admin-sidebar a.active {
    color: #fff;
    background: rgba(255, 255, 255, 0.1);
}

.admin-content {
    flex: 1;
    padding: 40px;
    background: var(--bg-color);
}

/* Forms */
input,
select,
textarea {
    width: 100%;
    padding: 10px;
    margin-bottom: 15px;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    color: var(--text-color);
    font-family: var(--font-body);
}

/* Cart */
.cart-table {
    width: 100%;
    border-collapse: collapse;
}

.cart-table th,
.cart-table td {
    padding: 15px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

/* Mobile Responsiveness */
@media (max-width: 768px) {
    header {
        flex-direction: column;
        gap: 15px;
        text-align: center;
    }

    .container {
        padding: 0 15px;
    }

    .product-container {
        grid-template-columns: 1fr;
        padding: 20px 0;
    }

    .modal-content {
        grid-template-columns: 1fr;
        padding: 20px;
        width: 95%;
        height: 90vh;
        overflow-y: auto;
    }

    .top-bar,
    .overlay-top-bar {
        top: 10px;
        right: 10px;
        flex-direction: column;
        align-items: flex-end;
        gap: 5px;
    }

    .filters {
        top: 10px;
        left: 10px;
        flex-direction: column;
        gap: 5px;
    }

    .nav-arrow {
        width: 40px;
        height: 40px;
        font-size: 1.5rem;
    }

    h1 {
        font-size: 1.8rem;
    }
}

/* --- MIGRATED INLINE STYLES from index.php --- */

#loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--bg-color);
    z-index: 50;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    transition: opacity 1s;
}

.nav-arrow {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 20;
    background: rgba(0, 0, 0, 0.3);
    color: white;
    border: none;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    font-size: 2rem;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
}

.nav-arrow:hover {
    background: var(--primary-color);
}

.nav-prev {
    left: 5%;
}

.nav-next {
    right: 5%;
}

.overlay-top-bar {
    position: absolute;
    top: 20px;
    right: 40px;
    z-index: 50;
    /* Z-Index Fix */
    display: flex;
    gap: 20px;
    align-items: center;
    opacity: 0;
    transition: opacity 1s ease;
}

.top-link {
    color: var(--text-color);
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.filters {
    position: absolute;
    top: 20px;
    left: 40px;
    z-index: 50;
    /* Z-Index Fix */
    display: flex;
    gap: 15px;
    opacity: 0;
    transition: opacity 1s ease;
}

select {
    padding: 8px 15px;
    border-radius: 20px;
    border: 1px solid var(--border-color);
    background: var(--card-bg);
    color: var(--text-color);
    font-family: 'Lato', sans-serif;
    cursor: pointer;
    min-width: 120px;
}

/* --- AMAZON STYLE MODAL & OVERLAY --- */

#product-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    z-index: 9999;
    justify-content: center;
    align-items: center;
}

.modal-content {
    background: #ffffff;
    padding: 0;
    max-width: 1200px;
    width: 95%;
    height: 90vh;
    display: flex;
    flex-direction: column;
    border-radius: 4px;
    position: relative;
    color: #333;
    overflow: hidden;
    box-shadow: 0 0 50px rgba(0, 0, 0, 0.5);
}

.modal-body {
    display: grid;
    grid-template-columns: 1.2fr 0.8fr;
    gap: 0;
    overflow-y: auto;
    height: 100%;
}

.modal-left {
    padding: 30px;
    background: #f8f8f8;
    display: flex;
    flex-direction: column;
    align-items: center;
    border-right: 1px solid #ddd;
    overflow-y: auto;
}

#modal-image-container {
    width: 100%;
    max-width: 600px;
    margin-bottom: 20px;
    display: flex;
    justify-content: center;
}

.thumbnails-row {
    display: flex;
    gap: 10px;
    margin-top: 20px;
    justify-content: center;
}

.thumb {
    width: 60px;
    height: 60px;
    border: 1px solid #ddd;
    object-fit: cover;
    cursor: pointer;
    opacity: 0.6;
    transition: 0.2s;
}

.thumb.active,
.thumb:hover {
    opacity: 1;
    border-color: var(--primary-color);
    box-shadow: 0 0 5px rgba(0, 0, 0, 0.2);
}

.modal-right {
    padding: 30px;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    background: #fff;
}

#modal-title {
    font-size: 2.2rem;
    margin-bottom: 5px;
    line-height: 1.2;
    color: #333;
}

#modal-category {
    font-size: 0.9rem;
    color: var(--primary-color);
    text-transform: uppercase;
    letter-spacing: 1.5px;
    margin-bottom: 20px;
}

#modal-price {
    font-size: 2.5rem;
    font-weight: 300;
    color: #b12704;
    margin-bottom: 20px;
}

.ar-section-modal {
    width: 100%;
    margin-top: 40px;
    padding-top: 30px;
    border-top: 1px solid #ddd;
}

.cart-success-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.98);
    display: none;
    /* CRITICAL: Must be hidden by default */
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 10001;
}

.close-modal {
    position: absolute;
    top: 15px;
    right: 20px;
    font-size: 2.5rem;
    cursor: pointer;
    color: #333;
    z-index: 10002;
    line-height: 0.7;
    background: #fff;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    text-align: center;
    padding-top: 5px;
}

/* Mobile Adjustments for Modal */
@media (max-width: 768px) {
    .modal-body {
        grid-template-columns: 1fr;
    }
}