/* =====================================================
   สุขศึกษา ม.3 - Main Stylesheet
   Mobile-first, Thai-friendly design
   ===================================================== */

:root {
    --primary: #1a7a4a;
    --primary-light: #2da664;
    --primary-dark: #145c38;
    --secondary: #f59e0b;
    --secondary-light: #fbbf24;
    --accent: #059669;
    --danger: #dc2626;
    --warning: #f59e0b;
    --info: #3b82f6;
    --success: #16a34a;

    --bg: #f0f7f4;
    --surface: #ffffff;
    --surface2: #f8faf9;
    --border: #d1fae5;
    --border-dark: #a7f3d0;

    --text: #1a2e22;
    --text-muted: #6b7280;
    --text-light: #9ca3af;

    --topbar-h: 60px;
    --bottom-nav-h: 65px;
    --radius: 12px;
    --radius-sm: 8px;
    --shadow: 0 2px 12px rgba(26,122,74,0.10);
    --shadow-md: 0 4px 24px rgba(26,122,74,0.15);

    font-family: 'Sarabun', 'Helvetica Neue', Arial, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    background: var(--bg);
    color: var(--text);
    font-size: 16px;
    line-height: 1.6;
    padding-top: var(--topbar-h);
}

body.has-bottom-nav { padding-bottom: var(--bottom-nav-h); }

/* ===== TOPBAR ===== */
.topbar {
    position: fixed;
    top: 0; left: 0; right: 0;
    height: var(--topbar-h);
    background: var(--primary);
    z-index: 1000;
    box-shadow: 0 2px 12px rgba(0,0,0,0.15);
}
.topbar-inner {
    max-width: 900px;
    margin: 0 auto;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
}
.logo-link {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: white;
}
.logo-icon { font-size: 26px; }
.logo-title { font-family: 'Kanit', sans-serif; font-size: 17px; font-weight: 600; display: block; line-height: 1.2; color: white; }
.logo-sub { font-size: 11px; opacity: 0.8; display: block; color: white; }

.topbar-right { display: flex; align-items: center; gap: 8px; }

