@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

:root {
    --sidebar-width: 270px;
    --primary: #1e3a5f;
    --primary-light: #2a4d7a;
    --accent: #2ecc71;
    --accent-hover: #27ae60;
    --teal: #3498db;
    --teal-light: #eaf4fd;
    --blue-light: #f0f5fa;
    --green-light: #eafaf1;
    --brown-light: #f0f5fa;
    --gold-light: #eafaf1;
    --text-dark: #1a2332;
    --text-muted: #6b7c93;
    --border: #dce4ed;
    --bg-main: #f4f7fa;
    --white: #ffffff;
    --danger: #e74c3c;
    --success: #2ecc71;
    --warning: #f39c12;
    --info: #3498db;
    --shadow-sm: 0 1px 3px rgba(30,58,95,0.08);
    --shadow-md: 0 4px 20px rgba(30,58,95,0.1);
    --shadow-lg: 0 10px 40px rgba(30,58,95,0.15);
    --radius: 14px;
    --radius-sm: 8px;
    --radius-lg: 20px;
}

* { box-sizing: border-box; }

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background-color: var(--bg-main);
    color: var(--text-dark);
    font-size: 0.9rem;
    line-height: 1.6;
}

/* ========================
   SIDEBAR
======================== */
#sidebar {
    min-width: var(--sidebar-width);
    max-width: var(--sidebar-width);
    min-height: 100vh;
    background: linear-gradient(180deg, #1e3a5f 0%, #152d4a 60%, #0f2035 100%) !important;
    transition: margin 0.3s ease;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    z-index: 100;
}

#sidebar.toggled {
    margin-left: calc(-1 * var(--sidebar-width));
}

#sidebar::-webkit-scrollbar { width: 4px; }
#sidebar::-webkit-scrollbar-thumb { background: rgba(46,204,113,0.3); border-radius: 4px; }

.sidebar-header {
    padding: 1.5rem 1.2rem;
    border-bottom: 1px solid rgba(52,152,219,0.2);
    display: flex;
    align-items: center;
    gap: 10px;
}

.sidebar-header h5 {
    color: #ffffff;
    font-weight: 700;
    letter-spacing: -0.3px;
}

.sidebar-header img {
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

#sidebar .nav-link {
    color: rgba(255,255,255,0.7) !important;
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    margin: 2px 8px;
    font-size: 0.85rem;
    font-weight: 500;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 10px;
}

#sidebar .nav-link:hover {
    color: #fff !important;
    background: rgba(46,204,113,0.15);
}

#sidebar .nav-link.active {
    color: #fff !important;
    background: var(--accent);
    font-weight: 600;
    box-shadow: 0 2px 10px rgba(46,204,113,0.3);
}

#sidebar .nav-link i {
    font-size: 1.1rem;
    width: 22px;
    text-align: center;
}

#sidebar .nav-link .badge {
    font-size: 0.7rem;
    padding: 3px 7px;
}

/* Sidebar Section Groups */
.sidebar-section {
    margin-bottom: 2px;
}

.sidebar-section-title {
    display: flex !important;
    align-items: center;
    justify-content: space-between;
    padding: 9px 20px 5px;
    margin-top: 4px;
    cursor: pointer;
    -webkit-user-select: none;
    user-select: none;
}

.sidebar-section-title:hover span {
    color: rgba(52,152,219,0.9);
}

.sidebar-section-title span {
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    color: rgba(52,152,219,0.6);
    transition: color 0.2s;
}

.sidebar-section-title .section-arrow {
    font-size: 0.55rem;
    color: rgba(52,152,219,0.4);
    transition: transform 0.25s ease;
    display: inline-block;
}

.sidebar-section.is-closed .section-arrow {
    transform: rotate(-90deg);
}

.sidebar-section.is-closed .sidebar-section-links {
    display: none !important;
}

/* ========================
   TOP NAVBAR
======================== */
#page-content-wrapper > .navbar {
    background: var(--white) !important;
    border-bottom: 1px solid var(--border);
    padding: 0.75rem 1.5rem;
    box-shadow: var(--shadow-sm);
}

#menu-toggle {
    border: 1px solid var(--border);
    color: var(--text-dark);
    border-radius: var(--radius-sm);
    padding: 6px 10px;
}

#menu-toggle:hover {
    background: var(--blue-light);
}

/* ========================
   LOGIN PAGE
======================== */
.login-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #1e3a5f 0%, #152d4a 40%, #0f2035 100%);
    position: relative;
    overflow: hidden;
}

.login-container::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -30%;
    width: 80%;
    height: 200%;
    background: radial-gradient(ellipse, rgba(46,204,113,0.08) 0%, transparent 70%);
    pointer-events: none;
}

