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

/* ===================== CSS VARIABLES ===================== */
:root {
    --bg-primary: #f4f6f8;
    --bg-surface: #ffffff;
    --primary-color: #00B050;
    --primary-hover: #008f40;
    --active-color: #16a34a;
    --text-main: #333333;
    --text-muted: #6b7280;
    --text-light: #ffffff;
    --male-color: #0070C0;
    --female-color: #C00000;
    --border-color: #e5e7eb;
    --topbar-height: 64px;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.1);
}

/* ===================== RESET ===================== */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* ===================== BASE ===================== */
body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-main);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* ===================== TOP HEADER ===================== */
.top-header {
    background-color: var(--bg-surface);
    box-shadow: var(--shadow-sm);
    position: sticky;
    top: 0;
    z-index: 200;
    width: 100%;
    flex-shrink: 0;
}

.top-header-content {
    height: var(--topbar-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    border-bottom: 1px solid var(--border-color);
}

/* ===================== BRAND ===================== */
.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    font-weight: 700;
    font-size: 1.3rem;
    color: var(--primary-color);
}

.brand-logo {
    height: 38px;
    width: auto;
    object-fit: contain;
    border-radius: 4px;
}

.brand-text {
    display: inline-block;
}

/* ===================== DESKTOP TOPBAR RIGHT ===================== */
.topbar-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.desktop-only {
    display: flex;
}

/* ===================== HAMBURGER ===================== */
.mobile-menu-toggle {
    display: none;
    background: none;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 8px 10px;
    font-size: 1.2rem;
    color: var(--text-main);
    cursor: pointer;
    transition: background 0.2s;
}
.mobile-menu-toggle:hover {
    background: #f3f4f6;
}

/* ===================== NAV MENU ===================== */
.top-nav {
    background-color: var(--bg-surface);
    border-bottom: 1px solid var(--border-color);
}

.nav-container {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 0 24px;
    overflow-x: auto;
    scrollbar-width: none;
}
.nav-container::-webkit-scrollbar { display: none; }

/* Mobile-only user section: hidden on desktop */
.mobile-user-section {
    display: none;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 14px 18px;
    color: var(--text-muted);
    text-decoration: none;
    font-weight: 500;
    font-size: 0.9rem;
    transition: all 0.2s ease;
    border-bottom: 2px solid transparent;
    white-space: nowrap;
    background: none;
    border-top: none;
    border-left: none;
    border-right: none;
    cursor: pointer;
    font-family: inherit;
}

.nav-item i {
    font-size: 1rem;
    width: 16px;
    text-align: center;
}

.nav-item:hover,
.nav-item.active {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
}

.nav-logout-btn {
    color: var(--female-color) !important;
}

/* ===================== USER PROFILE (desktop) ===================== */
.user-profile {
    display: flex;
    align-items: center;
    gap: 10px;
}

.avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background-color: var(--primary-color);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1rem;
    flex-shrink: 0;
}

.user-info {
    display: flex;
    flex-direction: column;
    line-height: 1.3;
}

.user-name {
    font-weight: 600;
    font-size: 0.9rem;
}

.user-role {
    font-size: 0.75rem;
    text-transform: capitalize;
}

/* ===================== MAIN CONTENT ===================== */
.main-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    width: 100%;
    min-height: 0;
}

.page-content {
    padding: 28px 32px;
    flex: 1;
    max-width: 100%;
}

/* ===================== ALERTS ===================== */
.alert {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 18px;
    border-radius: 8px;
    margin-bottom: 20px;
    font-size: 0.95rem;
}
.alert-success {
    background: rgba(0,176,80,0.1);
    color: var(--primary-color);
    border: 1px solid rgba(0,176,80,0.3);
}
.alert-error {
    background: rgba(192,0,0,0.1);
    color: var(--female-color);
    border: 1px solid rgba(192,0,0,0.3);
}

/* ===================== PAGE HEADER ===================== */
.page-header {
    margin-bottom: 24px;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    flex-wrap: wrap;
    gap: 12px;
}

