/* EduVHP - Main Stylesheet */
/* CSS Variables */
:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --primary-light: #3b82f6;
    --primary-bg: #eff6ff;
    --secondary: #64748b;
    --success: #16a34a;
    --success-bg: #f0fdf4;
    --warning: #d97706;
    --warning-bg: #fffbeb;
    --danger: #dc2626;
    --danger-bg: #fef2f2;
    --info: #0891b2;
    --info-bg: #ecfeff;
    --title-primary: #0b0c0c;
    --title-secondary: #dbdee3;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;
    --border: #e2e8f0;
    --border-light: #f1f5f9;
    --bg: #005a87;
    --bg-white: #ffffff;
    --sidebar-width: 260px;
    --header-height: 64px;
    --radius: 10px;
    --radius-sm: 6px;
    --radius-lg: 16px;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
    --shadow: 0 4px 12px rgba(0,0,0,0.08);
    --shadow-lg: 0 10px 30px rgba(0,0,0,0.12);
    --transition: 0.2s ease;
}

/* Reset & Base */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; scroll-behavior: smooth; }
body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    color: var(--text-primary);
    background: var(--bg);
    line-height: 1.6;
}
a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-dark); }
img { max-width: 100%; }
ul { list-style: none; }

/* Layout */
.app-layout {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background: linear-gradient(180deg, #003d5c 0%, #005a87 100%);
    color: #fff;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 1000;
    transition: transform var(--transition);
    overflow-y: auto;
}
.sidebar-header {
    padding: 1.5rem 1.25rem;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    display: flex;
    align-items: center;
    gap: 0.75rem;
}
.sidebar-logo {
    width: 40px; height: 40px;
    background: rgba(255,255,255,0.2);
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}
.sidebar-logo svg { width: 22px; height: 22px; fill: #fff; }
.sidebar-title { font-size: 1.25rem; font-weight: 800; letter-spacing: 0.5px; }
.sidebar-subtitle { font-size: 0.72rem; color: rgba(255,255,255,0.6); }

.sidebar-user {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    display: flex; align-items: center; gap: 0.75rem;
}
.user-avatar {
    width: 38px; height: 38px;
    background: rgba(255,255,255,0.25);
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 0.9rem; flex-shrink: 0;
}
.user-info .user-name { font-size: 0.875rem; font-weight: 600; }
.user-info .user-role {
    font-size: 0.72rem; color: rgba(255,255,255,0.6);
    text-transform: capitalize;
}
.sidebar-nav { flex: 1; padding: 1rem 0; }
.nav-section-title {
    font-size: 0.68rem; font-weight: 700; letter-spacing: 1.5px;
    text-transform: uppercase; color: rgba(255,255,255,0.4);
    padding: 0.75rem 1.25rem 0.35rem;
}
.nav-item { display: block; }
.nav-link {
    display: flex; align-items: center; gap: 0.75rem;
    padding: 0.7rem 1.25rem;
    color: rgba(255,255,255,0.75);
    font-size: 0.875rem; font-weight: 500;
    transition: all var(--transition);
    border-left: 3px solid transparent;
    text-decoration: none;
}
.nav-link svg { width: 18px; height: 18px; flex-shrink: 0; }
.nav-link:hover { background: rgba(255,255,255,0.08); color: #fff; }
.nav-link.active {
    background: rgba(255,255,255,0.15);
    color: #fff; border-left-color: #fff;
}
.sidebar-footer {
    padding: 1rem 1.25rem;
    border-top: 1px solid rgba(255,255,255,0.1);
}
.logout-btn {
    display: flex; align-items: center; gap: 0.75rem;
    padding: 0.7rem 1rem;
    background: rgba(255,255,255,0.1);
    border: none; border-radius: var(--radius);
    color: rgba(255,255,255,0.8);
    font-size: 0.875rem; cursor: pointer; width: 100%;
    text-decoration: none;
    transition: background var(--transition);
}
.logout-btn:hover { background: rgba(255,255,255,0.2); color: #fff; }
.logout-btn svg { width: 18px; height: 18px; }

/* Main Content */
.main-content {
    margin-left: var(--sidebar-width);
    flex: 1;
    display: flex; flex-direction: column;
    min-height: 100vh;
}
.topbar {
    height: var(--header-height);
    background: var(--bg-white);
    border-bottom: 1px solid var(--border);
    display: flex; align-items: center;
    padding: 0 1.5rem;
    gap: 1rem;
    position: sticky; top: 0; z-index: 100;
    box-shadow: var(--shadow-sm);
}
.topbar-hamburger {
    display: none;
    background: none; border: none;
    cursor: pointer; padding: 0.4rem;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
}
.topbar-hamburger:hover { background: #f1f5f9; }
.topbar-hamburger svg { width: 22px; height: 22px; display: block; }
.topbar-title { font-size: 1.05rem; font-weight: 700; color: var(--text-primary); flex: 1; }
.topbar-actions { display: flex; align-items: center; gap: 0.75rem; }
.page-content { padding: 1.5rem; flex: 1; }

/* Page Header */
.page-header {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 1.5rem; flex-wrap: wrap; gap: 0.75rem;
}
.page-header h2 { font-size: 1.35rem; font-weight: 700; color: var(--title-primary); }
.page-header p { font-size: 0.875rem; color: var(--title-secondary); margin-top: 0.15rem; }

/* Stats Cards */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
    gap: 1rem; margin-bottom: 1.5rem;
}
.stat-card {
    background: var(--bg-white);
    border-radius: var(--radius-lg);
    padding: 1.25rem 1.5rem;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
    display: flex; align-items: center; gap: 1rem;
}
.stat-icon {
    width: 52px; height: 52px;
    border-radius: 14px;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}
.stat-icon svg { width: 26px; height: 26px; }
.stat-icon.blue { background: #dbeafe; color: var(--primary); }
.stat-icon.green { background: #dcfce7; color: var(--success); }
.stat-icon.orange { background: #fed7aa; color: #ea580c; }
.stat-icon.purple { background: #ede9fe; color: #7c3aed; }
.stat-value { font-size: 1.75rem; font-weight: 800; color: var(--text-primary); line-height: 1; }
.stat-label { font-size: 0.8rem; color: var(--text-secondary); margin-top: 0.2rem; }

/* Cards */
.card {
    background: var(--bg-white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
    overflow: hidden;
}
.card-header {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border);
    display: flex; align-items: center; justify-content: space-between;
    gap: 0.75rem; flex-wrap: wrap;
}
.card-header h3 { font-size: 1rem; font-weight: 700; color: var(--text-primary); }
.card-body { padding: 1.5rem; }

/* Tables */
.table-wrapper { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; }
thead th {
    padding: 0.75rem 1rem;
    text-align: left;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
    background: #f8fafc;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}
tbody td {
    padding: 0.875rem 1rem;
    font-size: 0.875rem;
    color: var(--text-primary);
    border-bottom: 1px solid var(--border-light);
    vertical-align: middle;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #f8fafc; }

/* Badges */
.badge {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 0.25rem 0.65rem;
    border-radius: 20px;
    font-size: 0.72rem; font-weight: 700;
    text-transform: uppercase; letter-spacing: 0.5px;
}
.badge-success { background: #dcfce7; color: #15803d; }
.badge-warning { background: #fef9c3; color: #a16207; }
.badge-danger  { background: #fee2e2; color: #b91c1c; }
.badge-info    { background: #e0f2fe; color: #0369a1; }
.badge-secondary { background: #f1f5f9; color: #475569; }
.badge-primary { background: #dbeafe; color: #1d4ed8; }

/* Buttons */
.btn {
    display: inline-flex; align-items: center; gap: 0.45rem;
    padding: 0.55rem 1.1rem;
    border-radius: var(--radius);
    font-size: 0.875rem; font-weight: 600;
    cursor: pointer; border: 1.5px solid transparent;
    transition: all var(--transition); text-decoration: none;
    white-space: nowrap;
}
.btn svg { width: 16px; height: 16px; }
.btn-primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); color: #fff; }
.btn-success { background: var(--success); color: #fff; border-color: var(--success); }
.btn-success:hover { background: #15803d; border-color: #15803d; color: #fff; }
.btn-danger { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-danger:hover { background: #b91c1c; color: #fff; }
.btn-secondary { background: #f1f5f9; color: var(--text-secondary); border-color: var(--border); }
.btn-secondary:hover { background: #e2e8f0; color: var(--text-primary); }
.btn-sm { padding: 0.35rem 0.75rem; font-size: 0.8rem; }
.btn-outline { background: transparent; color: var(--primary); border-color: var(--primary); }
.btn-outline:hover { background: var(--primary); color: #fff; }

/* Forms */
.form-group { margin-bottom: 1.1rem; }
.form-group label {
    display: block; margin-bottom: 0.4rem;
    font-size: 0.85rem; font-weight: 600; color: var(--text-primary);
}
.form-control {
    width: 100%;
    padding: 0.65rem 0.9rem;
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.875rem; color: var(--text-primary);
    background: var(--bg-white);
    transition: border-color var(--transition), box-shadow var(--transition);
    outline: none;
}
.form-control:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37,99,235,0.1);
}
.form-control::placeholder { color: var(--text-muted); }
select.form-control { cursor: pointer; }
textarea.form-control { resize: vertical; min-height: 80px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.form-hint { font-size: 0.78rem; color: var(--text-muted); margin-top: 0.3rem; }
.form-check { display: flex; align-items: center; gap: 0.5rem; }
.form-check input[type="checkbox"] {
    width: 16px; height: 16px; cursor: pointer; accent-color: var(--primary);
}

/* Modal */
.modal-overlay {
    display: none; position: fixed; inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 2000; align-items: center; justify-content: center;
    padding: 1rem;
}
.modal-overlay.open { display: flex; }
.modal {
    background: var(--bg-white);
    border-radius: var(--radius-lg);
    width: 100%; max-width: 560px;
    max-height: 90vh; overflow-y: auto;
    box-shadow: var(--shadow-lg);
    animation: modalIn 0.2s ease;
}
@keyframes modalIn {
    from { transform: translateY(-20px); opacity: 0; }
    to   { transform: translateY(0); opacity: 1; }
}
.modal-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border);
    display: flex; align-items: center; justify-content: space-between;
}
.modal-header h3 { font-size: 1.05rem; font-weight: 700; }
.modal-close {
    background: none; border: none; cursor: pointer;
    color: var(--text-muted); padding: 0.25rem;
    border-radius: var(--radius-sm); transition: color var(--transition);
    display: flex;
}
.modal-close:hover { color: var(--text-primary); background: #f1f5f9; }
.modal-close svg { width: 20px; height: 20px; }
.modal-body { padding: 1.5rem; }
.modal-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border);
    display: flex; gap: 0.75rem; justify-content: flex-end;
}

/* Alerts */
.alert {
    padding: 0.875rem 1rem;
    border-radius: var(--radius);
    font-size: 0.875rem; margin-bottom: 1rem;
    display: flex; align-items: flex-start; gap: 0.6rem;
}
.alert svg { width: 16px; height: 16px; flex-shrink: 0; margin-top: 2px; }
.alert-success { background: var(--success-bg); color: #166534; border: 1px solid #bbf7d0; }
.alert-danger  { background: var(--danger-bg); color: #991b1b; border: 1px solid #fecaca; }
.alert-warning { background: var(--warning-bg); color: #92400e; border: 1px solid #fde68a; }
.alert-info    { background: var(--info-bg); color: #164e63; border: 1px solid #a5f3fc; }

/* Toast Notifications */
#toast-container {
    position: fixed; bottom: 1.5rem; right: 1.5rem;
    z-index: 9999; display: flex; flex-direction: column; gap: 0.5rem;
}
.toast {
    background: #1e293b; color: #fff;
    padding: 0.85rem 1.25rem; border-radius: var(--radius);
    font-size: 0.875rem; max-width: 320px;
    display: flex; align-items: center; gap: 0.6rem;
    box-shadow: var(--shadow-lg);
    animation: toastIn 0.3s ease;
}
@keyframes toastIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
.toast-success { border-left: 4px solid #22c55e; }
.toast-error   { border-left: 4px solid #ef4444; }
.toast-info    { border-left: 4px solid #3b82f6; }
.toast svg { width: 18px; height: 18px; flex-shrink: 0; }

/* Empty State */
.empty-state {
    text-align: center; padding: 3rem 1.5rem;
    color: var(--text-muted);
}
.empty-state svg { width: 48px; height: 48px; margin-bottom: 0.75rem; opacity: 0.4; }
.empty-state h4 { font-size: 1rem; color: var(--text-secondary); margin-bottom: 0.25rem; }
.empty-state p { font-size: 0.875rem; }

/* Attendance Table */
.attendance-grid { display: grid; gap: 0.5rem; }
.attendance-row {
    display: flex; align-items: center;
    padding: 0.75rem 1rem;
    background: #f8fafc;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    gap: 0.75rem;
}
.attendance-row.present { border-color: #bbf7d0; background: #f0fdf4; }
.attendance-check { flex: 0 0 auto; }
.attendance-name { flex: 1; font-size: 0.875rem; font-weight: 500; }

/* Progress Bar */
.progress-bar-wrap { background: var(--border); border-radius: 20px; height: 8px; overflow: hidden; }
.progress-bar { height: 100%; border-radius: 20px; background: var(--primary); transition: width 0.4s ease; }
.progress-bar.success { background: var(--success); }
.progress-bar.warning { background: var(--warning); }
.progress-bar.danger  { background: var(--danger); }

/* Sidebar Overlay (mobile) */
.sidebar-overlay {
    display: none; position: fixed; inset: 0;
    background: rgba(0,0,0,0.45); z-index: 999;
}
.sidebar-overlay.active { display: block; }

/* Certificate Styles */
.certificate-page {
    min-height: 100vh; background: #f5f0e8;
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    padding: 2rem;
}
.certificate-container {
    background: #fff;
    width: 100%; max-width: 800px;
    padding: 3rem;
    border: 12px solid #1d4ed8;
    outline: 4px solid #fbbf24;
    outline-offset: -18px;
    border-radius: 4px;
    text-align: center;
    position: relative;
    box-shadow: 0 10px 40px rgba(0,0,0,0.15);
}
.certificate-logo { font-size: 1.5rem; font-weight: 800; color: var(--primary); margin-bottom: 0.5rem; }
.certificate-title { font-size: 2.2rem; font-weight: 800; color: #1e3a8a; margin-bottom: 0.25rem; }
.certificate-subtitle { font-size: 1rem; color: var(--text-secondary); margin-bottom: 2rem; }
.certificate-body { margin: 1.5rem 0; }
.certificate-body .certify { font-size: 1rem; color: var(--text-secondary); }
.certificate-body .student-name {
    font-size: 2rem; font-weight: 800; color: #1e3a8a;
    border-bottom: 3px solid #fbbf24; display: inline-block;
    padding: 0 1rem 0.25rem; margin: 0.5rem 0;
}
.certificate-body .class-name {
    font-size: 1.3rem; font-weight: 700; color: var(--primary); margin: 0.5rem 0;
}
.certificate-date { font-size: 0.9rem; color: var(--text-secondary); margin-top: 2rem; }
.certificate-footer {
    margin-top: 2.5rem;
    display: flex; justify-content: space-between; align-items: flex-end;
    border-top: 1px solid var(--border); padding-top: 1.5rem;
}
.certificate-seal {
    width: 80px; height: 80px;
    background: radial-gradient(circle, #dbeafe, #1d4ed8);
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    color: #fff; font-weight: 800; font-size: 0.65rem;
    text-align: center; line-height: 1.2;
    box-shadow: 0 4px 12px rgba(29,78,216,0.4);
}
.cert-list { display: grid; gap: 1rem; }
.cert-card {
    background: var(--bg-white); border: 1px solid var(--border);
    border-radius: var(--radius-lg); padding: 1.25rem 1.5rem;
    display: flex; align-items: center; justify-content: space-between;
    gap: 1rem; flex-wrap: wrap;
}
.cert-info h4 { font-size: 1rem; font-weight: 700; }
.cert-info p { font-size: 0.85rem; color: var(--text-secondary); }

/* Responsive */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }
    .sidebar.open {
        transform: translateX(0);
    }
    .main-content {
        margin-left: 0;
    }
    .topbar-hamburger { display: flex; }
    .stats-grid { grid-template-columns: 1fr 1fr; }
    .form-row { grid-template-columns: 1fr; }
    .modal { max-width: 100%; margin: 0; border-radius: var(--radius) var(--radius) 0 0; }
    .modal-overlay { align-items: flex-end; padding: 0; }
    .page-header { flex-direction: column; align-items: flex-start; }
    .certificate-container { padding: 1.5rem; border-width: 8px; }
    .certificate-title { font-size: 1.5rem; }
    .certificate-body .student-name { font-size: 1.5rem; }
    .certificate-footer { flex-direction: column; align-items: center; gap: 1rem; }
    .card-header { flex-direction: column; align-items: flex-start; }
}
@media (max-width: 480px) {
    .stats-grid { grid-template-columns: 1fr; }
    .page-content { padding: 1rem; }
}

/* Print styles for certificate */
@media print {
    body { background: #fff !important; }
    .no-print, .topbar, .sidebar, .sidebar-overlay,
    #toast-container, .btn-print { display: none !important; }
    .main-content { margin-left: 0 !important; }
    .certificate-container {
        box-shadow: none !important;
        border: 12px solid #1d4ed8 !important;
        outline: 4px solid #fbbf24 !important;
    }
    .certificate-page { padding: 0; background: #fff; }
    @page { margin: 0.5cm; }
}
