:root {
    --bg-dark: #0f172a;
    --bg-glass: rgba(255, 255, 255, 0.05);
    --border-glass: rgba(255, 255, 255, 0.1);
    --primary: #3b82f6;
    --primary-glow: rgba(59, 130, 246, 0.5);
    --text-main: #f8fafc;
    --text-dim: #94a3b8;
    --accent: #10b981;
    --danger: #f43f5e;
    --sidebar-width: 260px;
    --transition: 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background-color: var(--bg-dark);
    color: var(--text-main);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    line-height: 1.5;
    display: flex;
    min-height: 100vh;
}

/* ─── Sidebar ─── */
.sidebar {
    width: var(--sidebar-width);
    height: 100vh;
    background: rgba(15, 23, 42, 0.95);
    border-right: 1px solid var(--border-glass);
    position: fixed;
    display: flex;
    flex-direction: column;
    z-index: 100;
}

.sidebar-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border-glass);
}

.sidebar-header h3 {
    font-size: 1.1rem;
    font-weight: 800;
    background: linear-gradient(to right, #fff, #94a3b8);
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.sidebar-nav {
    flex: 1;
    padding: 1rem 0;
}

.nav-link {
    display: flex;
    align-items: center;
    padding: 0.75rem 1.5rem;
    color: var(--text-dim);
    text-decoration: none;
    font-weight: 600;
    font-size: 0.9rem;
    transition: all var(--transition);
    gap: 0.75rem;
}

.nav-link:hover {
    color: var(--text-main);
    background: var(--bg-glass);
}

.nav-link.active {
    color: var(--text-main);
    background: rgba(59, 130, 246, 0.1);
    border-right: 3px solid var(--primary);
}

.nav-link i {
    width: 18px;
    text-align: center;
}

.sidebar-footer {
    padding: 1rem 0;
    border-top: 1px solid var(--border-glass);
}

/* ─── Main Content ─── */
.main-content {
    margin-left: var(--sidebar-width);
    flex: 1;
    min-height: 100vh;
    padding: 2rem;
    overflow-x: hidden;
    max-width: calc(100vw - var(--sidebar-width));
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

.page-header h1 {
    font-size: 1.75rem;
    font-weight: 900;
    letter-spacing: -0.02em;
}

/* ─── Glass Cards ─── */
.card {
    background: var(--bg-glass);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border-glass);
    border-radius: 16px;
    padding: 1.25rem;
    margin-bottom: 1.25rem;
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.2);
}

.card h3 {
    font-size: 1rem;
    font-weight: 700;
    margin-bottom: 0.75rem;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-size: 0.8rem;
}

/* ─── Forms ─── */
.form-group {
    margin-bottom: 1rem;
}

.form-label {
    display: block;
    margin-bottom: 0.4rem;
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--text-dim);
}

.form-control {
    width: 100%;
    padding: 0.65rem 1rem;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-glass);
    border-radius: 10px;
    color: var(--text-main);
    font-size: 0.9rem;
    font-family: inherit;
    transition: border-color 0.2s;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-glow);
}

textarea.form-control {
    resize: vertical;
    min-height: 80px;
}

/* ─── Buttons ─── */
.btn {
    padding: 0.6rem 1.25rem;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    font-weight: 700;
    font-size: 0.85rem;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.btn:active {
    transform: scale(0.96);
}

.btn-primary {
    background: var(--primary);
    color: #fff;
    box-shadow: 0 4px 10px var(--primary-glow);
}

.btn-primary:hover {
    opacity: 0.9;
}

.btn-danger {
    background: var(--danger);
    color: #fff;
}

.btn-danger:hover {
    opacity: 0.85;
}

.btn-sm {
    padding: 0.4rem 0.75rem;
    font-size: 0.8rem;
}

.btn-ghost {
    background: transparent;
    color: var(--text-dim);
    border: 1px solid var(--border-glass);
}

.btn-ghost:hover {
    color: var(--text-main);
    border-color: rgba(255, 255, 255, 0.3);
}

/* ─── Toggle Switch ─── */
.switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 22px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(255, 255, 255, 0.15);
    transition: .3s;
    border-radius: 34px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 16px;
    width: 16px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .3s;
    border-radius: 50%;
}

input:checked+.slider {
    background-color: var(--accent);
}

input:checked+.slider:before {
    transform: translateX(22px);
}

/* ─── Table ─── */
.admin-table {
    width: 100%;
    border-collapse: collapse;
}

.admin-table th {
    padding: 0.75rem 1rem;
    text-align: left;
    font-size: 0.75rem;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom: 1px solid var(--border-glass);
}

