/* ===== CSS Custom Properties (Light/Dark) ===== */
:root {
    --bg-primary: #ffffff;
    --bg-secondary: #f8f9fa;
    --bg-card: #ffffff;
    --bg-input: #ffffff;
    --text-primary: #1a1a2e;
    --text-secondary: #6c757d;
    --text-muted: #adb5bd;
    --accent: #4361ee;
    --accent-hover: #3a56d4;
    --accent-light: #eef0ff;
    --danger: #ef476f;
    --success: #06d6a0;
    --warning: #ffd166;
    --border: #e9ecef;
    --shadow: 0 2px 8px rgba(0,0,0,0.06);
    --shadow-lg: 0 8px 30px rgba(0,0,0,0.08);
    --radius: 10px;
    --radius-sm: 6px;
    --nav-height: 64px;
    --container: 1200px;
    --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --transition: 0.2s ease;
}

[data-theme="dark"] {
    --bg-primary: #0f0f1a;
    --bg-secondary: #1a1a2e;
    --bg-card: #16213e;
    --bg-input: #1a1a2e;
    --text-primary: #e8e8e8;
    --text-secondary: #a0a0b8;
    --text-muted: #6c6c80;
    --accent: #4cc9f0;
    --accent-hover: #3ab8df;
    --accent-light: #1a2a3e;
    --border: #2a2a3e;
    --shadow: 0 2px 8px rgba(0,0,0,0.2);
    --shadow-lg: 0 8px 30px rgba(0,0,0,0.3);
}

/* ===== Reset & Base ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
    font-family: var(--font);
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    transition: background var(--transition), color var(--transition);
}
a { color: var(--accent); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--accent-hover); }
img { max-width: 100%; height: auto; display: block; }
button, input, select, textarea {
    font-family: inherit;
    font-size: inherit;
    border: none;
    outline: none;
}
ul, ol { list-style: none; }

/* ===== Utility ===== */
.container { max-width: var(--container); margin: 0 auto; padding: 0 20px; width: 100%; }
.text-center { text-align: center; }
.text-muted { color: var(--text-secondary); }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mt-4 { margin-top: 2rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.gap-1 { gap: 0.5rem; }
.gap-2 { gap: 1rem; }
.flex { display: flex; }
.flex-wrap { flex-wrap: wrap; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.grid { display: grid; }
.hidden { display: none !important; }

/* ===== Buttons ===== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.6rem 1.4rem;
    border-radius: var(--radius-sm);
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
    border: 1px solid transparent;
    font-size: 0.9rem;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); color: #fff; }
.btn-outline { background: transparent; border-color: var(--border); color: var(--text-primary); }
.btn-outline:hover { border-color: var(--accent); color: var(--accent); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { opacity: 0.9; }
.btn-sm { padding: 0.4rem 0.8rem; font-size: 0.8rem; }
.btn-lg { padding: 0.8rem 2rem; font-size: 1rem; }
.btn-block { width: 100%; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ===== Forms ===== */
.form-group { margin-bottom: 1rem; }
.form-group label { display: block; margin-bottom: 0.3rem; font-weight: 500; font-size: 0.9rem; }
.form-control {
    width: 100%;
    padding: 0.6rem 0.8rem;
    background: var(--bg-input);
    color: var(--text-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    transition: border-color var(--transition);
}
.form-control:focus { border-color: var(--accent); }
select.form-control { cursor: pointer; }
textarea.form-control { resize: vertical; min-height: 100px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }

/* ===== Navigation ===== */
.navbar {
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    height: var(--nav-height);
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow);
}
.navbar .container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 100%;
}
.nav-brand {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.5px;
}
.nav-brand:hover { color: var(--accent); }
.nav-links { display: flex; align-items: center; gap: 1.5rem; }
.nav-links a {
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 500;
    transition: color var(--transition);
}
.nav-links a:hover { color: var(--accent); }
.nav-actions { display: flex; align-items: center; gap: 1rem; }

/* Cart icon */
.cart-icon {
    position: relative;
    color: var(--text-primary);
    font-size: 1.3rem;
    cursor: pointer;
}
.cart-badge {
    position: absolute;
    top: -8px;
    right: -8px;
    background: var(--accent);
    color: #fff;
    font-size: 0.65rem;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
}
.cart-badge:empty { display: none; }

/* Theme toggle */
.theme-toggle {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 1.2rem;
    padding: 0.3rem;
    border-radius: 50%;
    transition: color var(--transition);
    display: flex;
    align-items: center;
}
.theme-toggle:hover { color: var(--accent); }

/* Mobile menu */
.nav-toggle {
    display: none;
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 1.5rem;
    cursor: pointer;
}

/* ===== Hero ===== */
.hero {
    background: linear-gradient(135deg, var(--accent), #7209b7);
    color: #fff;
    padding: 4rem 0;
    text-align: center;
}
.hero h1 { font-size: 2.5rem; margin-bottom: 0.5rem; font-weight: 700; }
.hero p { font-size: 1.1rem; opacity: 0.9; margin-bottom: 1.5rem; }

/* ===== Product Grid ===== */
.products-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 1.5rem;
}
.product-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    transition: transform var(--transition), box-shadow var(--transition);
    cursor: pointer;
}
.product-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
}
.product-card-img {
    width: 100%;
    height: 220px;
    object-fit: cover;
    background: var(--bg-secondary);
}
.product-card-body { padding: 1rem; }
.product-card-title {
    font-weight: 600;
    font-size: 0.95rem;
    margin-bottom: 0.3rem;
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.product-card-price {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--accent);
}
.product-card-price .compare-price {
    font-size: 0.85rem;
    color: var(--text-muted);
    text-decoration: line-through;
    margin-left: 0.5rem;
    font-weight: 400;
}
.product-card-category {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 0.3rem;
}

