:root {
    --alabaster: #ffffff;
    --stone: #f5f1e9;
    --champagne: #4f866a;
    --champagne-light: #e8f2ec;
    --charcoal: #14120f;
    --slate: #5f625c;
    --border: rgba(34, 31, 27, 0.12);
    --ink-soft: #34322d;
    --surface: rgba(255, 255, 255, 0.82);
    --transition: all 0.4s cubic-bezier(0.25, 1, 0.5, 1);
    --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.02);
    --shadow-md: 0 24px 42px -18px rgba(51, 66, 52, 0.14);
    --shadow-lg: 0 34px 82px -38px rgba(20, 18, 15, 0.42);
    --radius: 16px;
    --bg: var(--alabaster);
    --bg-gradient:
        radial-gradient(circle at 18% 9%, rgba(79, 134, 106, 0.14), transparent 28rem),
        radial-gradient(circle at 88% 13%, rgba(197, 177, 132, 0.2), transparent 24rem),
        linear-gradient(180deg, #fbfaf7 0%, #f1eee7 44%, #fbfaf7 100%);
    --surface-hover: rgba(255, 255, 255, 0.9);
    --text: var(--charcoal);
    --text-muted: var(--slate);
    --accent: var(--champagne);
    --accent-muted: var(--champagne-light);
    --font-heading: 'Lexend', 'Outfit', sans-serif;
    --font-body: 'Plus Jakarta Sans', 'Inter', sans-serif;
}

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

body { 
    background: var(--bg-gradient);
    color: var(--text); 
    font-family: var(--font-body); 
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    line-height: 1.55;
}

main {
    flex: 1;
    margin-left: 320px;
    padding: 3.2rem 3rem 4rem;
    background: transparent;
    border: none;
    box-shadow: none;
    backdrop-filter: none;
}

h1, h2, h3, .heading { font-family: var(--font-heading); font-weight: 800; letter-spacing: -0.02em; }

/* Custom Scrollbar */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 10px; }

/* Navigation */
nav {
    position: fixed; top: 0; width: 100%; z-index: 1000;
    background: rgba(251, 250, 247, 0.82);
    border-bottom: 1px solid rgba(34, 31, 27, 0.1);
    backdrop-filter: blur(18px);
    box-shadow: 0 12px 30px rgba(51, 66, 52, 0.06);
    padding: 0.85rem 2rem;
    display: flex; justify-content: space-between; align-items: center;
}
.logo-btn { 
    background: none; border: none; padding: 0;
    display: flex; align-items: center; gap: 0;
    cursor: pointer; font-size: 1rem; font-family: var(--font-heading);
    font-weight: 800; color: var(--text); transition: var(--transition);
}
.logo-btn .logo-shape, .logo-shape {
    width: 84px;
    height: 84px;
    border-radius: 32px;
    background: linear-gradient(135deg, #5f8f74 0%, #4a6b5a 100%);
    border: 2px solid rgba(95, 143, 116, 0.2);
    box-shadow: 0 12px 32px rgba(95, 143, 116, 0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Inter', sans-serif;
    font-weight: 900;
    font-size: 2.5rem;
    color: #fff;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}
.logo-btn img, .logo-img {
    display: block;
}

#loading-overlay {
    position: fixed;
    inset: 0;
    background: #f0f4f8;
    z-index: 99999;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    transition: opacity 0.4s ease;
    opacity: 1;
}
#loading-overlay.hidden { opacity: 0; pointer-events: none; }
#loading-overlay .loading-text { font-family: 'Lexend', sans-serif; color: #0f172a; font-size: 1.5rem; font-weight: 800; letter-spacing: 0.1em; text-transform: uppercase; margin-bottom: 14px; }
#loading-overlay .spinner {
    width: 40px;
    height: 40px;
    border: 4px solid rgba(95, 143, 116, 0.2);
    border-top: 4px solid #5f8f74;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-top: 0;
}
@keyframes spin { 0% { transform: rotate(0deg);} 100% { transform: rotate(360deg);} }

.logo-img {
    width: 106px;
    height: 40px;
    border-radius: 12px;
    object-fit: contain;
    display: block;
    border: none;
    box-shadow: none;
}
.logo-btn .logo-shape { display: none; }
.logo-btn span { display: none !important; }
.logo-btn:hover { opacity: 0.7; }
.logo-mark { width: 24px; height: 24px; background: var(--text); border-radius: 4px; transform: rotate(45deg); }

.nav-actions { display: flex; align-items: center; gap: 1.5rem; }
.cart-trigger { 
    position: relative; background: var(--surface); border: 1px solid var(--border);
    padding: 0.6rem; border-radius: 100px; cursor: pointer; transition: var(--transition);
    color: var(--text); display: flex; align-items: center; justify-content: center;
}
.cart-trigger:hover {
    border-color: var(--accent);
    background: #ffffff;
    color: var(--accent);
    transform: translateY(-2px);
}
.cart-count { 
    position: absolute; top: -5px; right: -5px; background: var(--text); color: white;
    font-size: 0.65rem; font-weight: 800; width: 18px; height: 18px; 
    border-radius: 50%; display: flex; align-items: center; justify-content: center;
}

/* Cart Drawer */
#cartDrawer {
    position: fixed; top: 0; right: -400px; width: 400px; height: 100vh;
    background: var(--surface); border-left: 1px solid var(--border);
    z-index: 2000; transition: var(--transition); padding: 2rem;
    display: flex; flex-direction: column;
    box-shadow: -10px 0 30px rgba(0,0,0,0.05);
    will-change: right;
}
#cartDrawer.open { right: 0; }
.drawer-overlay {
    position: fixed; inset: 0; background: rgba(0,0,0,0.2); backdrop-filter: blur(4px);
    z-index: 1999; display: none;
}
.drawer-overlay.open { display: block; }
.cart-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 2rem; }
.cart-items { flex: 1; overflow-y: auto; margin-bottom: 2rem; }
.cart-item { display: flex; justify-content: space-between; align-items: center; padding: 1rem 0; border-bottom: 1px solid var(--border); }
.checkout-footer { border-top: 1px solid var(--border); padding-top: 1.5rem; }
.close-drawer { cursor: pointer; background: none; border: none; color: var(--text-muted); }

