/* ============================================
   EduPage — School Management System CSS
   ============================================ */

/* CSS Variables */
:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --primary-light: #dbeafe;
    --secondary: #64748b;
    --success: #16a34a;
    --success-light: #dcfce7;
    --danger: #dc2626;
    --danger-light: #fee2e2;
    --warning: #f59e0b;
    --warning-light: #fef3c7;
    --info: #0891b2;
    --info-light: #cffafe;
    --bg: #f1f5f9;
    --bg-white: #ffffff;
    --text: #1e293b;
    --text-muted: #64748b;
    --text-light: #94a3b8;
    --border: #e2e8f0;
    --border-dark: #cbd5e1;
    --sidebar-bg: #1e293b;
    --sidebar-text: #cbd5e1;
    --sidebar-active: #2563eb;
    --sidebar-width: 260px;
    --header-height: 60px;
    --radius: 8px;
    --radius-sm: 4px;
    --shadow: 0 1px 3px rgba(0,0,0,0.1);
    --shadow-lg: 0 4px 12px rgba(0,0,0,0.15);
    --transition: 0.2s ease;
    --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

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

body {
    font-family: var(--font);
    font-size: 14px;
    line-height: 1.5;
    color: var(--text);
    background: var(--bg);
}

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

img { max-width: 100%; }

/* ============================================
   Layout
   ============================================ */
.app-layout {
    display: flex;
    min-height: 100vh;
}

.main-wrapper {
    flex: 1;
    margin-left: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.main-content {
    flex: 1;
    padding: 24px;
    max-width: 1400px;
    width: 100%;
}

/* ============================================
   Sidebar
   ============================================ */
.sidebar {
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    overflow-y: auto;
    z-index: 1000;
    transition: transform var(--transition);
}

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

.sidebar-logo {
    font-size: 22px;
    font-weight: 700;
    color: #fff;
}

.sidebar-close {
    display: none;
    background: none;
    border: none;
    color: var(--sidebar-text);
    font-size: 24px;
    cursor: pointer;
}

.sidebar-nav ul {
    list-style: none;
    padding: 8px 0;
}

.sidebar-nav li a {
    display: flex;
    align-items: center;
    padding: 10px 20px;
    color: var(--sidebar-text);
    text-decoration: none;
    transition: background var(--transition);
    font-size: 14px;
}

.sidebar-nav li a:hover {
    background: rgba(255,255,255,0.08);
    color: #fff;
    text-decoration: none;
}

.sidebar-nav li.active a {
    background: var(--sidebar-active);
    color: #fff;
}

.nav-icon {
    margin-right: 12px;
    font-size: 16px;
    width: 20px;
    text-align: center;
}

.nav-divider {
    padding: 16px 20px 8px;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-light);
}

.badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 600;
    margin-left: auto;
}

.badge-unread {
    background: var(--danger);
    color: #fff;
}

/* ============================================
   Header
   ============================================ */
.top-header {
    height: var(--header-height);
    background: var(--bg-white);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.hamburger {
    display: none;
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--text);
}

.page-title {
    font-size: 18px;
    font-weight: 600;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 20px;
}

.user-menu {
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-name {
    font-size: 14px;
    font-weight: 500;
}

.user-role {
    color: var(--text-muted);
    font-weight: 400;
}

.lang-switcher {
    display: flex;
    gap: 4px;
}

.lang-switcher a {
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    text-decoration: none;
}

.lang-switcher a.active {
    background: var(--primary);
    color: #fff;
}

/* ============================================
   Auth Page
   ============================================ */
.auth-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #1e3a5f 0%, #2563eb 100%);
}

.auth-container {
    width: 100%;
    max-width: 420px;
    padding: 20px;
}

.auth-card {
    background: var(--bg-white);
    border-radius: var(--radius);
    padding: 40px;
    box-shadow: var(--shadow-lg);
}

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

.auth-logo h1 {
    font-size: 32px;
    color: var(--primary);
    margin-bottom: 8px;
}

.auth-logo p {
    color: var(--text-muted);
    font-size: 14px;
}

.auth-footer {
    text-align: center;
    margin-top: 20px;
}

.auth-footer .lang-switcher a {
    color: rgba(255,255,255,0.7);
}

.auth-footer .lang-switcher a.active {
    color: #fff;
    background: rgba(255,255,255,0.2);
}