.login-container::after {
    content: '';
    position: absolute;
    bottom: -50%;
    left: -20%;
    width: 60%;
    height: 150%;
    background: radial-gradient(ellipse, rgba(52,152,219,0.06) 0%, transparent 70%);
    pointer-events: none;
}

.login-card {
    background: var(--white);
    border-radius: var(--radius-lg);
    padding: 3rem;
    width: 100%;
    max-width: 440px;
    box-shadow: 0 25px 80px rgba(0,0,0,0.35);
    position: relative;
    z-index: 1;
    border-top: 4px solid var(--accent);
}

.login-card h2 {
    color: var(--primary);
    font-weight: 800;
    font-size: 1.5rem;
    letter-spacing: -0.5px;
}

.login-card .form-label {
    font-weight: 600;
    font-size: 0.82rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.login-card .form-control {
    border-radius: var(--radius-sm);
    padding: 12px 16px;
    border: 2px solid var(--border);
    font-size: 0.9rem;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.login-card .form-control:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(46,204,113,0.15);
}

.login-card .input-group-text {
    background: var(--blue-light);
    border: 2px solid var(--border);
    border-right: none;
    color: var(--primary);
}

.login-card .btn-primary {
    border-radius: var(--radius-sm);
    padding: 12px;
    font-weight: 700;
    font-size: 0.95rem;
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    transition: all 0.2s;
}

.login-card .btn-primary:hover {
    background: var(--accent-hover);
    border-color: var(--accent-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 15px rgba(46,204,113,0.4);
}

/* ========================
   STAT CARDS
======================== */
.stat-card {
    border: none;
    border-radius: var(--radius);
    background: var(--white);
    box-shadow: var(--shadow-sm);
    transition: all 0.3s ease;
    overflow: hidden;
    position: relative;
}

.stat-card::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    background: var(--accent);
    opacity: 0;
    transition: opacity 0.3s;
}

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

.stat-card:hover::after {
    opacity: 1;
}

.stat-card .card-body {
    padding: 1.5rem;
}

.stat-card .stat-icon {
    width: 52px;
    height: 52px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
}

.stat-card .stat-value {
    font-size: 1.9rem;
    font-weight: 800;
    line-height: 1;
    letter-spacing: -1px;
    color: var(--text-dark);
}

.stat-card .stat-label {
    color: var(--text-muted);
    font-size: 0.8rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-top: 4px;
}

/* ========================
   CONTENT CARDS
======================== */
.content-card {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
    overflow: hidden;
}

.content-card .card-header {
    background: var(--white);
    border-bottom: 2px solid var(--border);
    padding: 1rem 1.5rem;
    font-weight: 700;
    font-size: 0.9rem;
    color: var(--text-dark);
}

.content-card .card-body {
    padding: 1.25rem 1.5rem;
}

/* ========================
   TABLES
======================== */
.table-custom {
    border-radius: var(--radius);
    overflow: hidden;
}

.table-custom thead {
    background: var(--primary);
    color: var(--white);
}

.table-custom thead th {
    border: none;
    padding: 14px 16px;
    font-weight: 600;
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.8px;
}

.table-custom tbody td {
    padding: 12px 16px;
    vertical-align: middle;
    border-color: var(--border);
    font-size: 0.88rem;
}

.table-custom tbody tr {
    transition: background 0.15s;
}

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

/* ========================
   BUTTONS
======================== */
.btn-primary {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
    font-weight: 600;
    border-radius: var(--radius-sm);
}

.btn-primary:hover {
    background: var(--accent-hover);
    border-color: var(--accent-hover);
    color: #fff;
}

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

.btn-outline-primary:hover {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}

.btn-outline-secondary {
    border-color: var(--border);
    color: var(--text-muted);
}

.btn-outline-secondary:hover {
    background: var(--blue-light);
    border-color: var(--border);
    color: var(--text-dark);
}

.btn-outline-danger:hover {
    background: var(--danger);
    border-color: var(--danger);
}

.btn-sm {
    border-radius: 6px;
    font-size: 0.8rem;
    padding: 5px 12px;
}

/* ========================
   QUICK ACTIONS
======================== */
.quick-action {
    text-align: center;
    padding: 1.5rem 1rem;
    border-radius: var(--radius);
    background: var(--white);
    border: 2px solid var(--border);
    transition: all 0.25s ease;
    text-decoration: none;
    color: var(--text-dark);
    display: block;
}

.quick-action:hover {
    border-color: var(--accent);
    transform: translateY(-3px);
    box-shadow: var(--shadow-md);
    color: var(--primary);
    background: var(--green-light);
}

.quick-action i {
    font-size: 2rem;
    display: block;
    margin-bottom: 0.5rem;
    color: var(--primary);
}

.quick-action small {
    font-weight: 600;
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

/* ========================
   BADGES
======================== */
.badge {
    font-weight: 600;
    padding: 5px 10px;
    border-radius: 6px;
    font-size: 0.75rem;
    letter-spacing: 0.3px;
}

.badge.bg-primary {
    background: var(--primary) !important;
    color: #fff !important;
}

.badge.bg-success { background: var(--success) !important; }
.badge.bg-danger { background: var(--danger) !important; }
.badge.bg-info { background: var(--info) !important; color: #fff !important; }
.badge.bg-warning { background: var(--warning) !important; color: #fff !important; }

/* ========================
   FORMS
======================== */
.form-control, .form-select {
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 8px 14px;
    font-size: 0.88rem;
    transition: border-color 0.2s, box-shadow 0.2s;
    color: var(--text-dark);
}

.form-control:focus, .form-select:focus {
    border-color: var(--teal);
    box-shadow: 0 0 0 3px rgba(52,152,219,0.1);
}

.form-label {
    font-weight: 600;
    font-size: 0.82rem;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.form-check-input:checked {
    background-color: var(--accent);
    border-color: var(--accent);
}

/* ========================
   ALERTS
======================== */
.alert {
    border-radius: var(--radius-sm);
    border: none;
    font-weight: 500;
}

.alert-success { background: #d5f5e3; color: #1e8449; }
.alert-danger { background: #fadbd8; color: #922b21; }
.alert-warning { background: #fef9e7; color: #7d6608; border-left: 4px solid var(--warning); }
.alert-info { background: var(--teal-light); color: #1a5276; border-left: 4px solid var(--teal); }

/* ========================
   PAGINATION
======================== */
.page-link {
    color: var(--text-dark);
    border-color: var(--border);
    border-radius: 6px !important;
    margin: 0 2px;
    font-weight: 500;
}

.page-item.active .page-link {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}

/* ========================
   PROGRESS BARS
======================== */
.progress {
    border-radius: 20px;
    height: 22px;
    background: var(--blue-light);
}

.progress-bar {
    background: linear-gradient(90deg, var(--accent), var(--teal));
    border-radius: 20px;
    font-size: 0.72rem;
    font-weight: 700;
}

/* ========================
   MODAL
======================== */
.modal-content {
    border-radius: var(--radius);
    border: none;
    box-shadow: var(--shadow-lg);
}

.modal-header {
    border-bottom: 2px solid var(--border);
    padding: 1.2rem 1.5rem;
}

.modal-header h5 {
    font-weight: 700;
    color: var(--text-dark);
}

.modal-footer {
    border-top: 2px solid var(--border);
}

/* ========================
   NAV TABS
======================== */
.nav-tabs .nav-link {
    border-radius: var(--radius-sm) var(--radius-sm) 0 0;
    font-weight: 600;
    color: var(--text-muted);
    border: 2px solid transparent;
}

.nav-tabs .nav-link.active {
    color: var(--primary);
    border-color: var(--border);
    border-bottom-color: var(--white);
}

/* ========================
   SCROLLBAR
======================== */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--blue-light); }
::-webkit-scrollbar-thumb { background: #a8b8cc; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--primary); }

/* ========================
   FOOTER
======================== */
footer {
    color: var(--text-muted);
    border-top: 1px solid var(--border);
    background: var(--white);
}

/* ========================
   STATUS COLORS
======================== */
.status-present { color: var(--success); }
.status-absent { color: var(--danger); }
.status-late { color: var(--warning); }
.status-excused { color: var(--teal); }
.status-paid { color: var(--success); }
.status-pending { color: var(--warning); }
.status-overdue { color: var(--danger); }

/* ========================
   RESPONSIVE - TABLET (max 992px)
======================== */
@media (max-width: 992px) {
    #sidebar {
        margin-left: calc(-1 * var(--sidebar-width));
        position: fixed;
        z-index: 1050;
        top: 0;
        left: 0;
        box-shadow: 4px 0 25px rgba(0,0,0,0.3);
    }
    #sidebar.toggled {
        margin-left: 0;
    }

    /* Overlay when sidebar open */
    .sidebar-overlay {
        display: none;
        position: fixed;
        top: 0; left: 0; right: 0; bottom: 0;
        background: rgba(0,0,0,0.5);
        z-index: 1040;
    }
    .sidebar-overlay.active { display: block; }

    #page-content-wrapper {
        min-width: 100vw;
    }

    .container-fluid { padding: 1rem !important; }

    h3 { font-size: 1.3rem; }

    .stat-card .stat-value { font-size: 1.5rem; }
    .stat-card .stat-label { font-size: 0.72rem; }
    .stat-card .card-body { padding: 1rem; }
    .stat-card .stat-icon { width: 44px; height: 44px; font-size: 1.2rem; }
}

/* ========================
   RESPONSIVE - MOBILE (max 768px)
======================== */
@media (max-width: 768px) {
    .d-flex.justify-content-between.align-items-center.mb-4 {
        flex-direction: column;
        align-items: flex-start !important;
        gap: 10px;
    }

    /* Navbar */
    #page-content-wrapper > .navbar {
        padding: 0.5rem 0.8rem;
    }
    #page-content-wrapper > .navbar .d-flex {
        gap: 8px !important;
    }
    #page-content-wrapper > .navbar .text-muted.small {
        font-size: 0.72rem;
        max-width: 120px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    /* Stat cards 2 columns */
    .row.g-3.mb-4 > [class*="col-lg-3"],
    .row.g-3.mb-4 > [class*="col-md-3"] {
        flex: 0 0 50%;
        max-width: 50%;
    }
    .stat-card .stat-value { font-size: 1.3rem; }
    .stat-card .card-body {
        padding: 0.8rem;
        gap: 8px !important;
    }
    .stat-card .stat-icon { width: 40px; height: 40px; font-size: 1.1rem; border-radius: 10px; }

    /* Quick actions - 3 per row */
    .row.g-3.mb-4 > [class*="col-lg-2"] {
        flex: 0 0 33.33%;
        max-width: 33.33%;
    }
    .quick-action { padding: 0.8rem 0.4rem; }
    .quick-action i { font-size: 1.4rem; margin-bottom: 0.3rem; }
    .quick-action small { font-size: 0.65rem; }

    /* Tables */
    .table-custom thead th { padding: 10px 8px; font-size: 0.68rem; letter-spacing: 0.3px; }
    .table-custom tbody td { padding: 8px; font-size: 0.8rem; }
    .table-responsive { margin: 0 -1px; }

    /* Cards */
    .content-card .card-header { padding: 0.8rem 1rem; font-size: 0.85rem; }
    .content-card .card-body { padding: 0.8rem 1rem; }

    /* Forms */
    .form-control, .form-select { font-size: 0.85rem; padding: 8px 10px; }
    .row.g-3 > [class*="col-md"] { flex: 0 0 100%; max-width: 100%; }

    /* Buttons */
    .btn { font-size: 0.82rem; padding: 8px 14px; }
    .btn-sm { font-size: 0.75rem; padding: 4px 8px; }

    /* Filter bars */
    .card.content-card.mb-3 .row.g-2 > [class*="col-md"] {
        flex: 0 0 100%;
        max-width: 100%;
    }

    /* Timetable */
    .table-bordered td, .table-bordered th { padding: 6px 4px; font-size: 0.7rem; }
    .table-bordered td strong { font-size: 0.72rem; }
    .table-bordered td small { font-size: 0.6rem; }
}

/* ========================
   RESPONSIVE - SMALL MOBILE (max 480px)
======================== */
@media (max-width: 480px) {
    .container-fluid { padding: 0.6rem !important; }

    h3 { font-size: 1.1rem; }

    .row.g-3.mb-4 > [class*="col-lg-3"],
    .row.g-3.mb-4 > [class*="col-md-3"] {
        flex: 0 0 50%;
        max-width: 50%;
    }
    .stat-card .stat-value { font-size: 1.1rem; }
    .stat-card .stat-label { font-size: 0.65rem; }

    .quick-action i { font-size: 1.2rem; }
    .quick-action small { font-size: 0.6rem; }

    .table-custom thead th { font-size: 0.62rem; padding: 8px 5px; }
    .table-custom tbody td { font-size: 0.75rem; padding: 6px 5px; }

    /* Hide less important columns on very small screens */
    .table-custom .hide-mobile { display: none; }

    .badge { font-size: 0.65rem; padding: 3px 6px; }

    #page-content-wrapper > .navbar .text-muted.small { display: none; }
}

/* ========================
   UTILITY
======================== */
.fw-bold { font-weight: 700 !important; }
.text-accent { color: var(--accent); }
.bg-accent { background: var(--accent); }
.border-accent { border-color: var(--accent) !important; }

/* Table bordered for timetable */
.table-bordered { border-color: var(--border); }
.table-dark, .table-bordered thead.table-dark {
    background: var(--primary) !important;
}
.table-bordered thead.table-dark th {
    background: var(--primary);
    border-color: rgba(255,255,255,0.1);
    color: var(--white);
    font-weight: 600;
    font-size: 0.82rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Touch-friendly elements on mobile */
@media (pointer: coarse) {
    .btn-sm { min-height: 38px; min-width: 38px; display: inline-flex; align-items: center; justify-content: center; }
    .form-check-input { width: 1.3em; height: 1.3em; }
    .nav-link { min-height: 44px; }
    #sidebar .nav-link { padding: 12px 14px; }
}

/* Smooth transitions on all interactive elements */
a, button, .btn, .card, .nav-link {
    transition: all 0.2s ease;
}