/* ===== Product Page ===== */
.product-detail { display: grid; grid-template-columns: 1fr 1fr; gap: 2rem; padding: 2rem 0; }
.product-gallery img {
    width: 100%;
    border-radius: var(--radius);
    background: var(--bg-secondary);
}
.product-gallery-thumbs { display: flex; gap: 0.5rem; margin-top: 0.5rem; }
.product-gallery-thumbs img {
    width: 70px;
    height: 70px;
    object-fit: cover;
    border-radius: var(--radius-sm);
    cursor: pointer;
    border: 2px solid transparent;
    transition: border-color var(--transition);
}
.product-gallery-thumbs img.active,
.product-gallery-thumbs img:hover { border-color: var(--accent); }
.product-info h1 { font-size: 1.8rem; margin-bottom: 0.5rem; }
.product-info .price { font-size: 1.5rem; font-weight: 700; color: var(--accent); margin-bottom: 1rem; }
.product-info .description { color: var(--text-secondary); margin-bottom: 1.5rem; line-height: 1.8; }
.product-variants { margin-bottom: 1.5rem; }
.product-variants label { font-weight: 600; margin-bottom: 0.5rem; display: block; }
.variant-options { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.variant-option {
    padding: 0.4rem 1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition);
    font-size: 0.9rem;
}
.variant-option:hover, .variant-option.active {
    border-color: var(--accent);
    background: var(--accent-light);
    color: var(--accent);
}
.qty-control {
    display: flex;
    align-items: center;
    gap: 0;
    margin-bottom: 1.5rem;
}
.qty-control button {
    width: 40px;
    height: 40px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    color: var(--text-primary);
    font-size: 1.2rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}
.qty-control button:first-child { border-radius: var(--radius-sm) 0 0 var(--radius-sm); }
.qty-control button:last-child { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }
.qty-control input {
    width: 50px;
    height: 40px;
    text-align: center;
    border: 1px solid var(--border);
    border-left: 0;
    border-right: 0;
    background: var(--bg-input);
    color: var(--text-primary);
}

/* ===== Filters Sidebar ===== */
.shop-layout { display: grid; grid-template-columns: 260px 1fr; gap: 2rem; padding: 2rem 0; }
.filters-sidebar {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    height: fit-content;
    position: sticky;
    top: calc(var(--nav-height) + 20px);
}
.filter-group { margin-bottom: 1.5rem; }
.filter-group:last-child { margin-bottom: 0; }
.filter-group h3 {
    font-size: 0.9rem;
    font-weight: 600;
    margin-bottom: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
}
.filter-group ul li { margin-bottom: 0.3rem; }
.filter-group ul li a {
    color: var(--text-secondary);
    font-size: 0.9rem;
    display: flex;
    justify-content: space-between;
    padding: 0.3rem 0;
}
.filter-group ul li a:hover,
.filter-group ul li a.active { color: var(--accent); font-weight: 500; }
.price-range { display: flex; gap: 0.5rem; align-items: center; }
.price-range input { width: 100%; }

