:root {
    --bg: #ffffff;
    --bg-gradient: linear-gradient(180deg, #f8fafc 0%, #f1f5f9 55%, #ffffff 100%);
    --surface: rgba(255, 255, 255, 0.96);
    --surface-hover: #f4f6f3;
    --border: #e2e8f0;
    --text: #0f172a;
    --text-muted: #64748b;
    --accent: #8fcaac;
    --accent-muted: #e5f8ec;
    --radius: 14px;
    --transition: all 0.35s cubic-bezier(0.22, 1, 0.36, 1);
}

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

body { 
    background: var(--bg-gradient);
    color: var(--text); 
    font-family: 'Inter', sans-serif; 
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

main {
    flex: 1;
    margin-left: 320px;
    padding: 3rem;
    background: var(--surface);
    border-radius: 24px;
    border: 1px solid var(--border);
    box-shadow: 0 20px 45px rgba(27, 52, 39, 0.08);
    backdrop-filter: blur(4px);
}

h1, h2, h3, .heading { font-family: 'Bricolage Grotesque', sans-serif; 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: #ffffff;
    border-bottom: 1px solid var(--border); 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: 'Bricolage Grotesque', sans-serif;
    font-weight: 800; color: var(--text); transition: var(--transition);
}
.logo-btn .logo-shape, .logo-shape {
    width: 84px;
    height: 84px;
    border-radius: 20px;
    background: linear-gradient(135deg, #0ea5e9 0%, #8b5cf6 100%);
    border: 2px solid rgba(255, 255, 255, 0.45);
    box-shadow: 0 12px 32px rgba(0,0,0,0.25);
    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: #e2e8f0;
    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: #475569; 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(100, 116, 139, 0.3);
    border-top: 4px solid #334155;
    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: 150px;
    height: 65px;
    border-radius: 14px;
    object-fit: cover;
    display: block;
    border: none;
    box-shadow: 0 8px 20px rgba(0,0,0,0.16);
}
.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(--text-muted); background: var(--surface-hover); }
.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);
}
#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 var(--border); padding: 2.5rem;
    position: fixed; height: calc(100vh - 72px); overflow-y: auto;
    background: var(--bg);
}

.search-box {
    position: relative; margin-bottom: 2.5rem;
}
.search-box input {
    width: 100%; background: var(--surface); border: 1px solid var(--border);
    border-radius: 10px; padding: 0.8rem 1rem 0.8rem 2.8rem; color: var(--text);
    font-size: 0.9rem; transition: var(--transition); outline: none;
}
.search-box input:focus { border-color: var(--text); box-shadow: 0 0 0 2px rgba(9,9,11,0.05); }
.search-box i { position: absolute; left: 1rem; top: 50%; transform: translateY(-50%); color: var(--text-muted); }

.filter-group { margin-bottom: 2.5rem; }
.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.75rem 1rem; border-radius: 8px; cursor: pointer;
    transition: var(--transition); margin-bottom: 0.25rem; font-size: 0.9rem; font-weight: 500;
    color: var(--text-muted);
}
.category-pill:hover { background: var(--surface-hover); color: var(--text); }
.category-pill.active { background: var(--text); color: white; }
.count { font-size: 0.7rem; opacity: 0.6; }

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

.header-section { margin-bottom: 4rem; max-width: 800px; }
.header-section h1 { font-size: 4rem; margin-bottom: 1rem; line-height: 0.9; color: var(--text); }
.header-section p { color: var(--text-muted); font-size: 1.1rem; line-height: 1.6; }
.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.5rem;
}

.product-card {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 0.75rem; 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 1px 3px rgba(0,0,0,0.02);
}
.product-card:hover { transform: translateY(-8px); border-color: var(--text-muted); box-shadow: 0 12px 24px rgba(0,0,0,0.05); }

.image-container {
    width: 100%; aspect-ratio: 4/3; border-radius: 8px; overflow: hidden;
    background: #f1f1f1; margin-bottom: 1.25rem;
}
.image-container img { width: 100%; height: 100%; object-fit: cover; transition: var(--transition); }
.product-card:hover img { transform: scale(1.05); }

.product-info { padding: 0.5rem; display: flex; flex-direction: column; flex-grow: 1; }
.product-meta { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 0.5rem; }
.product-tag { font-size: 0.65rem; font-weight: 700; text-transform: uppercase; color: var(--text-muted); letter-spacing: 0.05em; }
.product-price { font-weight: 700; font-size: 1.1rem; color: var(--text); }

.product-name { font-size: 1.1rem; margin-bottom: 0.75rem; color: var(--text); }

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

.add-btn, .buy-btn {
    flex: 1; padding: 0.8rem; border-radius: 8px; font-weight: 700; font-size: 0.8rem;
    cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 0.4rem;
    transition: var(--transition); border: none;
}

.add-btn { background: var(--surface-hover); color: var(--text); border: 1px solid var(--border); }
.add-btn:hover { background: #e4e4e7; transform: scale(0.97); }

.buy-btn { background: var(--text); color: white; }
.buy-btn { position: relative; overflow: hidden; }
.buy-btn::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(120deg, rgba(255,255,255,0.2), rgba(255,255,255,0));
    opacity: 0;
    transition: var(--transition);
}
.buy-btn:hover { background: #27272a; transform: scale(0.97); }
.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.25rem;
        line-height: 1.15;
        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: var(--bg); padding: 1rem;
        z-index: 1500;
        box-shadow: 0 8px 20px rgba(0,0,0,0.08);
    }

    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; }

    main { margin-left: 0; padding: 1.5rem 1rem 2rem; }
    .header-section { margin-bottom: 2rem; }
    .header-section h1 { font-size: 2.2rem; line-height: 1.1; }
    .header-section p { font-size: 1rem; }

    .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; }
}