.page-title {
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--text-main);
    line-height: 1.2;
}

.breadcrumb {
    color: var(--text-muted);
    font-size: 0.875rem;
    margin-top: 6px;
    line-height: 1.5;
    max-width: 100%;
    overflow-wrap: anywhere;
    word-break: break-word;
}

.page-header-main {
    min-width: 0;
    flex: 1;
    max-width: 100%;
}

.page-header-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    flex-shrink: 0;
}

/* ===================== DASHBOARD ===================== */
.dashboard-stat-grid,
.dashboard-attendance-grid,
.dashboard-bottom-grid {
    margin-bottom: 24px;
}

.dashboard-section-title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 14px;
}
.dashboard-section-title i {
    margin-right: 6px;
}

.dashboard-side-stack {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.dashboard-summary-card {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 36px;
    text-align: center;
}
.dashboard-summary-icon {
    width: 70px;
    height: 70px;
    font-size: 28px;
    margin-bottom: 12px;
}
.dashboard-summary-label {
    color: var(--text-muted);
    margin-bottom: 6px;
    font-size: 0.95rem;
    font-weight: 600;
}
.dashboard-summary-value {
    font-size: 2.8rem;
    font-weight: 700;
    color: var(--text-main);
    line-height: 1;
}
.dashboard-summary-link {
    margin-top: 10px;
    font-size: 0.82rem;
    color: var(--primary-color);
    text-decoration: none;
}

.dashboard-gender-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 24px;
}
.dashboard-gender-title {
    margin-bottom: 16px;
    font-size: 1rem;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 8px;
    width: 100%;
    text-align: center;
    font-weight: 700;
}
.dashboard-gender-chart {
    width: 130px;
    height: 130px;
    border-radius: 50%;
    margin-bottom: 14px;
    flex-shrink: 0;
}
.dashboard-gender-legend {
    display: flex;
    gap: 16px;
    justify-content: center;
    flex-wrap: wrap;
}
.dashboard-gender-legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
}
.dashboard-gender-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}
.dashboard-gender-dot-male { background: var(--male-color); }
.dashboard-gender-dot-female { background: var(--female-color); }

.dashboard-weekly-card {
    grid-column: span 2;
}
.dashboard-weekly-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 12px;
    flex-wrap: wrap;
}
.dashboard-weekly-title {
    font-size: 1.1rem;
    font-weight: 700;
    margin: 0;
    min-width: 0;
}
.dashboard-weekly-btn {
    padding: 5px 12px;
    font-size: 0.82rem;
    flex-shrink: 0;
}
.dashboard-weekly-chart {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    height: 160px;
    padding: 0 8px;
}
.dashboard-weekly-bar-col {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    height: 100%;
    min-width: 0;
}
.dashboard-weekly-bar-label {
    font-size: 0.78rem;
    font-weight: 700;
    text-align: center;
}
.dashboard-weekly-bar-track {
    flex: 1;
    width: 100%;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    min-height: 80px;
}
.dashboard-weekly-bar-fill {
    width: 100%;
    border-radius: 6px 6px 0 0;
    min-height: 4px;
    transition: height 0.5s ease;
}
.dashboard-weekly-day {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 600;
    text-align: center;
}
.dashboard-weekly-legend {
    margin-top: 16px;
    display: flex;
    gap: 20px;
    justify-content: center;
    flex-wrap: wrap;
}
.dashboard-weekly-legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.82rem;
}
.dashboard-weekly-legend-swatch {
    width: 12px;
    height: 12px;
    border-radius: 3px;
    display: inline-block;
    flex-shrink: 0;
}
.dashboard-weekly-legend-good { background: var(--active-color); }
.dashboard-weekly-legend-fair { background: var(--male-color); }
.dashboard-weekly-legend-low { background: var(--female-color); }

