/* ============================================================
   School Management System - Main Stylesheet
   ============================================================ */

:root {
    --sidebar-width: 260px;
    --sidebar-collapsed-width: 0px;
    --topbar-height: 64px;
    --primary: #4f46e5;
    --primary-dark: #4338ca;
    --primary-light: #eef2ff;
    --secondary: #64748b;
    --success: #22c55e;
    --danger: #ef4444;
    --warning: #f59e0b;
    --info: #3b82f6;
    --dark: #1e293b;
    --light: #f8fafc;
    --border: #e2e8f0;
    --sidebar-bg: #1e293b;
    --sidebar-text: #94a3b8;
    --sidebar-active: #4f46e5;
    --body-bg: #f1f5f9;
    --card-bg: #ffffff;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -2px rgba(0,0,0,0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -4px rgba(0,0,0,0.1);
    --radius: 8px;
    --radius-lg: 12px;
    --transition: all 0.3s ease;
}

/* ---- Reset & Base ---- */
* { box-sizing: border-box; }

body {
    font-family: var(--font-family);
    background: var(--body-bg);
    color: var(--text-primary);
    margin: 0;
    padding: 0;
    font-size: 14px;
    line-height: 1.6;
    overflow-x: hidden;
}

a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-dark); }

/* ============================================================
   SIDEBAR
   ============================================================ */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    z-index: 1040;
    display: flex;
    flex-direction: column;
    transition: var(--transition);
    overflow: hidden;
}

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    min-height: var(--topbar-height);
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    color: #fff;
    font-size: 24px;
}

.sidebar-brand {
    font-size: 20px;
    font-weight: 700;
    letter-spacing: 1px;
}

.sidebar-close {
    color: var(--sidebar-text);
    display: none;
}

.sidebar-body {
    flex: 1;
    overflow-y: auto;
    padding: 12px 0;
}

.sidebar-body::-webkit-scrollbar { width: 4px; }
.sidebar-body::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 4px; }

.sidebar-footer {
    padding: 12px 20px;
    border-top: 1px solid rgba(255,255,255,0.08);
}

/* Nav Items */
.nav-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.nav-item { margin: 2px 8px; }

.nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    color: var(--sidebar-text);
    border-radius: var(--radius);
    transition: var(--transition);
    font-size: 13.5px;
    font-weight: 400;
    white-space: nowrap;
    position: relative;
}

.nav-link:hover {
    color: #fff;
    background: rgba(255,255,255,0.08);
}

.nav-link.active {
    color: #fff;
    background: var(--sidebar-active);
    font-weight: 500;
}

.nav-link i:first-child {
    font-size: 18px;
    width: 22px;
    text-align: center;
    flex-shrink: 0;
}

.nav-arrow {
    margin-left: auto;
    font-size: 12px;
    transition: transform 0.3s ease;
}

.nav-link:not(.collapsed) .nav-arrow {
    transform: rotate(180deg);
}

/* Sub Nav */
.nav-sub {
    list-style: none;
    padding: 4px 0 4px 50px;
    margin: 0;
}

.nav-sub li a {
    display: block;
    padding: 7px 16px;
    color: var(--sidebar-text);
    font-size: 13px;
    border-radius: var(--radius);
    transition: var(--transition);
    position: relative;
}

.nav-sub li a::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 6px;
    height: 6px;
    border-radius: 50%;
    border: 1.5px solid var(--sidebar-text);
    transition: var(--transition);
}

.nav-sub li a:hover,
.nav-sub li a.active {
    color: #fff;
}

.nav-sub li a.active::before {
    background: var(--sidebar-active);
    border-color: var(--sidebar-active);
}

/* Sidebar Overlay */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 1035;
}

/* ============================================================
   MAIN CONTENT
   ============================================================ */
.main-content {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    transition: var(--transition);
}

/* ============================================================
   TOP NAVBAR
   ============================================================ */
.top-navbar {
    position: sticky;
    top: 0;
    z-index: 1020;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    height: var(--topbar-height);
    background: var(--card-bg);
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
}

.top-navbar .btn-link {
    color: var(--text-secondary);
    text-decoration: none;
    padding: 4px;
}

.top-navbar .btn-link:hover {
    color: var(--text-primary);
}

.sidebar-toggle { display: none; }

.avatar-sm {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--primary-light);
    color: var(--primary);
    font-size: 20px;
    flex-shrink: 0;
}

.avatar-sm img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.notification-badge {
    font-size: 10px;
    padding: 2px 5px;
}

.breadcrumb { font-size: 12px; }
.breadcrumb-item a { color: var(--text-secondary); }
.breadcrumb-item.active { color: var(--text-secondary); }

/* ============================================================
   PAGE CONTENT
   ============================================================ */
.page-content {
    padding: 24px;
}

/* ============================================================
   CARDS
   ============================================================ */
.card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    margin-bottom: 24px;
}

.card-header {
    background: transparent;
    border-bottom: 1px solid var(--border);
    padding: 16px 20px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.card-body { padding: 20px; }

/* Stat Cards */
.stat-card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    transition: var(--transition);
    box-shadow: var(--shadow-sm);
}

.stat-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.stat-icon {
    width: 52px;
    height: 52px;
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    flex-shrink: 0;
}