/* Layout Structure */
.wrapper { display: flex; min-height: 100vh; padding-top: 72px; }

/* Sidebar Filter */
aside {
    width: 320px;
    border-right: 1px solid rgba(34, 31, 27, 0.1);
    padding: 2.5rem 1.5rem;
    position: fixed;
    height: calc(100vh - 72px);
    overflow-y: auto;
    background: rgba(255, 255, 255, 0.62);
    backdrop-filter: blur(18px);
}

.search-box {
    position: relative; margin-bottom: 2.5rem;
}
.search-box input {
    width: 100%;
    min-height: 50px;
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 0.8rem 1rem 0.8rem 2.8rem;
    color: var(--text);
    font-size: 0.9rem;
    font-weight: 650;
    transition: var(--transition);
    outline: none;
    box-shadow: 0 14px 34px rgba(51, 66, 52, 0.06);
}
.search-box input:focus { border-color: rgba(95, 143, 116, 0.56); box-shadow: 0 0 0 3px rgba(95, 143, 116, 0.14); }
.search-box i,
.search-box svg {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--accent);
    width: 18px;
    height: 18px;
    pointer-events: none;
}

#sortOrder {
    min-height: 48px;
    appearance: none;
    background:
        linear-gradient(135deg, rgba(255,255,255,0.92), rgba(255,255,255,0.66)) !important;
    border: 1px solid rgba(34, 31, 27, 0.12) !important;
    border-radius: 13px !important;
    box-shadow: 0 14px 28px rgba(51, 66, 52, 0.05);
}

.filter-group {
    margin-bottom: 1.25rem;
    padding: 1rem;
    border: 1px solid rgba(34, 31, 27, 0.1);
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.64);
    box-shadow: 0 18px 38px rgba(51, 66, 52, 0.06);
}
.filter-label { font-size: 0.7rem; font-weight: 800; text-transform: uppercase; color: var(--text-muted); margin-bottom: 1rem; letter-spacing: 0.1em; }

.category-pill {
    display: flex; align-items: center; justify-content: space-between;
    padding: 0.85rem 0.95rem; border-radius: 12px; cursor: pointer;
    transition: var(--transition); margin-bottom: 0.35rem; font-size: 0.9rem; font-weight: 700;
    color: var(--text-muted);
}
.category-pill:hover { background: var(--surface-hover); color: var(--text); }
.category-pill.active {
    background: var(--champagne-light);
    color: var(--accent);
    border: 1px solid rgba(79, 134, 106, 0.2);
    box-shadow: none;
}
.count { font-size: 0.72rem; opacity: 0.8; font-weight: 700; }

/* Main Content */
main { flex: 1; margin-left: 320px; padding: 3.2rem 3rem 4rem; }