.attendance-card {
    display: flex;
    flex-direction: column;
    gap: 0;
}
.attendance-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 10px;
    margin-bottom: 16px;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 12px;
    flex-wrap: wrap;
}
.attendance-card-title-row {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
    flex: 1;
}
.attendance-card-icon {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    flex-shrink: 0;
}
.attendance-card-title {
    font-size: 1rem;
    font-weight: 700;
    margin: 0;
    line-height: 1.3;
    word-break: break-word;
}
.attendance-card-badge {
    font-size: 0.75rem;
    padding: 3px 8px;
    border-radius: 20px;
    font-weight: 600;
    flex-shrink: 0;
    white-space: nowrap;
}
.attendance-card-badge-pending {
    background: #fef3c7;
    color: #92400e;
}
.attendance-card-badge-done {
    background: #dcfce7;
    color: #166534;
}
.attendance-card-rate {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 16px;
    min-width: 0;
}
.attendance-card-ring {
    position: relative;
    width: 72px;
    height: 72px;
    flex-shrink: 0;
}
.attendance-card-ring svg {
    width: 72px;
    height: 72px;
    transform: rotate(-90deg);
}
.attendance-card-ring-value {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    font-weight: 800;
}
.attendance-card-rate-body {
    flex: 1;
    min-width: 0;
}
.attendance-card-rate-label {
    font-size: 0.82rem;
    color: var(--text-muted);
    margin-bottom: 4px;
}
.attendance-card-rate-bar {
    height: 8px;
    background: var(--border-color);
    border-radius: 4px;
    overflow: hidden;
}
.attendance-card-rate-bar-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 0.8s ease;
}
.attendance-card-rate-meta {
    margin-top: 6px;
    font-size: 0.78rem;
    color: var(--text-muted);
}
.attendance-card-breakdown {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-bottom: 14px;
}
.attendance-card-pill {
    text-align: center;
    padding: 8px;
    border-radius: 8px;
}
.attendance-card-pill-value {
    font-size: 1.1rem;
    font-weight: 800;
}
.attendance-card-pill-label {
    font-size: 0.72rem;
    font-weight: 600;
}
.attendance-card-link {
    display: block;
    text-align: center;
    padding: 8px;
    font-size: 0.82rem;
    border-radius: 8px;
    text-decoration: none;
    font-weight: 600;
    transition: background 0.2s, opacity 0.2s;
}
.attendance-card-link:hover {
    opacity: 0.85;
}

/* ===================== SURFACE CARD ===================== */
.surface-card {
    background: var(--bg-surface);
    border-radius: 12px;
    padding: 24px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
}

/* ===================== GRID ===================== */
.grid {
    display: grid;
    gap: 20px;
}
.grid-cols-1 { grid-template-columns: repeat(1, 1fr); }
.grid-cols-2 { grid-template-columns: repeat(2, 1fr); }
.grid-cols-3 { grid-template-columns: repeat(3, 1fr); }
.grid-cols-4 { grid-template-columns: repeat(4, 1fr); }

/* ===================== STAT CARD ===================== */
.stat-card {
    display: flex;
    align-items: center;
    gap: 18px;
    transition: transform 0.2s, box-shadow 0.2s;
}
.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}
.stat-icon {
    width: 56px;
    height: 56px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    flex-shrink: 0;
}
.stat-icon.primary { background: rgba(0,176,80,0.1); color: var(--primary-color); }
.stat-icon.blue    { background: rgba(0,112,192,0.1); color: var(--male-color); }
.stat-icon.red     { background: rgba(192,0,0,0.1);   color: var(--female-color); }
.stat-icon.gray    { background: rgba(107,114,128,0.1); color: var(--text-muted); }

.stat-content { display: flex; flex-direction: column; }
.stat-label { font-size: 0.85rem; color: var(--text-muted); font-weight: 500; margin-bottom: 4px; }
.stat-value { font-size: 1.6rem; font-weight: 700; }

