:root {
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --bg-body: #f8fafc;
    --bg-sidebar: #ffffff;
    --bg-topbar: #ffffff;
    --bg-card: #ffffff;
    --text-main: #1e293b;
    --text-muted: #64748b;
    --border-color: #e2e8f0;
    --success: #10b981;
    --error: #ef4444;
    --sidebar-width: 260px;
    --topbar-height: 70px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

body {
    background-color: var(--bg-body);
    color: var(--text-main);
}

/* --- Layout Structure --- */
.admin-container {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border-color);
    position: fixed;
    height: 100vh;
    left: 0;
    top: 0;
    z-index: 1000; /* Increased z-index */
    display: flex;
    flex-direction: column;
    transition: transform 0.3s ease-in-out;
}

/* Sidebar Toggle for Mobile */
.sidebar.mobile-hidden {
    transform: translateX(-100%);
}

.sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.4);
    z-index: 999;
    display: none;
}

.sidebar-overlay.active {
    display: block;
}

.sidebar-brand {
    height: var(--topbar-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.5rem;
    font-size: 1.15rem;
    font-weight: 800;
    color: var(--primary);
    border-bottom: 1px solid var(--border-color);
}

.close-sidebar {
    display: none;
    font-size: 1.25rem;
    cursor: pointer;
    color: var(--text-muted);
}

.nav-menu {
    flex: 1;
    padding: 1rem;
    list-style: none;
}

.nav-item {
    margin-bottom: 0.25rem;
}

.nav-link {
    display: flex;
    align-items: center;
    padding: 0.75rem 1rem;
    color: var(--text-muted);
    text-decoration: none;
    border-radius: 8px;
    font-weight: 500;
    font-size: 0.9rem;
    transition: all 0.2s;
}

.nav-link i {
    width: 20px;
    margin-right: 12px;
    font-size: 1rem;
}

.nav-link:hover, .nav-link.active {
    background: #f1f5f9;
    color: var(--primary);
}

/* Main Wrapper */
.main-wrapper {
    flex: 1;
    margin-left: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    min-width: 0;
    transition: margin-left 0.3s ease-in-out;
}

/* Topbar */
.topbar {
    height: var(--topbar-height);
    background: var(--bg-topbar);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.5rem;
    position: sticky;
    top: 0;
    z-index: 900;
}

.menu-toggle {
    display: none;
    font-size: 1.25rem;
    cursor: pointer;
    color: var(--text-main);
    background: #f1f5f9;
    width: 40px;
    height: 40px;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
}

/* Content Area */
.content-area {
    padding: 1.5rem;
    flex: 1;
}

/* Footer */
.footer {
    padding: 1.25rem;
    background: var(--bg-sidebar);
    border-top: 1px solid var(--border-color);
    text-align: center;
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* --- Responsive Layout --- */
@media (max-width: 991px) {
    :root {
        --sidebar-width: 280px;
    }

    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.active {
        transform: translateX(0);
    }

    .main-wrapper {
        margin-left: 0 !important;
    }

    .menu-toggle {
        display: flex;
    }

    .close-sidebar {
        display: block;
    }

    .content-area {
        padding: 1rem;
    }

    /* Small text on mobile */
    /* Micro-typography for mobile */
    h1 { font-size: 1.3rem !important; font-weight: 800 !important; }
    h2 { font-size: 1.15rem !important; }
    h3 { font-size: 1rem !important; }
    p, span, td, th, label, input, button, .btn-primary { font-size: 0.75rem !important; }
    .alert { font-size: 0.75rem !important; padding: 0.75rem !important; }
    
    .card {
        padding: 1rem;
        margin-bottom: 1rem;
    }

    .topbar {
        padding: 0 1rem;
    }

    .mobile-hide {
        display: none !important;
    }

    .desktop-only {
        display: none !important;
    }

    .mobile-only {
        display: block !important;
    }
}

.desktop-only {
    display: block;
}

.mobile-only {
    display: none;
}

/* Cards & Components */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    margin-bottom: 1.5rem;
}

.table-container {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    overflow-x: auto;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 600px; /* Force scroll on very small screens instead of squishing */
}

th {
    text-align: left;
    padding: 1rem;
    background: #f8fafc;
    font-size: 0.75rem;
    text-transform: uppercase;
    font-weight: 700;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border-color);
}

td {
    padding: 0.85rem 1rem;
    border-bottom: 1px solid var(--border-color);
    font-size: 0.9rem;
}

/* Buttons */
.btn-primary {
    background: var(--primary);
    color: white;
    padding: 0.6rem 1.2rem;
    border-radius: 8px;
    text-decoration: none;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.btn-primary:hover {
    background: var(--primary-hover);
}

.alert {
    padding: 1rem;
    border-radius: 8px;
    margin-bottom: 1.5rem;
    font-size: 0.85rem;
}

.alert-success { background: #ecfdf5; color: #065f46; border: 1px solid #a7f3d0; }

/* Form Elements */
.form-group { margin-bottom: 1.25rem; }
.form-group label { display: block; margin-bottom: 0.5rem; font-size: 0.85rem; font-weight: 600; color: var(--text-main); }
.form-group input { 
    width: 100%; 
    padding: 0.75rem 1rem; 
    border: 1px solid var(--border-color); 
    border-radius: 8px; 
    outline: none;
    transition: 0.3s;
    font-size: 0.95rem;
}
.form-group input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1); }