/* ===== Cart ===== */
.cart-table { width: 100%; border-collapse: collapse; }
.cart-table th { text-align: left; padding: 0.8rem; border-bottom: 2px solid var(--border); font-size: 0.85rem; color: var(--text-muted); text-transform: uppercase; }
.cart-table td { padding: 0.8rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
.cart-item-img { width: 60px; height: 60px; object-fit: cover; border-radius: var(--radius-sm); }
.cart-item-name { font-weight: 500; }
.cart-item-variant { font-size: 0.85rem; color: var(--text-muted); }
.cart-item-remove { color: var(--danger); cursor: pointer; background: none; border: none; font-size: 0.85rem; }
.cart-item-remove:hover { text-decoration: underline; }
.cart-summary {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    margin-top: 1.5rem;
    max-width: 400px;
    margin-left: auto;
}
.cart-summary-row { display: flex; justify-content: space-between; margin-bottom: 0.5rem; }
.cart-summary-row.total { font-weight: 700; font-size: 1.2rem; border-top: 2px solid var(--border); padding-top: 0.8rem; margin-top: 0.5rem; }

/* ===== Checkout ===== */
.checkout-layout { display: grid; grid-template-columns: 1.2fr 0.8fr; gap: 2rem; padding: 2rem 0; }
.checkout-form { }
.checkout-summary {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    height: fit-content;
    position: sticky;
    top: calc(var(--nav-height) + 20px);
}

/* ===== Auth Pages ===== */
.auth-container {
    max-width: 440px;
    margin: 3rem auto;
    padding: 0 20px;
}
.auth-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 2rem;
    box-shadow: var(--shadow);
}
.auth-card h1 { font-size: 1.5rem; margin-bottom: 0.3rem; }
.auth-card .subtitle { color: var(--text-secondary); margin-bottom: 1.5rem; font-size: 0.9rem; }
.auth-tabs { display: flex; margin-bottom: 1.5rem; border-bottom: 2px solid var(--border); }
.auth-tab {
    padding: 0.6rem 1.2rem;
    cursor: pointer;
    font-weight: 500;
    color: var(--text-secondary);
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: all var(--transition);
    background: none;
}
.auth-tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.auth-divider {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin: 1.2rem 0;
    color: var(--text-muted);
    font-size: 0.85rem;
}
.auth-divider::before, .auth-divider::after { content: ''; flex: 1; height: 1px; background: var(--border); }
.btn-google {
    background: var(--bg-secondary);
    color: var(--text-primary);
    border: 1px solid var(--border);
    width: 100%;
    padding: 0.7rem;
    font-size: 0.9rem;
}
.btn-google:hover { border-color: var(--accent); }

/* ===== Account ===== */
.orders-list { margin-top: 1rem; }
.order-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.2rem;
    margin-bottom: 1rem;
}
.order-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 0.5rem; }
.order-number { font-weight: 600; }
.order-status {
    padding: 0.2rem 0.8rem;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}