.stat-icon.bg-primary-light { background: #eef2ff; color: var(--primary); }
.stat-icon.bg-success-light { background: #f0fdf4; color: var(--success); }
.stat-icon.bg-danger-light { background: #fef2f2; color: var(--danger); }
.stat-icon.bg-warning-light { background: #fffbeb; color: var(--warning); }
.stat-icon.bg-info-light { background: #eff6ff; color: var(--info); }

.stat-details h3 {
    font-size: 24px;
    font-weight: 700;
    margin: 0;
    line-height: 1.2;
}

.stat-details p {
    margin: 0;
    color: var(--text-secondary);
    font-size: 13px;
}

/* ============================================================
   TABLES
   ============================================================ */
.table {
    font-size: 13.5px;
}

.table thead th {
    background: var(--light);
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
    border-bottom: 2px solid var(--border);
    padding: 12px 16px;
    white-space: nowrap;
}

.table tbody td {
    padding: 12px 16px;
    vertical-align: middle;
    border-bottom: 1px solid var(--border);
}

.table-hover tbody tr:hover {
    background: var(--light);
}

/* ============================================================
   FORMS
   ============================================================ */
.form-control, .form-select {
    border-radius: var(--radius);
    border-color: var(--border);
    font-size: 14px;
    padding: 8px 14px;
}

.form-control:focus, .form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.15);
}

.form-label {
    font-weight: 500;
    font-size: 13px;
    color: var(--text-primary);
    margin-bottom: 6px;
}

.form-text { font-size: 12px; }

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
    border-radius: var(--radius);
    font-size: 13.5px;
    font-weight: 500;
    padding: 8px 16px;
    transition: var(--transition);
}

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

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

.btn-sm { padding: 5px 12px; font-size: 12.5px; }

.btn-icon {
    width: 34px;
    height: 34px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius);
}

/* ============================================================
   BADGES
   ============================================================ */
.badge {
    font-weight: 500;
    font-size: 11.5px;
    padding: 4px 10px;
    border-radius: 6px;
}

/* ============================================================
   ALERTS
   ============================================================ */
.alert {
    border-radius: var(--radius);
    font-size: 14px;
    border: none;
}

/* ============================================================
   LOGIN PAGE
   ============================================================ */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 20px;
}

.login-card {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 420px;
    padding: 40px;
}

.login-logo {
    text-align: center;
    margin-bottom: 32px;
}

.login-logo i {
    font-size: 48px;
    color: var(--primary);
}

.login-logo h2 {
    font-size: 22px;
    font-weight: 700;
    margin: 12px 0 4px;
    color: var(--text-primary);
}

.login-logo p {
    color: var(--text-secondary);
    font-size: 14px;
    margin: 0;
}

.login-form .form-control {
    padding: 12px 16px;
    font-size: 15px;
}

.login-form .btn-primary {
    padding: 12px;
    font-size: 15px;
    font-weight: 600;
    width: 100%;
}

.input-group-text {
    background: var(--light);
    border-color: var(--border);
    color: var(--text-secondary);
}

/* ============================================================
   UTILITIES
   ============================================================ */
.text-muted { color: var(--text-secondary) !important; }
.bg-light-custom { background: var(--light); }
.border-custom { border-color: var(--border) !important; }

.empty-state {
    text-align: center;
    padding: 48px 24px;
    color: var(--text-secondary);
}

.empty-state i {
    font-size: 48px;
    margin-bottom: 16px;
    opacity: 0.5;
}

.empty-state h5 {
    font-weight: 600;
    color: var(--text-primary);
}

.avatar-circle {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 14px;
    flex-shrink: 0;
}

.filter-bar {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 16px 20px;
    margin-bottom: 20px;
    box-shadow: var(--shadow-sm);
}

/* Quick Actions */
.quick-action {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 20px 12px;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    transition: var(--transition);
    color: var(--text-primary);
    text-align: center;
    gap: 8px;
    background: var(--card-bg);
}

.quick-action:hover {
    border-color: var(--primary);
    color: var(--primary);
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.quick-action i {
    font-size: 28px;
    color: var(--primary);
}

.quick-action span {
    font-size: 12.5px;
    font-weight: 500;
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 991.98px) {
    .sidebar {
        transform: translateX(-100%);
    }

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

    .sidebar-close { display: block; }
    .sidebar-overlay.show { display: block; }
    .sidebar-toggle { display: block !important; }

    .main-content {
        margin-left: 0;
    }

    .page-content {
        padding: 16px;
    }
}

@media (max-width: 767.98px) {
    .top-navbar {
        padding: 0 16px;
    }

    .stat-card {
        padding: 16px;
    }

    .stat-icon {
        width: 44px;
        height: 44px;
        font-size: 20px;
    }

    .stat-details h3 { font-size: 20px; }

    .card-header {
        flex-direction: column;
        gap: 12px;
        align-items: flex-start;
    }
}

@media (max-width: 575.98px) {
    .login-card { padding: 28px 24px; }
    .page-content { padding: 12px; }
}

/* ============================================================
   PRINT STYLES
   ============================================================ */
@media print {
    .sidebar, .top-navbar, .sidebar-overlay { display: none !important; }
    .main-content { margin-left: 0 !important; }
    .page-content { padding: 0 !important; }
    .card { box-shadow: none !important; border: 1px solid #ddd !important; }
    .btn, .filter-bar { display: none !important; }
}
