@font-face {
    font-family: 'Rebar';
    src: url('fonts/rabar.woff') format('woff');
    font-weight: normal;
    font-style: normal;
    font-display: swap;
}

:root {
    --brand-dark: #0b1120;
    --brand-primary: #1e40af;
    --brand-accent: #3b82f6;
    --brand-light: #f8fafc;
    --border-subtle: #e2e8f0;
    --card-bg: #ffffff;
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    --shadow-sm: 0 4px 14px -4px rgba(15, 23, 42, 0.06);
    --shadow-md: 0 18px 40px -12px rgba(15, 23, 42, 0.10);
    --radius-card: 20px;
    --radius-item: 12px;
    --transition: all 0.22s cubic-bezier(0.2, 0, 0, 1);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; scroll-behavior: smooth; }

body {
    font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: #f1f5f9;
    color: #1e293b;
    line-height: 1.55;
    padding: 0 0 60px;
    -webkit-font-smoothing: antialiased;
}

.ku-text {
    font-family: 'Rebar', 'Inter', sans-serif !important;
    direction: rtl;
    unicode-bidi: isolate;
    font-weight: 500;
}

/* ===================== NAVBAR ===================== */
.navbar {
    background: linear-gradient(135deg, #0b1120 0%, #1e3a8a 100%);
    color: white;
    padding: 0 24px;
    position: sticky;
    top: 0;
    z-index: 999;
    box-shadow: 0 4px 20px -4px rgba(0,0,0,0.25);
}
.nav-inner {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 68px;
    flex-wrap: wrap;
}
.nav-logo {
    font-weight: 800;
    font-size: 1.15rem;
    letter-spacing: -0.02em;
    display: flex;
    align-items: center;
    gap: 10px;
    color: #fff;
    text-decoration: none;
}
.nav-logo span { color: #93c5fd; }
.nav-links {
    display: flex;
    gap: 6px;
    align-items: center;
    flex-wrap: wrap;
}
.nav-links a {
    color: rgba(255,255,255,0.85);
    text-decoration: none;
    padding: 9px 16px;
    border-radius: 40px;
    font-weight: 500;
    font-size: 0.9rem;
    transition: var(--transition);
}
.nav-links a:hover,
.nav-links a.active {
    background: rgba(255,255,255,0.12);
    color: #fff;
}
.nav-links a.logout {
    background: rgba(239, 68, 68, 0.15);
    color: #fca5a5;
}
.nav-links a.logout:hover { background: #ef4444; color: white; }

.nav-user {
    color: #93c5fd;
    font-size: 0.85rem;
    padding: 6px 14px;
    border-radius: 40px;
    background: rgba(147, 197, 253, 0.12);
    font-weight: 600;
}

/* ===================== LAYOUT ===================== */
.a4-wrapper {
    max-width: 960px;
    margin: 24px auto;
    background: var(--card-bg);
    border-radius: var(--radius-card);
    box-shadow: var(--shadow-md);
    padding: 36px 40px;
    border: 1px solid rgba(226, 232, 240, 0.7);
}
.a4-wide { max-width: 1200px; }

/* ===================== TYPOGRAPHY ===================== */
h1, h2, h3, h4 {
    font-weight: 600;
    letter-spacing: -0.02em;
    color: var(--brand-dark);
}
h1 { font-size: 1.9rem; font-weight: 700; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.2rem; margin: 28px 0 14px; }

/* ===================== DASHBOARD STATS ===================== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin: 20px 0 30px;
}
.stat-card {
    background: white;
    border-radius: 16px;
    padding: 22px 24px;
    border: 1px solid var(--border-subtle);
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}
.stat-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-md);
}
.stat-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0;
    width: 5px; height: 100%;
    background: var(--brand-primary);
}
.stat-card.green::before { background: var(--success); }
.stat-card.orange::before { background: var(--warning); }
.stat-card.purple::before { background: #8b5cf6; }

.stat-icon { font-size: 1.6rem; margin-bottom: 8px; }
.stat-value { font-size: 1.9rem; font-weight: 700; color: var(--brand-dark); line-height: 1.1; }
.stat-label {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: #64748b;
    font-weight: 600;
    margin-top: 4px;
}

/* ===================== SELECT / SEARCH BAR ===================== */
.selector-container {
    text-align: center;
    padding: 10px 15px 5px;
}
.selector-label {
    font-weight: 700;
    font-size: 0.9rem;
    display: block;
    margin-bottom: 10px;
    color: var(--brand-dark);
    letter-spacing: 0.3px;
    text-transform: uppercase;
}
select, .admin-input, .admin-select {
    width: 100%;
    padding: 12px 16px;
    border: 1.5px solid var(--border-subtle);
    border-radius: 12px;
    font-size: 0.95rem;
    font-family: inherit;
    background: #fff;
    color: var(--brand-dark);
    font-weight: 500;
    transition: var(--transition);
}
.selector-container select {
    max-width: 460px;
    border-radius: 60px;
    padding: 14px 44px 14px 20px;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='%231e40af' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 20px center;
    background-size: 18px;
    cursor: pointer;
}
select:focus, .admin-input:focus, .admin-select:focus {
    outline: none;
    border-color: var(--brand-accent);
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.12);
}

.search-bar {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 18px;
}
.search-bar .admin-input { flex: 1; min-width: 200px; }
.search-bar .admin-select { flex: 0 0 auto; width: auto; min-width: 160px; }

/* ===================== TABLES ===================== */
.table-wrap { overflow-x: auto; border-radius: 14px; }
.academic-table {
    width: 100%;
    border-collapse: collapse;
    background: #fff;
    border-radius: 14px;
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    font-size: 0.88rem;
    margin: 14px 0;
    min-width: 620px;
}
.academic-table th {
    background: #f1f6fe;
    color: #0b2b5c;
    font-weight: 700;
    padding: 14px 12px;
    text-align: left;
    border-bottom: 2px solid #dbe7f5;
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.4px;
}
.academic-table td {
    padding: 12px;
    border-bottom: 1px solid #edf2f9;
    vertical-align: middle;
}
.academic-table tr:hover td { background: #fafbff; }
.academic-table tr:last-child td { border-bottom: none; }

/* ===================== BADGES ===================== */
.badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 40px;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.4px;
}
.badge-online { background: #d1fae5; color: #065f46; }
.badge-offline { background: #fee2e2; color: #991b1b; }
.badge-code {
    background: #eff6ff;
    color: #1e40af;
    font-family: 'Courier New', monospace;
    font-size: 0.82rem;
    letter-spacing: 1px;
    padding: 5px 12px;
    border: 1px dashed #93c5fd;
}
.badge-price {
    background: #fef3c7;
    color: #92400e;
    font-weight: 700;
}

/* ===================== BUTTONS ===================== */
.btn-primary, .btn-edit, .btn-danger, .btn-success, .btn-warning, .btn-ghost {
    display: inline-block;
    padding: 10px 18px;
    border-radius: 40px;
    font-weight: 600;
    text-decoration: none;
    font-size: 0.83rem;
    transition: var(--transition);
    border: none;
    cursor: pointer;
    text-align: center;
    white-space: nowrap;
}
.btn-primary { background: var(--brand-primary); color: #fff; box-shadow: 0 6px 14px -4px rgba(30, 64, 175, 0.3); }
.btn-primary:hover { background: #1e3a8a; transform: translateY(-1px); }

.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { background: #059669; }

.btn-edit { background: #eef4ff; color: var(--brand-primary); }
.btn-edit:hover { background: var(--brand-primary); color: #fff; }

.btn-danger { background: #fee2e2; color: #b91c1c; }
.btn-danger:hover { background: var(--danger); color: #fff; }

.btn-warning { background: #fef3c7; color: #92400e; }
.btn-warning:hover { background: var(--warning); color: #fff; }

.btn-ghost { background: transparent; color: var(--brand-primary); border: 1.5px solid var(--brand-primary); }
.btn-ghost:hover { background: var(--brand-primary); color: #fff; }

.btn-sm { padding: 7px 14px; font-size: 0.78rem; }

.actions-cell { display: flex; gap: 6px; flex-wrap: wrap; }

/* ===================== LESSON HEADER ===================== */
.lesson-header {
    text-align: center;
    border-bottom: 2px solid #f1f5f9;
    padding-bottom: 18px;
}
.lesson-image-wrapper {
    width: 100%;
    margin: 24px 0;
    text-align: center;
}
.lesson-image-wrapper img {
    max-width: 88%;
    height: auto;
    border-radius: 16px;
    border: 1px solid var(--border-subtle);
    box-shadow: var(--shadow-sm);
}

/* ===================== VOCABULARY ===================== */
.word-item-container {
    background: #fff;
    border: 1px solid #edf2f7;
    border-radius: var(--radius-item);
    margin-bottom: 8px;
    overflow: hidden;
    transition: var(--transition);
    box-shadow: 0 1px 3px rgba(0,0,0,0.02);
}
.word-item-container:hover { border-color: #cbd5e1; box-shadow: 0 4px 12px -4px rgba(0,0,0,0.06); }
.word-main-bar {
    padding: 14px 18px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    user-select: none;
}
.word-main-bar:hover { background: #f8fafc; }
.word-main-bar strong { font-size: 1.02rem; color: var(--brand-dark); font-weight: 600; }
.dropdown-icon { font-size: 12px; color: var(--brand-accent); margin-left: 10px; transition: transform 0.25s; opacity: 0.75; }
.word-item-container.active .dropdown-icon { transform: rotate(180deg); opacity: 1; }
.ku-reveal-panel {
    display: none;
    padding: 12px 18px;
    background: #f8fafc;
    border-top: 1px dashed #e2e8f0;
    font-size: 1.1rem;
    color: var(--brand-primary);
    font-weight: 600;
}
.word-item-container.active .ku-reveal-panel { display: block; }

.speaker-btn {
    background: #eef4ff;
    color: var(--brand-primary);
    border: none;
    border-radius: 50%;
    width: 36px; height: 36px;
    font-size: 15px;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: var(--transition);
    flex-shrink: 0;
}
.speaker-btn:hover { background: var(--brand-primary); color: #fff; transform: scale(1.05); }

/* ===================== QUIZ ===================== */
.quiz-section-container {
    margin-top: 36px;
    background: #f8fafc;
    padding: 26px 24px;
    border-radius: 18px;
    border: 1px solid var(--border-subtle);
}
.quiz-header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 14px;
    margin-bottom: 18px;
}
.quiz-toggle-btn {
    background: #fff;
    border: 1.5px solid var(--brand-primary);
    color: var(--brand-primary);
    padding: 10px 20px;
    border-radius: 60px;
    font-weight: 600;
    font-size: 0.88rem;
    cursor: pointer;
    transition: var(--transition);
    display: inline-flex; align-items: center; gap: 8px;
}
.quiz-toggle-btn:hover { background: var(--brand-primary); color: #fff; }

.quiz-card {
    background: #fff;
    padding: 18px 20px;
    border-radius: 14px;
    margin-bottom: 12px;
    border: 1px solid #e9eef4;
    transition: var(--transition);
}
.quiz-card.correct-highlight { border-left: 5px solid var(--success); background: #f0fdf4; }
.quiz-card.wrong-highlight { border-left: 5px solid var(--danger); background: #fef2f2; }
.quiz-question-header { font-weight: 700; font-size: 1rem; color: var(--brand-dark); margin-bottom: 10px; }
.quiz-option-item {
    display: flex; align-items: center;
    padding: 10px 14px;
    border: 1.5px solid #e9eef4;
    border-radius: 12px;
    margin-bottom: 6px;
    cursor: pointer;
    background: #fff;
    font-size: 0.94rem;
    transition: var(--transition);
    font-weight: 500;
}
.quiz-option-item:hover { border-color: var(--brand-accent); background: #f5f9ff; }
.quiz-option-item input[type="radio"] {
    accent-color: var(--brand-primary);
    width: 17px; height: 17px;
    margin-right: 12px;
    cursor: pointer;
}

.btn-submit {
    background: var(--brand-primary);
    color: #fff;
    border: none;
    padding: 14px 26px;
    border-radius: 60px;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    width: 100%;
    margin-top: 14px;
    transition: var(--transition);
    box-shadow: 0 8px 18px -6px rgba(30, 64, 175, 0.35);
}
.btn-submit:hover { background: #1e3a8a; transform: translateY(-2px); }

.score-feedback {
    margin-top: 16px;
    padding: 16px 20px;
    border-radius: 14px;
    background: #fff;
    border: 1px solid var(--border-subtle);
    font-weight: 600;
    display: none;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px;
}
.score-feedback.show { display: flex; }
.score-badge {
    background: var(--brand-primary);
    color: #fff;
    padding: 8px 20px;
    border-radius: 40px;
    font-size: 1.05rem;
    font-weight: 700;
}

.quiz-container-hidden { display: none; }
.quiz-container-visible { display: block; animation: fadeIn 0.22s ease; }

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(4px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ===================== LOGIN PAGE ===================== */
.login-card {
    max-width: 460px;
    margin: 60px auto;
    background: #fff;
    border-radius: 24px;
    padding: 44px 36px;
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border-subtle);
    text-align: center;
}
.login-card .logo-big { font-size: 3rem; margin-bottom: 12px; }
.login-card h1 { font-size: 1.6rem; margin-bottom: 6px; }
.login-card p { color: #64748b; font-size: 0.92rem; margin-bottom: 28px; }

.code-input {
    width: 100%;
    padding: 18px 22px;
    font-family: 'Courier New', monospace;
    font-size: 1.3rem;
    font-weight: 700;
    letter-spacing: 4px;
    text-align: center;
    border: 2px solid var(--border-subtle);
    border-radius: 14px;
    text-transform: uppercase;
    transition: var(--transition);
}
.code-input:focus {
    outline: none;
    border-color: var(--brand-primary);
    box-shadow: 0 0 0 5px rgba(30, 64, 175, 0.12);
}

.alert {
    padding: 14px 18px;
    border-radius: 12px;
    font-size: 0.9rem;
    font-weight: 600;
    margin-bottom: 16px;
    text-align: left;
}
.alert-error { background: #fef2f2; color: #b91c1c; border: 1px solid #fecaca; }
.alert-success { background: #f0fdf4; color: #15803d; border: 1px solid #bbf7d0; }
.alert-info { background: #eff6ff; color: #1e40af; border: 1px solid #bfdbfe; }

/* ===================== ACCESS CODE DISPLAY ===================== */
.access-code-box {
    background: linear-gradient(135deg, #eff6ff, #dbeafe);
    border: 2px dashed #3b82f6;
    border-radius: 16px;
    padding: 20px;
    text-align: center;
    margin: 16px 0;
}
.access-code-box .code {
    font-family: 'Courier New', monospace;
    font-size: 1.8rem;
    font-weight: 800;
    letter-spacing: 5px;
    color: var(--brand-primary);
    word-break: break-all;
}
.access-code-box small { color: #1e40af; font-weight: 600; }

/* ===================== FORM GRID ===================== */
.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 16px;
}
.form-grid .full { grid-column: 1 / -1; }
.form-grid label { font-weight: 600; font-size: 0.88rem; display: block; margin-bottom: 6px; color: #334155; }

/* ===================== RESPONSIVE ===================== */
@media (max-width: 768px) {
    body { padding: 0 0 60px; }
    .a4-wrapper { padding: 22px 16px; border-radius: 16px; margin: 14px 10px; }
    h1 { font-size: 1.55rem; }
    h2 { font-size: 1.25rem; }
    h3 { font-size: 1.08rem; }

    .nav-inner { height: auto; padding: 12px 0; gap: 8px; }
    .nav-links { width: 100%; justify-content: center; gap: 4px; }
    .nav-links a { padding: 7px 12px; font-size: 0.82rem; }

    .lesson-image-wrapper img { max-width: 100%; }
    .word-main-bar { padding: 12px 14px; }
    .quiz-section-container { padding: 20px 16px; }
    .quiz-card { padding: 16px 14px; }

    .academic-table th, .academic-table td { padding: 10px 8px; font-size: 0.8rem; }

    .quiz-header-row { flex-direction: column; align-items: flex-start; }
    .quiz-toggle-btn { width: 100%; justify-content: center; }

    .form-grid { grid-template-columns: 1fr; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
    .stat-card { padding: 16px; }
    .stat-value { font-size: 1.4rem; }

    .search-bar .admin-select { width: 100%; }
    .login-card { padding: 30px 22px; margin: 30px 14px; }
    .access-code-box .code { font-size: 1.4rem; letter-spacing: 3px; }
}

@media (max-width: 480px) {
    .a4-wrapper { padding: 18px 14px; }
    .word-main-bar strong { font-size: 0.95rem; }
    .ku-reveal-panel { font-size: 1rem; padding: 10px 14px; }
    .quiz-option-item { padding: 9px 12px; font-size: 0.88rem; }
    .speaker-btn { width: 32px; height: 32px; font-size: 13px; }
    .stats-grid { grid-template-columns: 1fr 1fr; }
    .actions-cell { flex-direction: column; }
    .btn-sm { width: 100%; }
}