/* ============================================
   Buttons
   ============================================ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 16px;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    transition: all var(--transition);
    line-height: 1.5;
}

.btn:hover { text-decoration: none; }

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

.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { opacity: 0.9; color: #fff; }

.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { opacity: 0.9; color: #fff; }

.btn-warning { background: var(--warning); color: #fff; }

.btn-outline {
    background: transparent;
    border: 1px solid var(--border-dark);
    color: var(--text);
}
.btn-outline:hover {
    background: var(--bg);
    color: var(--text);
}

.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-lg { padding: 12px 24px; font-size: 16px; }
.btn-block { display: flex; width: 100%; }

.btn-group {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

/* ============================================
   Forms
   ============================================ */
.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    margin-bottom: 4px;
    color: var(--text);
}

.form-control {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--border-dark);
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-family: var(--font);
    color: var(--text);
    background: var(--bg-white);
    transition: border-color var(--transition);
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

select.form-control {
    appearance: none;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3e%3cpath d='M6 8L1 3h10z' fill='%2364748b'/%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 32px;
}

textarea.form-control {
    resize: vertical;
    min-height: 100px;
}

.form-check {
    display: flex;
    align-items: center;
    gap: 8px;
}

.form-check input[type="checkbox"],
.form-check input[type="radio"] {
    width: 16px;
    height: 16px;
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
}

.form-inline {
    display: flex;
    gap: 12px;
    align-items: flex-end;
    flex-wrap: wrap;
}

.form-inline .form-group {
    margin-bottom: 0;
}

/* ============================================
   Cards
   ============================================ */
.card {
    background: var(--bg-white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
}

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

.card-header h2, .card-header h3 {
    font-size: 16px;
    font-weight: 600;
}

.card-body {
    padding: 20px;
}

.card-footer {
    padding: 12px 20px;
    border-top: 1px solid var(--border);
    background: var(--bg);
}

/* ============================================
   Tables
   ============================================ */
.table-responsive {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
}

table th, table td {
    padding: 10px 12px;
    text-align: left;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
}

table th {
    background: var(--bg);
    font-weight: 600;
    color: var(--text);
    position: sticky;
    top: 0;
}

table tr:hover {
    background: #f8fafc;
}

table .actions {
    white-space: nowrap;
}

table .actions a, table .actions button {
    margin-right: 4px;
}

/* ============================================
   Alerts
   ============================================ */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    margin-bottom: 16px;
    font-size: 14px;
}

.alert ul {
    margin: 4px 0 0 16px;
}