.user-btn {
    display: flex; align-items: center; gap: 8px;
    background: rgba(255,255,255,0.15);
    border: 1px solid rgba(255,255,255,0.25);
    color: white;
    padding: 6px 12px;
    border-radius: 24px;
    cursor: pointer;
    font-size: 14px;
    font-family: 'Sarabun', sans-serif;
}
.user-avatar {
    width: 28px; height: 28px;
    background: var(--secondary);
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 13px; font-weight: 700; color: white;
}
.user-name-short { max-width: 80px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.user-menu-wrap { position: relative; }
.user-dropdown {
    display: none;
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    background: white;
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    min-width: 220px;
    overflow: hidden;
    border: 1px solid var(--border);
    z-index: 999;
}
.user-dropdown.open { display: block; }
.user-info-box {
    display: flex; align-items: center; gap: 10px;
    padding: 14px 16px;
    background: var(--surface2);
    border-bottom: 1px solid var(--border);
}
.user-avatar-lg {
    width: 40px; height: 40px;
    background: var(--primary);
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 16px; font-weight: 700; color: white;
    flex-shrink: 0;
}
.user-fullname { font-weight: 600; font-size: 14px; }
.user-role-badge { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.user-dropdown a {
    display: flex; align-items: center; gap: 8px;
    padding: 10px 16px;
    color: var(--text);
    text-decoration: none;
    font-size: 14px;
    transition: background 0.2s;
}
.user-dropdown a:hover { background: var(--surface2); }
.user-dropdown hr { border: none; border-top: 1px solid var(--border); }
.logout-link { color: var(--danger) !important; }

/* ===== BOTTOM NAV ===== */
.bottom-nav {
    position: fixed;
    bottom: 0; left: 0; right: 0;
    height: var(--bottom-nav-h);
    background: white;
    border-top: 1px solid var(--border);
    display: flex;
    z-index: 1000;
    box-shadow: 0 -4px 12px rgba(0,0,0,0.08);
}
.bottom-nav-item {
    flex: 1;
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    gap: 3px;
    text-decoration: none;
    color: var(--text-muted);
    font-size: 11px;
    transition: color 0.2s;
    padding-bottom: 6px;
}
.bottom-nav-item i { font-size: 20px; }
.bottom-nav-item.active { color: var(--primary); }
.bottom-nav-item.active i { color: var(--primary); }

/* ===== FLASH MESSAGES ===== */
.flash-message {
    display: flex; align-items: center; gap: 10px;
    padding: 12px 16px;
    position: sticky; top: var(--topbar-h);
    z-index: 998;
    font-size: 14px;
}
.flash-success { background: #d1fae5; color: #065f46; border-bottom: 2px solid #6ee7b7; }
.flash-error { background: #fee2e2; color: #7f1d1d; border-bottom: 2px solid #fca5a5; }
.flash-info { background: #dbeafe; color: #1e3a5f; border-bottom: 2px solid #93c5fd; }
.flash-warning { background: #fef3c7; color: #78350f; border-bottom: 2px solid #fcd34d; }
.flash-close { margin-left: auto; background: none; border: none; cursor: pointer; font-size: 18px; opacity: 0.6; }

/* ===== MAIN WRAPPER ===== */
.main-wrapper {
    max-width: 900px;
    margin: 0 auto;
    padding: 20px 16px 24px;
}

/* ===== CARDS ===== */
.card {
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
    margin-bottom: 16px;
}
.card-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    display: flex; align-items: center; justify-content: space-between;
    gap: 10px;
}
.card-title {
    font-family: 'Kanit', sans-serif;
    font-size: 17px; font-weight: 600;
    color: var(--primary-dark);
}
.card-body { padding: 16px 20px; }
.card-footer {
    padding: 12px 20px;
    border-top: 1px solid var(--border);
    background: var(--surface2);
}

/* ===== PAGE HEADER ===== */
.page-header {
    margin-bottom: 20px;
}
.page-header h1 {
    font-family: 'Kanit', sans-serif;
    font-size: 22px; font-weight: 700;
    color: var(--primary-dark);
    line-height: 1.3;
}
.page-header p {
    color: var(--text-muted);
    font-size: 14px;
    margin-top: 4px;
}
.breadcrumb {
    display: flex; align-items: center; gap: 6px;
    font-size: 13px; color: var(--text-muted);
    margin-bottom: 8px;
}
.breadcrumb a { color: var(--primary); text-decoration: none; }
.breadcrumb-sep { color: var(--text-light); }

/* ===== BUTTONS ===== */
.btn {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 10px 18px;
    border-radius: var(--radius-sm);
    border: none; cursor: pointer;
    font-size: 15px;
    font-family: 'Sarabun', sans-serif;
    font-weight: 500;
    text-decoration: none;
    transition: all 0.2s;
    line-height: 1.4;
    white-space: nowrap;
}
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-secondary { background: var(--secondary); color: white; }
.btn-secondary:hover { background: #d97706; }
.btn-success { background: var(--success); color: white; }
.btn-danger { background: var(--danger); color: white; }
.btn-outline { background: transparent; color: var(--primary); border: 1.5px solid var(--primary); }
.btn-outline:hover { background: var(--primary); color: white; }
.btn-gray { background: #f3f4f6; color: var(--text); border: 1.5px solid #e5e7eb; }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-lg { padding: 13px 24px; font-size: 17px; }
.btn-block { width: 100%; justify-content: center; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ===== FORMS ===== */
.form-group { margin-bottom: 16px; }
.form-label {
    display: block;
    font-weight: 500; font-size: 14px;
    margin-bottom: 6px;
    color: var(--text);
}
.form-label.required::after { content: ' *'; color: var(--danger); }
.form-control {
    width: 100%;
    padding: 10px 14px;
    border: 1.5px solid #d1d5db;
    border-radius: var(--radius-sm);
    font-size: 15px;
    font-family: 'Sarabun', sans-serif;
    background: white;
    color: var(--text);
    transition: border-color 0.2s;
    -webkit-appearance: none;
}
.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(26,122,74,0.1);
}
.form-control.error { border-color: var(--danger); }
.form-hint { font-size: 12px; color: var(--text-muted); margin-top: 4px; }
.form-error { font-size: 12px; color: var(--danger); margin-top: 4px; }
textarea.form-control { min-height: 100px; resize: vertical; }
select.form-control { cursor: pointer; }

/* ===== TABLES ===== */
.table-wrap { overflow-x: auto; }
.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}
.table th, .table td {
    padding: 10px 14px;
    border-bottom: 1px solid var(--border);
    text-align: left;
    vertical-align: middle;
}
.table th {
    background: var(--surface2);
    font-weight: 600;
    color: var(--primary-dark);
    font-size: 13px;
}
.table tbody tr:hover { background: var(--surface2); }
.table-striped tbody tr:nth-child(even) { background: var(--surface2); }

/* ===== BADGES ===== */
.badge {
    display: inline-flex; align-items: center;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 12px; font-weight: 600;
}
.badge-green { background: #d1fae5; color: #065f46; }
.badge-yellow { background: #fef3c7; color: #92400e; }
.badge-red { background: #fee2e2; color: #7f1d1d; }
.badge-blue { background: #dbeafe; color: #1e40af; }
.badge-gray { background: #f3f4f6; color: #374151; }

/* ===== LOGIN PAGE ===== */
.login-page {
    min-height: 100vh;
    background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary-light) 100%);
    display: flex; align-items: center; justify-content: center;
    padding: 20px;
}
.login-box {
    background: white;
    border-radius: 20px;
    padding: 36px 32px;
    width: 100%; max-width: 400px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.2);
}
.login-logo {
    text-align: center; margin-bottom: 24px;
}
.login-logo .emoji { font-size: 52px; display: block; margin-bottom: 10px; }
.login-logo h1 { font-family: 'Kanit', sans-serif; font-size: 22px; color: var(--primary-dark); }
.login-logo p { color: var(--text-muted); font-size: 14px; }
.login-tabs { display: flex; background: var(--bg); border-radius: 8px; padding: 4px; margin-bottom: 20px; }
.login-tab { flex: 1; padding: 8px; text-align: center; border-radius: 6px; cursor: pointer; font-size: 14px; font-weight: 500; color: var(--text-muted); border: none; background: none; font-family: 'Sarabun', sans-serif; }
.login-tab.active { background: white; color: var(--primary); box-shadow: 0 1px 4px rgba(0,0,0,0.1); }

/* ===== DASHBOARD ===== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    margin-bottom: 20px;
}
.stat-card {
    background: white;
    border-radius: var(--radius);
    padding: 16px;
    box-shadow: var(--shadow);
    text-align: center;
    border-top: 3px solid var(--primary);
}
.stat-card.yellow { border-top-color: var(--secondary); }
.stat-card.blue { border-top-color: var(--info); }
.stat-card.red { border-top-color: var(--danger); }
.stat-number { font-family: 'Kanit', sans-serif; font-size: 28px; font-weight: 700; color: var(--primary); }
.stat-card.yellow .stat-number { color: var(--secondary); }
.stat-card.blue .stat-number { color: var(--info); }
.stat-card.red .stat-number { color: var(--danger); }
.stat-label { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

/* ===== UNIT CARDS ===== */
.unit-list { display: flex; flex-direction: column; gap: 14px; }
.unit-card {
    background: white;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
    border-left: 5px solid var(--primary);
    text-decoration: none; color: inherit;
    display: block;
    transition: box-shadow 0.2s, transform 0.2s;
}
.unit-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }
.unit-card.locked { border-left-color: #d1d5db; opacity: 0.75; }
.unit-card.completed { border-left-color: var(--success); }
.unit-card-header {
    display: flex; align-items: center; gap: 12px;
    padding: 14px 16px;
}
.unit-num {
    width: 44px; height: 44px;
    background: var(--primary);
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    font-family: 'Kanit', sans-serif;
    font-size: 17px; font-weight: 700;
    color: white; flex-shrink: 0;
}
.unit-card.locked .unit-num { background: #9ca3af; }
.unit-card.completed .unit-num { background: var(--success); }
.unit-info { flex: 1; }
.unit-title { font-weight: 600; font-size: 15px; color: var(--text); line-height: 1.3; }
.unit-meta { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.unit-status-icon { font-size: 20px; }

/* Progress bar */
.progress-row { padding: 0 16px 14px; }
.progress-bar-wrap {
    background: #e5e7eb;
    border-radius: 8px; height: 8px; overflow: hidden;
}
.progress-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary-light), var(--primary));
    border-radius: 8px;
    transition: width 0.5s ease;
}
.progress-steps {
    display: flex; gap: 8px; margin-top: 8px;
    flex-wrap: wrap;
}
.progress-step {
    display: flex; align-items: center; gap: 4px;
    font-size: 11px; color: var(--text-muted);
}
.progress-step.done { color: var(--success); }
.progress-step i { font-size: 12px; }

/* ===== CONTENT VIEWER ===== */
.content-tabs {
    display: flex; gap: 4px;
    padding: 4px;
    background: var(--bg);
    border-radius: var(--radius-sm);
    margin-bottom: 16px;
    overflow-x: auto;
}
.content-tab {
    flex-shrink: 0;
    padding: 8px 14px;
    border: none; background: none;
    border-radius: 6px;
    font-size: 14px; font-family: 'Sarabun', sans-serif;
    cursor: pointer; color: var(--text-muted); font-weight: 500;
    display: flex; align-items: center; gap: 6px;
    transition: all 0.2s;
}
.content-tab.active { background: white; color: var(--primary); box-shadow: 0 1px 4px rgba(0,0,0,0.1); }
.content-panel { display: none; }
.content-panel.active { display: block; }

/* PDF viewer */
.pdf-frame { width: 100%; height: 500px; border: none; border-radius: 8px; }
.pdf-download-bar {
    background: var(--surface2); padding: 12px 16px;
    border-radius: 8px; margin-bottom: 12px;
    display: flex; align-items: center; justify-content: space-between;
    flex-wrap: wrap; gap: 8px;
}

/* YouTube embed */
.video-wrap {
    position: relative; width: 100%; padding-bottom: 56.25%;
    border-radius: 8px; overflow: hidden; background: #000;
}
.video-wrap iframe { position: absolute; top: 0; left: 0; width: 100%; height: 100%; border: none; }

/* ===== QUIZ ===== */
.quiz-info-box {
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    border-radius: var(--radius);
    color: white; padding: 20px;
    margin-bottom: 20px;
    text-align: center;
}
.quiz-info-box h2 { font-family: 'Kanit', sans-serif; font-size: 20px; margin-bottom: 8px; }
.quiz-meta-row { display: flex; justify-content: center; gap: 16px; flex-wrap: wrap; margin-top: 12px; }
.quiz-meta-item { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.quiz-meta-item span { font-size: 11px; opacity: 0.8; }
.quiz-meta-item strong { font-size: 16px; }

.question-card {
    background: white;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 18px;
    margin-bottom: 14px;
}
.question-num { font-size: 12px; color: var(--text-muted); margin-bottom: 6px; }
.question-text { font-size: 16px; font-weight: 500; margin-bottom: 14px; line-height: 1.5; }
.options-list { display: flex; flex-direction: column; gap: 8px; }
.option-item {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 14px;
    border: 1.5px solid #e5e7eb;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 15px;
}
.option-item:hover { border-color: var(--primary); background: #f0fdf4; }
.option-item input[type="radio"] { accent-color: var(--primary); width: 18px; height: 18px; flex-shrink: 0; }
.option-item.selected { border-color: var(--primary); background: #d1fae5; }
.option-item.correct { border-color: var(--success); background: #d1fae5; }
.option-item.wrong { border-color: var(--danger); background: #fee2e2; }

/* Quiz timer */
.quiz-timer {
    position: sticky; top: var(--topbar-h);
    background: white; z-index: 100;
    padding: 10px 20px;
    display: flex; align-items: center; justify-content: space-between;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    margin-bottom: 16px;
}
.timer-display {
    font-family: 'Kanit', sans-serif; font-size: 22px;
    color: var(--primary);
}
.timer-display.warning { color: var(--danger); animation: blink 1s infinite; }
@keyframes blink { 50% { opacity: 0.5; } }

/* Score result */
.score-result {
    text-align: center; padding: 30px 20px;
}
.score-circle {
    width: 130px; height: 130px;
    border-radius: 50%;
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    margin: 0 auto 20px;
    font-family: 'Kanit', sans-serif;
    border: 6px solid;
}
.score-circle.passed { border-color: var(--success); color: var(--success); }
.score-circle.failed { border-color: var(--danger); color: var(--danger); }
.score-percent { font-size: 34px; font-weight: 700; }
.score-label { font-size: 12px; }
.result-badge {
    display: inline-block; padding: 8px 24px;
    border-radius: 24px; font-size: 16px; font-weight: 600; margin-bottom: 16px;
}
.result-badge.pass { background: #d1fae5; color: var(--success); }
.result-badge.fail { background: #fee2e2; color: var(--danger); }

/* ===== ADMIN ===== */
.admin-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 14px;
    margin-bottom: 20px;
}
.admin-menu-card {
    background: white;
    border-radius: var(--radius);
    padding: 20px 16px;
    text-align: center;
    box-shadow: var(--shadow);
    text-decoration: none;
    color: var(--text);
    transition: all 0.2s;
    border-top: 3px solid var(--primary);
}
.admin-menu-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }
.admin-menu-card i { font-size: 28px; color: var(--primary); margin-bottom: 8px; display: block; }
.admin-menu-card span { font-size: 14px; font-weight: 500; }
.admin-menu-card.yellow { border-top-color: var(--secondary); }
.admin-menu-card.yellow i { color: var(--secondary); }
.admin-menu-card.blue { border-top-color: var(--info); }
.admin-menu-card.blue i { color: var(--info); }
.admin-menu-card.red { border-top-color: var(--danger); }
.admin-menu-card.red i { color: var(--danger); }

/* Grade submission */
.submission-img {
    width: 100%;
    border-radius: 8px;
    max-height: 400px;
    object-fit: contain;
    background: #f9f9f9;
    cursor: zoom-in;
}

/* ===== ALERT BOXES ===== */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    margin-bottom: 14px;
    display: flex; align-items: flex-start; gap: 10px;
    font-size: 14px;
}
.alert i { flex-shrink: 0; margin-top: 2px; }
.alert-info { background: #dbeafe; color: #1e40af; border-left: 4px solid var(--info); }
.alert-warning { background: #fef3c7; color: #92400e; border-left: 4px solid var(--warning); }
.alert-success { background: #d1fae5; color: #065f46; border-left: 4px solid var(--success); }
.alert-danger { background: #fee2e2; color: #7f1d1d; border-left: 4px solid var(--danger); }

/* ===== FILE UPLOAD ===== */
.upload-area {
    border: 2px dashed var(--border-dark);
    border-radius: var(--radius);
    padding: 24px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    background: var(--surface2);
}
.upload-area:hover, .upload-area.dragover { border-color: var(--primary); background: #f0fdf4; }
.upload-area i { font-size: 32px; color: var(--primary); margin-bottom: 8px; }
.upload-area p { color: var(--text-muted); font-size: 14px; }
.upload-area input { display: none; }
.upload-preview { display: flex; align-items: center; gap: 10px; margin-top: 12px; padding: 10px; background: white; border-radius: 8px; border: 1px solid var(--border); }
.upload-preview img { width: 60px; height: 60px; object-fit: cover; border-radius: 4px; }

/* ===== ANNOUNCEMENTS ===== */
.announcement-card {
    background: linear-gradient(135deg, #fff8e1 0%, #fff3cd 100%);
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 14px;
    border-left: 4px solid var(--secondary);
}
.announcement-card h4 { font-size: 15px; font-weight: 600; color: #7c4c00; margin-bottom: 6px; }
.announcement-card p { font-size: 14px; color: #78350f; }
.announcement-card .ann-date { font-size: 11px; color: #a16207; margin-top: 8px; }

/* ===== MOBILE OPTIMIZATIONS ===== */
@media (max-width: 480px) {
    .main-wrapper { padding: 14px 12px 16px; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
    .admin-grid { grid-template-columns: repeat(2, 1fr); }
    .table th, .table td { padding: 8px 10px; font-size: 13px; }
    .user-name-short { display: none; }
    .quiz-timer { padding: 8px 14px; }
    .card-body { padding: 14px; }
}

@media (max-width: 360px) {
    .stats-grid { grid-template-columns: 1fr 1fr; }
    .btn { padding: 8px 14px; font-size: 14px; }
}

/* ===== EMPTY STATE ===== */
.empty-state {
    text-align: center; padding: 40px 20px;
    color: var(--text-muted);
}
.empty-state i { font-size: 48px; margin-bottom: 12px; opacity: 0.4; display: block; }
.empty-state h3 { font-size: 16px; margin-bottom: 6px; color: var(--text); }
.empty-state p { font-size: 14px; }

/* ===== 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: 20px;
}
.modal-overlay.open { display: flex; }
.modal-box {
    background: white;
    border-radius: var(--radius);
    width: 100%; max-width: 480px;
    max-height: 90vh; overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}
.modal-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
}
.modal-header h3 { font-size: 17px; font-weight: 600; }
.modal-close { background: none; border: none; font-size: 22px; cursor: pointer; color: var(--text-muted); }
.modal-body { padding: 20px; }
.modal-footer { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; gap: 8px; justify-content: flex-end; }

/* ===== GRADING ===== */
.score-input-row {
    display: flex; align-items: center; gap: 10px;
}
.score-input-row input { max-width: 90px; text-align: center; }
.score-input-row span { color: var(--text-muted); font-size: 14px; }

/* Scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border-dark); border-radius: 3px; }

/* ===== SIDEBAR (Teacher/Admin) ===== */
.sidebar-toggle-btn {
    display: none;
    background: rgba(255,255,255,0.15);
    border: 1px solid rgba(255,255,255,0.25);
    color: white;
    width: 36px; height: 36px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 16px;
    align-items: center; justify-content: center;
    margin-right: 4px;
    flex-shrink: 0;
}

.sidebar {
    position: fixed;
    top: var(--topbar-h);
    left: 0;
    width: 240px;
    height: calc(100vh - var(--topbar-h));
    background: white;
    border-right: 1px solid var(--border);
    z-index: 900;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
}
.sidebar.open { transform: translateX(0); }

.sidebar-section-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-light);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 18px 20px 8px;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 0 10px;
    flex: 1;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 14px;
    border-radius: var(--radius-sm);
    color: var(--text);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    transition: background 0.15s, color 0.15s;
}
.sidebar-link i {
    width: 20px;
    text-align: center;
    color: var(--text-muted);
    font-size: 16px;
    flex-shrink: 0;
}
.sidebar-link:hover { background: var(--surface2); }
.sidebar-link.active {
    background: #d1fae5;
    color: var(--primary-dark);
}
.sidebar-link.active i { color: var(--primary); }

.sidebar-footer {
    padding: 10px;
    border-top: 1px solid var(--border);
}
.sidebar-link.logout { color: var(--danger); }
.sidebar-link.logout i { color: var(--danger); }
.sidebar-link.logout:hover { background: #fee2e2; }

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    top: var(--topbar-h);
    background: rgba(0,0,0,0.4);
    z-index: 899;
}
.sidebar-overlay.open { display: block; }

/* Desktop: sidebar always visible, pushes content over */
@media (min-width: 900px) {
    .sidebar-toggle-btn { display: none !important; }
    .sidebar-overlay { display: none !important; }
    body.has-sidebar .sidebar {
        transform: translateX(0);
        box-shadow: none;
    }
    body.has-sidebar .main-wrapper {
        margin-left: 240px;
        max-width: 1100px;
        padding: 24px 32px 32px;
    }
    body.has-sidebar .topbar-inner {
        max-width: none;
        padding: 0 24px;
    }
    body.has-sidebar .flash-message {
        margin-left: 240px;
    }
}

/* Mobile/tablet: hamburger + slide-out drawer */
@media (max-width: 899px) {
    .sidebar-toggle-btn { display: flex; }
    .sidebar {
        box-shadow: 4px 0 24px rgba(0,0,0,0.15);
    }
}

/* Print */
@media print { .topbar, .bottom-nav, .sidebar, .btn { display: none !important; } }

/* ===== DASHBOARD HERO (teacher, sidebar-aware) ===== */
.dash-hero {
    background: linear-gradient(135deg, var(--primary-dark), var(--primary-light));
    color: white;
    padding: 20px 16px;
    margin: -20px -16px 20px;
    border-radius: 0 0 20px 20px;
}
@media (max-width: 480px) {
    .dash-hero { margin: -14px -12px 20px; }
}
@media (min-width: 900px) {
    body.has-sidebar .dash-hero {
        margin: -24px -32px 24px;
        padding: 24px 32px;
        border-radius: 0 0 24px 24px;
    }
}

