@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

:root {
    --bg-primary: #0b0b1a;
    --bg-secondary: #111128;
    --bg-card: #161637;
    --bg-card-hover: #1c1c47;
    --bg-sidebar: #0d0d22;
    --bg-input: #1a1a3e;
    --border: rgba(255,255,255,0.06);
    --border-light: rgba(255,255,255,0.1);
    --primary: #6366f1;
    --primary-light: #818cf8;
    --primary-dark: #4f46e5;
    --primary-glow: rgba(99,102,241,0.25);
    --accent: #06b6d4;
    --success: #22c55e;
    --success-bg: rgba(34,197,94,0.1);
    --warning: #f59e0b;
    --warning-bg: rgba(245,158,11,0.1);
    --danger: #ef4444;
    --danger-bg: rgba(239,68,68,0.1);
    --info: #3b82f6;
    --info-bg: rgba(59,130,246,0.1);
    --text: #e2e8f0;
    --text-muted: #94a3b8;
    --text-dim: #64748b;
    --shadow: 0 4px 24px rgba(0,0,0,0.3);
    --shadow-lg: 0 8px 40px rgba(0,0,0,0.4);
    --radius: 12px;
    --radius-lg: 16px;
    --radius-sm: 8px;
    --transition: all 0.3s ease;
    --sidebar-width: 260px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: 'Inter', sans-serif;
    background: var(--bg-primary);
    color: var(--text);
    min-height: 100vh;
    overflow-x: hidden;
}

/* ===== LOGIN PAGE ===== */
.login-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #0b0b1a 0%, #1a1040 50%, #0b0b1a 100%);
    position: relative;
    overflow: hidden;
}

.login-container::before {
    content: '';
    position: absolute;
    width: 600px; height: 600px;
    background: radial-gradient(circle, rgba(99,102,241,0.15), transparent 70%);
    top: -200px; right: -200px;
    border-radius: 50%;
    animation: float 8s ease-in-out infinite;
}

.login-container::after {
    content: '';
    position: absolute;
    width: 400px; height: 400px;
    background: radial-gradient(circle, rgba(6,182,212,0.1), transparent 70%);
    bottom: -100px; left: -100px;
    border-radius: 50%;
    animation: float 6s ease-in-out infinite reverse;
}

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-30px); }
}

.login-card {
    background: rgba(22,22,55,0.8);
    backdrop-filter: blur(20px);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    padding: 48px 40px;
    width: 420px;
    max-width: 90vw;
    box-shadow: var(--shadow-lg);
    position: relative;
    z-index: 1;
    animation: slideUp 0.6s ease;
}

@keyframes slideUp {
    from { opacity: 0; transform: translateY(30px); }
    to { opacity: 1; transform: translateY(0); }
}

.login-logo {
    text-align: center;
    margin-bottom: 32px;
}

.login-logo .icon {
    width: 64px; height: 64px;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    border-radius: 16px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    margin-bottom: 16px;
    box-shadow: 0 8px 32px var(--primary-glow);
}

.login-logo h1 {
    font-size: 1.5rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--text), var(--primary-light));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.login-logo p {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-top: 4px;
}

/* ===== FORM ELEMENTS ===== */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.form-input {
    width: 100%;
    padding: 12px 16px;
    background: var(--bg-input);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-family: 'Inter', sans-serif;
    font-size: 0.95rem;
    transition: var(--transition);
    outline: none;
}

.form-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-glow);
}

.form-input::placeholder {
    color: var(--text-dim);
}

select.form-input {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%2394a3b8' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
}