.admin-table td {
    padding: 0.6rem 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
    font-size: 0.9rem;
}

.admin-table tr:hover {
    background: rgba(255, 255, 255, 0.02);
}

/* ─── Category Section ─── */
.category-section {
    margin-bottom: 1.5rem;
}

.category-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1rem;
    background: rgba(59, 130, 246, 0.08);
    border-radius: 12px;
    cursor: pointer;
    transition: background 0.2s;
    margin-bottom: 0.5rem;
}

.category-header:hover {
    background: rgba(59, 130, 246, 0.15);
}

.category-header h4 {
    font-weight: 700;
    font-size: 0.95rem;
}

.category-header .count {
    font-size: 0.75rem;
    color: var(--text-dim);
    background: var(--bg-glass);
    padding: 0.2rem 0.6rem;
    border-radius: 8px;
}

/* ─── Product Row ─── */
.product-row {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.5rem 0.75rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
    transition: background 0.15s;
}

.product-row:hover {
    background: rgba(255, 255, 255, 0.03);
}

.product-thumb {
    width: 48px;
    height: 48px;
    border-radius: 10px;
    object-fit: cover;
    flex-shrink: 0;
}

.product-info {
    flex: 1;
    min-width: 0;
}

.product-name {
    font-weight: 600;
    font-size: 0.9rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.product-desc {
    font-size: 0.75rem;
    color: var(--text-dim);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.product-price {
    font-weight: 800;
    white-space: nowrap;
}

.product-actions {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

/* ─── Modal ─── */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(8px);
    z-index: 500;
    display: none;
    align-items: center;
    justify-content: center;
}

.modal-overlay.active {
    display: flex;
}

.modal {
    background: var(--bg-dark);
    border: 1px solid var(--border-glass);
    border-radius: 20px;
    width: 100%;
    max-width: 500px;
    max-height: 85vh;
    overflow-y: auto;
    padding: 1.5rem;
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.5);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.25rem;
}

.modal-header h3 {
    font-weight: 800;
    font-size: 1.1rem;
}

/* ─── Dashboard Stats ─── */
.stat-card {
    text-align: center;
    padding: 1.5rem;
}

.stat-value {
    font-size: 2.25rem;
    font-weight: 900;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.stat-label {
    color: var(--text-dim);
    font-size: 0.8rem;
    font-weight: 600;
    margin-top: 0.25rem;
}

/* ─── Mobile Toggle & Overlay ─── */
.mobile-toggle {
    display: none;
    position: fixed;
    top: 0.75rem;
    left: 0.75rem;
    z-index: 200;
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: var(--bg-glass);
    backdrop-filter: blur(12px);
    border: 1px solid var(--border-glass);
    color: var(--text-main);
    font-size: 1.1rem;
    cursor: pointer;
    align-items: center;
    justify-content: center;
}

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    z-index: 90;
}

.sidebar-overlay.active {
    display: block;
}

.sidebar-close {
    display: none;
    background: none;
    border: none;
    color: var(--text-dim);
    font-size: 1.1rem;
    cursor: pointer;
    padding: 0.25rem;
}

.sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* ─── Responsive ─── */
@media (max-width: 768px) {
    .mobile-toggle {
        display: flex;
    }

    .sidebar-close {
        display: block;
    }

    .sidebar {
        transform: translateX(-100%);
        transition: transform var(--transition);
    }

    .sidebar.active {
        transform: translateX(0);
    }

    .main-content {
        margin-left: 0;
        max-width: 100vw;
        padding: 3.5rem 0.75rem 1rem 0.75rem;
    }

    .page-header {
        flex-direction: column;
        gap: 0.75rem;
        align-items: flex-start;
    }

    .page-header h1 {
        font-size: 1.35rem;
    }

    /* Fix 2-column grids to stack on mobile */
    .card div[style*="grid-template-columns: 1fr 1fr"] {
        grid-template-columns: 1fr !important;
    }

    /* Dietary tag row: make it more compact on mobile */
    #tags-container > div {
        grid-template-columns: 1fr 1fr auto !important;
    }

    /* Product rows: stack on small screens */
    .product-row {
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    .product-info {
        min-width: calc(100% - 60px);
    }

    .product-actions {
        width: 100%;
        justify-content: flex-end;
    }

    /* Table scroll */
    .admin-table {
        display: block;
        overflow-x: auto;
    }

    /* Modal fill on mobile */
    .modal {
        max-width: calc(100vw - 1rem);
        margin: 0.5rem;
        max-height: 90vh;
    }

    /* Stats grid */
    .stat-card {
        padding: 1rem;
    }

    .stat-value {
        font-size: 1.75rem;
    }
}