.header-section {
    position: relative;
    margin-bottom: 1.5rem;
    max-width: none;
    min-height: 220px;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    padding: clamp(1.2rem, 3vw, 2rem);
    border: 1px solid rgba(34, 31, 27, 0.12);
    border-radius: 28px;
    overflow: hidden;
    background:
        linear-gradient(90deg, rgba(251, 250, 247, 0.94) 0%, rgba(251, 250, 247, 0.78) 50%, rgba(251, 250, 247, 0.18) 100%),
        url("../hero-bg.jpg") center / cover no-repeat;
    box-shadow: var(--shadow-lg);
}
.header-section::before {
    content: "";
    position: absolute;
    inset: 0;
    background:
        radial-gradient(circle at 18% 18%, rgba(79, 134, 106, 0.18), transparent 28rem),
        linear-gradient(180deg, rgba(255,255,255,0) 0%, rgba(20,18,15,0.08) 100%);
    pointer-events: none;
}
.header-section > * {
    position: relative;
    z-index: 1;
}
.hero-kicker {
    display: inline-flex;
    width: fit-content;
    align-items: center;
    gap: 0.55rem;
    font-weight: 850;
    color: var(--accent);
    text-transform: uppercase;
    letter-spacing: 0.2em;
    font-size: 0.72rem;
    margin-bottom: 0.6rem;
    padding: 0.4rem 0.75rem;
    border: 1px solid rgba(79, 134, 106, 0.24);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.78);
    backdrop-filter: blur(10px);
}
.hero-kicker::before {
    content: "";
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--accent);
    box-shadow: 0 0 0 5px rgba(79, 134, 106, 0.12);
}
.header-section h1 {
    max-width: 820px;
    font-size: clamp(1.8rem, 4vw, 2.75rem);
    margin-bottom: 0.6rem;
    line-height: 1.1;
    color: var(--text);
    letter-spacing: -0.035em;
}
.header-section h1 span {
    color: var(--accent);
}
.header-section p {
    color: var(--ink-soft);
    font-size: clamp(0.85rem, 1.1vw, 0.95rem);
    line-height: 1.55;
    max-width: 62ch;
    font-weight: 550;
}
.market-stats {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.6rem;
    max-width: 640px;
    margin-top: 0.8rem;
}
.market-stats div {
    padding: 0.45rem 0.75rem;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.7);
    border: 1px solid rgba(34, 31, 27, 0.1);
    backdrop-filter: blur(12px);
}
.market-stats strong {
    display: block;
    font-family: 'Bricolage Grotesque', sans-serif;
    font-size: 0.88rem;
}
.market-stats span {
    display: block;
    color: var(--text-muted);
    font-size: 0.7rem;
    font-weight: 700;
    margin-top: 0.05rem;
}
.reveal {
    opacity: 0;
    transform: translateY(10px);
    animation: fadeUp 0.8s ease forwards;
}
.reveal.delay-1 { animation-delay: 0.1s; }
.reveal.delay-2 { animation-delay: 0.2s; }
.reveal.delay-3 { animation-delay: 0.3s; }
@keyframes fadeUp {
    to { opacity: 1; transform: translateY(0); }
}

/* Grid */
.products-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.35rem;
}

.product-card {
    background: rgba(255, 255, 255, 0.82);
    border: 1px solid rgba(34, 31, 27, 0.1);
    border-radius: 20px;
    padding: 0.85rem;
    transition: var(--transition);
    display: flex; flex-direction: column; cursor: pointer; position: relative;
    animation: slideUp 0.6s cubic-bezier(0.2, 0, 0, 1) backwards;
    box-shadow: 0 16px 34px rgba(51, 66, 52, 0.07);
    backdrop-filter: blur(10px);
    overflow: hidden;
    will-change: transform, box-shadow;
}
.product-card::before {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(255,255,255,0.5), rgba(79,134,106,0.09));
    opacity: 0;
    transition: var(--transition);
    pointer-events: none;
}
.product-card:hover {
    transform: translateY(-10px);
    border-color: rgba(79, 134, 106, 0.44);
    box-shadow: 0 32px 70px -34px rgba(20, 18, 15, 0.45);
    background: rgba(255, 255, 255, 0.95);
}
.product-card:hover::before { opacity: 1; }