/* ===== BUTTONS ===== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 24px;
    border: none;
    border-radius: var(--radius-sm);
    font-family: 'Inter', sans-serif;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    box-shadow: 0 4px 16px var(--primary-glow);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 24px var(--primary-glow);
}

.btn-success { background: var(--success); color: white; }
.btn-success:hover { background: #16a34a; transform: translateY(-2px); }
.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { background: #dc2626; transform: translateY(-2px); }
.btn-outline {
    background: transparent;
    border: 1px solid var(--border-light);
    color: var(--text-muted);
}
.btn-outline:hover {
    background: var(--bg-card);
    color: var(--text);
    border-color: var(--primary);
}
.btn-sm { padding: 8px 14px; font-size: 0.8rem; }
.btn-full { width: 100%; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none !important; }

/* ===== LAYOUT ===== */
.app-layout {
    display: flex;
    min-height: 100vh;
}

/* ===== SIDEBAR ===== */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border);
    position: fixed;
    top: 0; left: 0; bottom: 0;
    display: flex;
    flex-direction: column;
    z-index: 100;
    transition: transform 0.3s ease;
}

.sidebar-header {
    padding: 24px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 12px;
}

.sidebar-header .logo-icon {
    width: 40px; height: 40px;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
}

.sidebar-header .logo-text h2 {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text);
    line-height: 1.2;
}

.sidebar-header .logo-text p {
    font-size: 0.7rem;
    color: var(--text-dim);
}

.sidebar-nav {
    flex: 1;
    padding: 16px 12px;
    overflow-y: auto;
}

.nav-label {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 1px;
    padding: 8px 12px;
    margin-top: 8px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    transition: var(--transition);
    margin-bottom: 2px;
    cursor: pointer;
}

.nav-item:hover {
    background: var(--bg-card);
    color: var(--text);
}

.nav-item.active {
    background: linear-gradient(135deg, rgba(99,102,241,0.15), rgba(99,102,241,0.05));
    color: var(--primary-light);
    border: 1px solid rgba(99,102,241,0.2);
}

.nav-item .nav-icon { font-size: 1.1rem; width: 24px; text-align: center; }

.sidebar-footer {
    padding: 16px 12px;
    border-top: 1px solid var(--border);
}

/* ===== MAIN CONTENT ===== */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    min-height: 100vh;
}

.topbar {
    padding: 20px 32px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(11,11,26,0.8);
    backdrop-filter: blur(10px);
    position: sticky;
    top: 0;
    z-index: 50;
}

.topbar h1 {
    font-size: 1.25rem;
    font-weight: 700;
}

.topbar .subtitle {
    font-size: 0.8rem;
    color: var(--text-dim);
    margin-top: 2px;
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.page-content {
    padding: 28px 32px;
}

/* ===== STAT CARDS ===== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 20px;
    margin-bottom: 28px;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}

.stat-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow);
    border-color: var(--border-light);
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 3px;
}

.stat-card.blue::before { background: linear-gradient(90deg, var(--info), var(--accent)); }
.stat-card.green::before { background: linear-gradient(90deg, var(--success), #34d399); }
.stat-card.red::before { background: linear-gradient(90deg, var(--danger), #f97316); }
.stat-card.yellow::before { background: linear-gradient(90deg, var(--warning), #fbbf24); }

.stat-card .stat-icon {
    width: 44px; height: 44px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    margin-bottom: 16px;
}

.stat-card.blue .stat-icon { background: var(--info-bg); color: var(--info); }
.stat-card.green .stat-icon { background: var(--success-bg); color: var(--success); }
.stat-card.red .stat-icon { background: var(--danger-bg); color: var(--danger); }
.stat-card.yellow .stat-icon { background: var(--warning-bg); color: var(--warning); }

.stat-card .stat-value {
    font-size: 2rem;
    font-weight: 700;
    line-height: 1;
    margin-bottom: 4px;
}

.stat-card .stat-label {
    font-size: 0.85rem;
    color: var(--text-muted);
}

/* ===== CARDS ===== */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

.card-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.card-header h3 { font-size: 1rem; font-weight: 600; }
.card-body { padding: 24px; }

/* ===== GRID ===== */
.grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 28px;
}

/* ===== TABLE ===== */
.table-container {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
}

table th, table td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid var(--border);
    font-size: 0.875rem;
}