.status-pending { background: #fff3cd; color: #856404; }
.status-paid, .status-processing { background: #cce5ff; color: #004085; }
.status-shipped { background: #d4edda; color: #155724; }
.status-delivered { background: #d1e7dd; color: #0f5132; }
.status-cancelled, .status-refunded { background: #f8d7da; color: #721c24; }

/* ===== Footer ===== */
.footer {
    margin-top: auto;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border);
    padding: 2rem 0;
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.85rem;
}

/* ===== Alerts ===== */
.alert {
    padding: 0.8rem 1.2rem;
    border-radius: var(--radius-sm);
    margin-bottom: 1rem;
    font-size: 0.9rem;
}
.alert-success { background: #d1e7dd; color: #0f5132; }
.alert-error { background: #f8d7da; color: #842029; }
.alert-info { background: #cff4fc; color: #055160; }

/* ===== Badges ===== */
.badge {
    display: inline-block;
    padding: 0.2rem 0.6rem;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
}
.badge-sale { background: var(--danger); color: #fff; }
.badge-new { background: var(--success); color: #fff; }

/* ===== Section ===== */
.section { padding: 3rem 0; }
.section-title { font-size: 1.5rem; font-weight: 700; margin-bottom: 1.5rem; }

/* ===== Empty State ===== */
.empty-state { text-align: center; padding: 4rem 2rem; }
.empty-state .icon { font-size: 3rem; margin-bottom: 1rem; opacity: 0.4; }
.empty-state h2 { font-size: 1.3rem; margin-bottom: 0.5rem; }
.empty-state p { color: var(--text-secondary); margin-bottom: 1.5rem; }

/* ===== Pagination ===== */
.pagination { display: flex; justify-content: center; gap: 0.3rem; margin-top: 2rem; }
.pagination a, .pagination span {
    padding: 0.5rem 0.8rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    font-size: 0.9rem;
    transition: all var(--transition);
}
.pagination a:hover { border-color: var(--accent); color: var(--accent); }
.pagination .active { background: var(--accent); color: #fff; border-color: var(--accent); }

/* ===== Loading Spinner ===== */
.spinner {
    width: 30px;
    height: 30px;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
    margin: 2rem auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== Success Page ===== */
.success-page { text-align: center; padding: 4rem 2rem; }
.success-icon { font-size: 4rem; color: var(--success); margin-bottom: 1rem; }

/* ===== Responsive ===== */
@media (max-width: 900px) {
    .shop-layout { grid-template-columns: 1fr; }
    .filters-sidebar { position: static; }
    .product-detail { grid-template-columns: 1fr; }
    .checkout-layout { grid-template-columns: 1fr; }
    .form-row { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
    .nav-links { display: none; }
    .nav-links.active {
        display: flex;
        flex-direction: column;
        position: absolute;
        top: var(--nav-height);
        left: 0;
        right: 0;
        background: var(--bg-card);
        border-bottom: 1px solid var(--border);
        padding: 1rem 20px;
        box-shadow: var(--shadow-lg);
        z-index: 99;
    }
    .nav-toggle { display: block; }
    .hero h1 { font-size: 1.8rem; }
    .products-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 1rem; }
    .product-card-img { height: 160px; }
    .cart-table { font-size: 0.85rem; }
    .cart-item-img { width: 45px; height: 45px; }
}

@media (max-width: 480px) {
    .products-grid { grid-template-columns: 1fr 1fr; }
    .product-card-img { height: 140px; }
    .auth-card { padding: 1.5rem; }
}

/* ===== Animations ===== */
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.fade-in { animation: fadeIn 0.3s ease; }

/* ===== Toast Notification ===== */
.toast-container { position: fixed; top: 80px; right: 20px; z-index: 1000; display: flex; flex-direction: column; gap: 0.5rem; }
.toast {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.8rem 1.2rem;
    box-shadow: var(--shadow-lg);
    font-size: 0.9rem;
    animation: fadeIn 0.3s ease;
    max-width: 320px;
}
.toast-success { border-left: 3px solid var(--success); }
.toast-error { border-left: 3px solid var(--danger); }

/* ===== Breadcrumbs ===== */
.breadcrumbs { padding: 1rem 0; font-size: 0.85rem; color: var(--text-muted); }
.breadcrumbs a { color: var(--text-muted); }
.breadcrumbs a:hover { color: var(--accent); }
.breadcrumbs span { margin: 0 0.3rem; }

/* ===== Search ===== */
.search-box {
    position: relative;
    max-width: 300px;
}
.search-box input {
    width: 100%;
    padding: 0.5rem 0.8rem 0.5rem 2.2rem;
    background: var(--bg-secondary);
    color: var(--text-primary);
    border: 1px solid var(--border);
    border-radius: 20px;
    font-size: 0.85rem;
}
.search-box input:focus { border-color: var(--accent); }
.search-box::before {
    content: '🔍';
    position: absolute;
    left: 0.7rem;
    top: 50%;
    transform: translateY(-50%);
    font-size: 0.8rem;
}