.image-container {
    width: 100%; aspect-ratio: 16/11; border-radius: 15px; overflow: hidden;
    background: #ede8dd; margin-bottom: 1.15rem;
    position: relative;
    z-index: 1;
}
.image-container::after {
    content: "Preview";
    position: absolute;
    right: 0.8rem;
    bottom: 0.8rem;
    padding: 0.42rem 0.62rem;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.78);
    border: 1px solid rgba(255, 255, 255, 0.64);
    color: var(--text);
    font-size: 0.66rem;
    font-weight: 850;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    opacity: 0;
    transform: translateY(8px);
    transition: var(--transition);
    backdrop-filter: blur(10px);
}
.image-container img { width: 100%; height: 100%; object-fit: cover; transition: var(--transition); }
.product-card:hover img { transform: scale(1.05); }
.product-card:hover .image-container::after { opacity: 1; transform: translateY(0); }

.product-info { padding: 0.45rem 0.35rem 0.25rem; display: flex; flex-direction: column; flex-grow: 1; position: relative; z-index: 1; }
.product-meta { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 0.5rem; }
.product-tag {
    font-size: 0.66rem;
    font-weight: 850;
    text-transform: uppercase;
    color: var(--accent);
    letter-spacing: 0.1em;
}
.product-price { font-weight: 850; font-size: 1.13rem; color: #254f35; }

.product-name { font-size: 1.12rem; margin-bottom: 0.45rem; color: var(--text); line-height: 1.25; }
.product-description {
    color: var(--text-muted);
    font-size: 0.84rem;
    line-height: 1.45;
    margin-bottom: 1rem;
    min-height: 2.4em;
}

.button-group {
    display: flex; gap: 0.5rem; margin-top: auto;
}

.add-btn, .buy-btn {
    flex: 1; padding: 0.78rem; border-radius: 10px; font-weight: 700; font-size: 0.78rem;
    cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 0.4rem;
    transition: var(--transition); border: none;
    letter-spacing: 0.02em;
    text-transform: uppercase;
}

.add-btn { background: rgba(255, 255, 255, 0.72); color: var(--text); border: 1px solid var(--border); }
.add-btn:hover { background: #ffffff; transform: translateY(-2px); border-color: var(--accent); color: var(--accent); }

.buy-btn { background: linear-gradient(135deg, #171411 0%, #2f3f34 100%); color: white; box-shadow: 0 10px 24px rgba(20, 18, 15, 0.16); }
.buy-btn { position: relative; overflow: hidden; }
.buy-btn::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(120deg, rgba(255,255,255,0.15), rgba(255,255,255,0));
    opacity: 0;
    transition: var(--transition);
}
.buy-btn:hover {
    background: linear-gradient(135deg, #2f3f34 0%, #4f866a 100%);
    transform: translateY(-3px);
    box-shadow: 0 18px 34px rgba(79, 134, 106, 0.24);
}
.buy-btn:hover::after { opacity: 1; }

/* Empty State */
.empty { text-align: center; padding: 10rem 0; display: none; }
.empty h2 { font-size: 2rem; color: var(--text-muted); }

/* Animated headline */
.typing { display: inline-block; position: relative; }
.typing::after {
    content: '';
    display: inline-block;
    width: 2px;
    height: 1.1em;
    margin-left: 2px;
    background-color: var(--text);
    animation: blink-caret 1s step-end infinite;
    vertical-align: bottom;
}

@keyframes blink-caret {
    0%, 50% { opacity: 1; }
    50.1%, 100% { opacity: 0; }
}

/* Toasts */
.toast-container {
    position: fixed; bottom: 2rem; right: 2rem; z-index: 3000;
    display: flex; flex-direction: column; gap: 0.75rem;
}
.toast {
    background: var(--text); color: white; padding: 1rem 1.5rem; border-radius: 8px;
    font-weight: 700; font-size: 0.85rem; display: flex; align-items: center; gap: 0.75rem;
    box-shadow: 0 20px 40px rgba(0,0,0,0.1); animation: toastIn 0.4s ease forwards;
}

@keyframes toastIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
@keyframes slideUp { from { opacity: 0; transform: translateY(30px); } }

#buyConfirmModal { display: none; }
#buyConfirmModal.open { display: flex; }

/* Responsive */
@media (max-width: 1280px) {
    .products-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 900px) {
    nav {
        padding: 0.65rem 0.9rem;
        border-bottom: 1px solid var(--border);
        flex-wrap: wrap;
        gap: 0.6rem;
        justify-content: space-between;
        align-items: center;
        min-height: 56px;
    }
    .logo-btn {
        font-size: 1rem;
        gap: 0.5rem;
        padding: 0.2rem 0.2rem 0.1rem;
    }
    .nav-actions {
        gap: 0.5rem;
        display: flex;
        align-items: center;
        flex-wrap: wrap;
    }
    .nav-actions a { display: none; }
    .mobile-filter-btn {
        display: inline-flex !important;
        font-size: 0.8rem;
        padding: 0.42rem 0.65rem;
    }
    .cart-trigger { padding: 0.48rem; }

    .wrapper {
        display: block;
        min-height: auto;
        padding-top: 70px;
    }

    .header-section { margin-bottom: 2.2rem; }
    .header-section h1 {
        font-size: 2.7rem;
        line-height: 0.98;
        word-wrap: break-word;
        word-break: break-word;
    }
    .header-section p { font-size: 1rem; }

    .mobile-filter-btn { display: inline-flex !important; }

    aside {
        width: 100%; position: fixed; top: 64px; left: 0; right: 0;
        height: calc(100vh - 64px); overflow-y: auto;
        transform: translateX(-100%); transition: transform 0.25s ease;
        border-right: none; border-bottom: none;
        background: rgba(251, 250, 247, 0.96); padding: 1rem;
        z-index: 1500;
        box-shadow: 0 8px 20px rgba(0,0,0,0.08);
        backdrop-filter: blur(18px);
    }

    aside.open {
        transform: translateX(0);
    }

    .aside-backdrop {
        position: fixed; inset: 0; background: rgba(0,0,0,0.35);
        z-index: 1400; display: none;
    }

    .aside-backdrop.open { display: block; }

    .search-box { margin-bottom: 1.5rem; }
    .search-box input { padding: 0.7rem 1rem 0.7rem 2.8rem; }

    main { margin-left: 0; padding: 1.5rem 1rem 2rem; }
    .header-section {
        min-height: 200px;
        margin-bottom: 1.2rem;
        border-radius: 22px;
        padding: 1rem;
        background:
            linear-gradient(180deg, rgba(251, 250, 247, 0.93) 0%, rgba(251, 250, 247, 0.82) 70%, rgba(251, 250, 247, 0.52) 100%),
            url("../hero-bg.jpg") center / cover no-repeat;
    }
    .header-section h1 { font-size: 1.6rem; line-height: 1.1; }
    .header-section p { font-size: 0.85rem; }
    .market-stats { grid-template-columns: 1fr; margin-top: 0.6rem; gap: 0.4rem; }
    .market-stats div { padding: 0.4rem 0.6rem; }

    .products-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    .product-card {
        padding: 0.65rem;
    }

    .image-container { aspect-ratio: 4/3; }
    .product-name { font-size: 1rem; margin-bottom: 0.5rem; }
    .product-price { font-size: 1rem; }
    .button-group { flex-direction: column; gap: 0.45rem; }
    .add-btn, .buy-btn { font-size: 0.85rem; padding: 0.6rem; }

    #cartDrawer {
        width: 100%; right: -100%; height: 100vh; max-width: 100%;
        border-left: none; border-top: 1px solid var(--border);
        box-shadow: none;
    }
    #cartDrawer.open { right: 0; }

    .checkout-footer { position: sticky; bottom: 0; background: var(--surface); padding: 1rem 0 0; }

    .toast-container { bottom: 1rem; right: 1rem; left: 1rem; }

    #admin-panel { right: 0; left: 0; bottom: 0; width: 100%; max-width: 100%; border-radius: 12px 12px 0 0; }
}

/* Button click micro-interactions */
.add-btn:active,
.buy-btn:active,
.category-pill:active,
.cart-trigger:active,
.logo-btn:active {
    transform: scale(0.97) !important;
}

/* Skeleton Loading Screens */
.skeleton-card {
    background: rgba(255, 255, 255, 0.72);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.9rem;
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    pointer-events: none;
}

.skeleton-image {
    width: 100%;
    aspect-ratio: 16/10;
    border-radius: 12px;
    background: linear-gradient(90deg, #f0ede6 25%, #e1dbd0 50%, #f0ede6 75%);
    background-size: 200% 100%;
    animation: loadingPulse 1.5s infinite;
}

.skeleton-text {
    height: 14px;
    border-radius: 4px;
    background: linear-gradient(90deg, #f0ede6 25%, #e1dbd0 50%, #f0ede6 75%);
    background-size: 200% 100%;
    animation: loadingPulse 1.5s infinite;
}

.skeleton-text.title {
    width: 70%;
    height: 18px;
    margin-bottom: 0.35rem;
}

.skeleton-text.price {
    width: 30%;
    height: 16px;
}

.skeleton-text.desc {
    width: 90%;
    height: 12px;
}

@keyframes loadingPulse {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}