table th {
    background: var(--bg-secondary);
    color: var(--text-muted);
    font-weight: 600;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    position: sticky;
    top: 0;
}

table tr { transition: var(--transition); }
table tr:hover { background: rgba(99,102,241,0.04); }
table tr:last-child td { border-bottom: none; }

/* ===== BADGES ===== */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
}

.badge-success { background: var(--success-bg); color: var(--success); }
.badge-danger { background: var(--danger-bg); color: var(--danger); }
.badge-warning { background: var(--warning-bg); color: var(--warning); }
.badge-info { background: var(--info-bg); color: var(--info); }

/* ===== TOOLBAR ===== */
.toolbar {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.search-box {
    position: relative;
    flex: 1;
    min-width: 200px;
}

.search-box input {
    width: 100%;
    padding: 10px 16px 10px 40px;
    background: var(--bg-input);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-family: 'Inter', sans-serif;
    font-size: 0.9rem;
    outline: none;
    transition: var(--transition);
}

.search-box input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-glow);
}

.search-box::before {
    content: '🔍';
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 0.9rem;
}

/* ===== MODAL ===== */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.7);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: var(--transition);
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal {
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    width: 480px;
    max-width: 90vw;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
    transform: scale(0.9);
    transition: var(--transition);
}

.modal-overlay.active .modal {
    transform: scale(1);
}

.modal-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-header h3 { font-size: 1.1rem; font-weight: 600; }

.modal-close {
    width: 32px; height: 32px;
    background: none;
    border: 1px solid var(--border-light);
    border-radius: 8px;
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    font-size: 1.2rem;
}

.modal-close:hover { background: var(--danger-bg); color: var(--danger); border-color: var(--danger); }

.modal-body { padding: 24px; }
.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

/* ===== CHART CONTAINER ===== */
.chart-container {
    position: relative;
    height: 280px;
    padding: 8px;
}

/* ===== TOAST ===== */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    padding: 14px 20px;
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-lg);
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 280px;
    animation: slideInRight 0.4s ease, fadeOut 0.4s ease 3s forwards;
    border-left: 3px solid;
}

.toast.success { border-left-color: var(--success); }
.toast.error { border-left-color: var(--danger); }
.toast.warning { border-left-color: var(--warning); }

@keyframes slideInRight {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

@keyframes fadeOut {
    to { opacity: 0; transform: translateX(50px); }
}

/* ===== LOADING ===== */
.spinner {
    width: 20px; height: 20px;
    border: 2px solid var(--border-light);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.loading-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px;
    color: var(--text-muted);
    gap: 16px;
}

/* ===== MONTHLY GRID ===== */
.monthly-grid table th,
.monthly-grid table td {
    text-align: center;
    padding: 8px 4px;
    font-size: 0.8rem;
    min-width: 36px;
}

.monthly-grid .day-present { color: var(--success); font-weight: 700; }
.monthly-grid .day-absent { color: var(--text-dim); }
.monthly-grid .day-header { font-size: 0.7rem; }
.monthly-grid .student-name { text-align: left; min-width: 160px; font-weight: 500; }
.monthly-grid .student-class { text-align: left; min-width: 60px; color: var(--text-muted); }
.monthly-grid .total-col { font-weight: 700; color: var(--primary-light); min-width: 50px; }

/* ===== HAMBURGER ===== */
.hamburger {
    display: none;
    background: none;
    border: none;
    color: var(--text);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 4px;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }
    .sidebar.open { transform: translateX(0); }
    .main-content { margin-left: 0; }
    .hamburger { display: block; }
    .topbar { padding: 16px 20px; }
    .page-content { padding: 20px; }
    .stats-grid { grid-template-columns: 1fr 1fr; }
    .grid-2 { grid-template-columns: 1fr; }
    .toolbar { flex-direction: column; align-items: stretch; }
}

@media (max-width: 480px) {
    .stats-grid { grid-template-columns: 1fr; }
    .login-card { padding: 32px 24px; }
}