.alert-success { background: var(--success-light); color: #166534; border: 1px solid #bbf7d0; }
.alert-error { background: var(--danger-light); color: #991b1b; border: 1px solid #fecaca; }
.alert-warning { background: var(--warning-light); color: #92400e; border: 1px solid #fde68a; }
.alert-info { background: var(--info-light); color: #155e75; border: 1px solid #a5f3fc; }

/* ============================================
   Pagination
   ============================================ */
.pagination ul {
    display: flex;
    gap: 4px;
    list-style: none;
    justify-content: center;
    margin-top: 20px;
}

.pagination li a, .pagination li span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    height: 36px;
    padding: 0 8px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 13px;
    color: var(--text);
    text-decoration: none;
}

.pagination li a:hover { background: var(--bg); }
.pagination li.active a { background: var(--primary); color: #fff; border-color: var(--primary); }

.pagination-info {
    text-align: center;
    color: var(--text-muted);
    font-size: 13px;
    margin-top: 8px;
}

/* ============================================
   Stats Cards
   ============================================ */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--bg-white);
    border-radius: var(--radius);
    padding: 20px;
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
}

.stat-card .stat-value {
    font-size: 28px;
    font-weight: 700;
    color: var(--primary);
}

.stat-card .stat-label {
    font-size: 13px;
    color: var(--text-muted);
    margin-top: 4px;
}

/* ============================================
   Schedule Grid
   ============================================ */
.schedule-grid {
    display: grid;
    grid-template-columns: auto repeat(6, 1fr);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    background: var(--bg-white);
}

.schedule-grid .grid-header {
    background: var(--primary);
    color: #fff;
    padding: 12px 8px;
    text-align: center;
    font-weight: 600;
    font-size: 13px;
}

.schedule-grid .grid-time {
    background: var(--bg);
    padding: 8px;
    text-align: center;
    font-size: 12px;
    font-weight: 500;
    border-right: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-width: 80px;
}

.schedule-grid .grid-time .slot-num {
    font-size: 16px;
    font-weight: 700;
    color: var(--primary);
}

.schedule-grid .grid-cell {
    padding: 4px;
    border-right: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
    min-height: 70px;
    position: relative;
}

.schedule-grid .lesson-card {
    padding: 6px 8px;
    border-radius: var(--radius-sm);
    font-size: 12px;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    cursor: pointer;
}

.lesson-card .lesson-subject {
    font-weight: 600;
    margin-bottom: 2px;
}

.lesson-card .lesson-teacher {
    font-size: 11px;
    opacity: 0.8;
}

.lesson-card .lesson-room {
    font-size: 11px;
    opacity: 0.7;
}

/* ============================================
   Gradebook Table
   ============================================ */
.gradebook-table {
    overflow-x: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.gradebook-table table {
    min-width: 800px;
}

.gradebook-table th:first-child,
.gradebook-table td:first-child {
    position: sticky;
    left: 0;
    background: var(--bg-white);
    z-index: 1;
    min-width: 180px;
    border-right: 2px solid var(--border-dark);
}

.gradebook-table th:first-child {
    background: var(--bg);
    z-index: 2;
}

.grade-cell {
    text-align: center;
    cursor: pointer;
    min-width: 50px;
    font-weight: 600;
    transition: background var(--transition);
}

.grade-cell:hover {
    background: var(--primary-light);
}

.grade-5 { color: #16a34a; }
.grade-4 { color: #2563eb; }
.grade-3 { color: #f59e0b; }
.grade-2 { color: #dc2626; }
.grade-1 { color: #991b1b; }

.grade-avg {
    font-weight: 700;
    background: var(--bg) !important;
}

.grade-final {
    background: #fef3c7 !important;
    font-weight: 700;
}

/* ============================================
   Attendance
   ============================================ */
.attendance-grid table td {
    text-align: center;
}

.status-present { color: var(--success); font-weight: 600; }
.status-absent { color: var(--danger); font-weight: 600; }
.status-late { color: var(--warning); font-weight: 600; }
.status-excused { color: var(--info); font-weight: 600; }
.status-sick { color: #7c3aed; font-weight: 600; }

.attendance-radio-group {
    display: flex;
    gap: 8px;
    justify-content: center;
}

.attendance-radio-group label {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    font-size: 11px;
    cursor: pointer;
}

/* ============================================
   Messages
   ============================================ */
.message-list {
    list-style: none;
}

.message-item {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    display: flex;
    gap: 12px;
    cursor: pointer;
    transition: background var(--transition);
}

.message-item:hover {
    background: #f8fafc;
}

.message-item.unread {
    background: var(--primary-light);
    font-weight: 500;
}

.message-item .message-sender {
    font-weight: 600;
    min-width: 160px;
}

.message-item .message-subject {
    flex: 1;
}

.message-item .message-date {
    color: var(--text-muted);
    font-size: 12px;
    white-space: nowrap;
}

/* ============================================
   Modal
   ============================================ */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 2000;
    align-items: center;
    justify-content: center;
}

.modal-overlay.active {
    display: flex;
}

.modal {
    background: var(--bg-white);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-header h3 {
    font-size: 16px;
    font-weight: 600;
}

.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--text-muted);
}

.modal-body {
    padding: 20px;
}

.modal-footer {
    padding: 12px 20px;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

/* ============================================
   Utilities
   ============================================ */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-muted { color: var(--text-muted); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-warning { color: var(--warning); }
.text-sm { font-size: 12px; }
.text-lg { font-size: 16px; }
.font-bold { font-weight: 700; }

.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mr-1 { margin-right: 8px; }
.ml-1 { margin-left: 8px; }

.d-flex { display: flex; }
.d-grid { display: grid; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: 8px; }
.gap-2 { gap: 16px; }
.flex-wrap { flex-wrap: wrap; }

.w-100 { width: 100%; }
.hidden { display: none !important; }

.toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 16px;
}

.filter-bar {
    display: flex;
    gap: 12px;
    align-items: center;
    flex-wrap: wrap;
    margin-bottom: 16px;
    padding: 12px 16px;
    background: var(--bg-white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.filter-bar .form-control {
    width: auto;
    min-width: 150px;
}

/* Print styles */
@media print {
    .sidebar, .top-header, .toolbar, .btn, .pagination { display: none !important; }
    .main-wrapper { margin-left: 0; }
    .main-content { padding: 0; }
    body { background: #fff; }
}

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

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

    .sidebar-close {
        display: block;
    }

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

    .hamburger {
        display: block;
    }

    .main-content {
        padding: 16px;
    }

    .header-right .user-name {
        display: none;
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .form-row {
        grid-template-columns: 1fr;
    }

    .schedule-grid {
        font-size: 11px;
    }

    .schedule-grid .grid-time {
        min-width: 50px;
    }

    .toolbar {
        flex-direction: column;
        align-items: stretch;
    }
}

@media (max-width: 480px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }

    .top-header {
        padding: 0 12px;
    }

    .card-body {
        padding: 12px;
    }
}