/* ===================== BUTTONS ===================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    border-radius: 8px;
    font-weight: 500;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
    border: 1px solid transparent;
    font-family: inherit;
    white-space: nowrap;
}
.btn-primary { background-color: var(--primary-color); color: white; }
.btn-primary:hover { background-color: var(--primary-hover); }
.btn-secondary { background-color: white; color: var(--text-main); border-color: var(--border-color); }
.btn-secondary:hover { background-color: #f9fafb; }

/* ===================== TABLES ===================== */
.table-container {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}
table { width: 100%; border-collapse: collapse; min-width: 500px; }
th, td { padding: 14px 16px; text-align: left; border-bottom: 1px solid var(--border-color); }
th { font-size: 0.8rem; text-transform: uppercase; color: var(--text-muted); font-weight: 600; background-color: #f9fafb; }
td { font-size: 0.9rem; vertical-align: middle; }
tbody tr:hover { background-color: #f9fafb; }

.table-actions {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}
.table-actions form {
    margin: 0;
    display: inline-flex;
    align-items: center;
}
.col-actions {
    text-align: center;
    white-space: nowrap;
}

/* ===================== BADGES ===================== */
.badge {
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 0.72rem;
    font-weight: 600;
    display: inline-block;
}
.badge-active   { background: rgba(0,176,80,0.1);   color: var(--primary-color); }
.badge-inactive { background: rgba(107,114,128,0.1); color: var(--text-muted); }
.badge-late     { background: rgba(0,112,192,0.1);  color: var(--male-color); }
.badge-excused  { background: rgba(124,58,237,0.1); color: #7c3aed; }
.badge-suspended { background: rgba(245,158,11,0.1); color: #d97706; }
.badge-expelled { background: rgba(220,38,38,0.1); color: #b91c1c; }
.badge-graduated { background: rgba(59,130,246,0.1); color: #2563eb; }
.badge-transferred { background: rgba(139,92,246,0.1); color: #7c3aed; }
.badge-low { background: rgba(16,185,129,0.1); color: #059669; }
.badge-medium { background: rgba(245,158,11,0.1); color: #d97706; }
.badge-high { background: rgba(239,68,68,0.1); color: #dc2626; }

/* ===================== FORMS ===================== */
.form-group { margin-bottom: 18px; }
.form-label { display: block; margin-bottom: 6px; font-size: 0.875rem; font-weight: 500; }
.form-control {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 0.9rem;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
    font-family: inherit;
    background: white;
}
.form-control:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(0,176,80,0.12);
}
.form-row { display: flex; gap: 16px; flex-wrap: wrap; }
.form-col { flex: 1; min-width: 200px; }

/* ===================== PAGINATION ===================== */
.pagination-wrapper { padding-top: 20px; border-top: 1px solid var(--border-color); margin-top: 8px; }
.pagination-nav { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px; }
.pagination-info { font-size: 0.875rem; color: var(--text-muted); }
.pagination { list-style: none; display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.page-link {
    display: inline-flex; align-items: center; justify-content: center;
    min-width: 36px; height: 36px; padding: 0 10px;
    border-radius: 8px; font-size: 0.875rem; font-weight: 500;
    color: var(--text-main); background: white;
    border: 1px solid var(--border-color);
    text-decoration: none; cursor: pointer; transition: all 0.2s;
}
.page-link:hover { background: rgba(0,176,80,0.08); border-color: var(--primary-color); color: var(--primary-color); }
.page-link-active { background: var(--primary-color) !important; border-color: var(--primary-color) !important; color: white !important; }
.page-item.disabled .page-link { background: #f9fafb; color: #d1d5db; pointer-events: none; }
.page-ellipsis { border: none; background: transparent; color: var(--text-muted); cursor: default; padding: 0 4px; }

/* ===================== MOBILE RESPONSIVE ===================== */
@media (max-width: 768px) {

    /* Show hamburger, hide desktop profile */
    .mobile-menu-toggle { display: flex; }
    .desktop-only { display: none !important; }

    .top-header-content { padding: 0 16px; }

    /* Nav drops down full width */
    .top-nav {
        display: none;
        border-top: 1px solid var(--border-color);
        max-height: calc(100vh - var(--topbar-height));
        overflow-y: auto;
    }
    .top-nav.show-mobile { display: block; }

    .nav-container {
        flex-direction: column;
        align-items: stretch;
        padding: 8px 0;
        gap: 0;
        overflow-x: visible;
    }

    .nav-item {
        padding: 14px 20px;
        border-bottom: none;
        border-left: 3px solid transparent;
        border-radius: 0;
        font-size: 0.95rem;
    }
    .nav-item:hover,
    .nav-item.active {
        border-bottom-color: transparent;
        border-left-color: var(--primary-color);
        background: rgba(0,176,80,0.05);
        color: var(--primary-color);
    }

    /* Mobile user section */
    .mobile-user-section {
        display: block;
        border-top: 1px solid var(--border-color);
        margin-top: 8px;
        padding-top: 8px;
    }
    .mobile-user-info {
        display: flex;
        align-items: center;
        gap: 12px;
        padding: 12px 20px 8px;
    }

    /* Page content smaller padding */
    .page-content { padding: 16px; }

    /* Grid: stack on mobile */
    .grid-cols-2,
    .grid-cols-3,
    .grid-cols-4 { grid-template-columns: 1fr; }

    /* Allow 2-col on slightly wider phones */
    @media (min-width: 480px) {
        .grid-cols-3,
        .grid-cols-4 { grid-template-columns: repeat(2, 1fr); }
    }

    /* Page header stacks */
    .page-header { flex-direction: column; align-items: stretch; }
    .page-title { font-size: 1.3rem; }
    .page-header-actions {
        width: 100%;
        flex-direction: column;
    }
    .page-header-actions .btn {
        width: 100%;
        white-space: normal;
        text-align: center;
    }

    /* Dashboard grids: single column on mobile */
    .dashboard-stat-grid,
    .dashboard-attendance-grid,
    .dashboard-bottom-grid {
        grid-template-columns: 1fr !important;
    }
    .dashboard-weekly-card {
        grid-column: span 1;
    }
    .dashboard-summary-card {
        padding: 24px;
    }
    .dashboard-summary-value {
        font-size: 2.2rem;
    }
    .dashboard-weekly-header {
        flex-direction: column;
        align-items: stretch;
    }
    .dashboard-weekly-btn {
        width: 100%;
    }
    .dashboard-weekly-chart {
        height: 140px;
        gap: 6px;
        padding: 0 4px;
    }
    .dashboard-weekly-bar-label {
        font-size: 0.7rem;
    }
    .dashboard-weekly-day {
        font-size: 0.68rem;
    }
    .dashboard-weekly-legend {
        gap: 10px;
        font-size: 0.78rem;
    }
    .attendance-card-header {
        flex-direction: column;
        align-items: stretch;
    }
    .attendance-card-badge {
        align-self: flex-start;
    }

    /* Form rows stack */
    .form-row { flex-direction: column; gap: 0; }
    .form-col { min-width: 100%; }

    /* Surface card */
    .surface-card { padding: 16px; border-radius: 10px; }

    /* Tables scroll */
    .table-container { border-radius: 8px; }
    table { min-width: 480px; }
    th, td { padding: 10px 12px; font-size: 0.82rem; }

    /* Stat cards */
    .stat-card { gap: 12px; }
    .stat-icon { width: 46px; height: 46px; font-size: 18px; }
    .stat-value { font-size: 1.3rem; }

    /* Buttons full-width in some contexts */
    .btn { font-size: 0.85rem; padding: 9px 16px; }

    /* Brand text hidden on very small screens */
    @media (max-width: 360px) {
        .brand-text { display: none; }
    }
}

@media (min-width: 769px) and (max-width: 1024px) {
    .page-content { padding: 20px 24px; }
    .grid-cols-4 { grid-template-columns: repeat(2, 1fr); }
    .dashboard-stat-grid { grid-template-columns: repeat(2, 1fr); }
    .dashboard-attendance-grid { grid-template-columns: repeat(2, 1fr); }
    .dashboard-bottom-grid { grid-template-columns: 1fr 1fr; }
    .dashboard-weekly-card { grid-column: span 2; }
    .top-header-content { padding: 0 20px; }
    .nav-container { padding: 0 20px; }
}
