/* ===== English Voice Exam - shared stylesheet ===== */
:root {
  --primary: #2f6fed;
  --primary-dark: #1e4fb8;
  --success: #1fa971;
  --danger: #e0473f;
  --warning: #e0a13f;
  --bg: #f4f6fb;
  --card-bg: #ffffff;
  --text: #24304a;
  --muted: #6b7688;
  --border: #e2e6ef;
  --radius: 10px;
}

* { box-sizing: border-box; }
img { max-width: 100%; }

body {
  margin: 0;
  font-family: "Segoe UI", Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 20px;
}

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

h1, h2, h3 { line-height: 1.25; }

/* ---- Header / nav ---- */
.site-header {
  background: var(--card-bg);
  border-bottom: 1px solid var(--border);
}
.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  padding: 14px 20px;
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); }
.brand:hover { text-decoration: none; }
.brand-logo { height: 42px; width: 42px; object-fit: contain; border-radius: 8px; }
.brand-logo-placeholder {
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; background: var(--primary); color: #fff;
}
.brand-name { font-weight: 700; font-size: 1.2rem; }
.main-nav { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.main-nav a { color: var(--text); font-weight: 500; }
.lang-switch {
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 5px 14px;
  font-size: 0.85rem;
  font-weight: 600;
}
.lang-switch:hover { border-color: var(--primary); color: var(--primary); text-decoration: none; }

.header-actions { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }

.nav-toggle {
  display: none;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 5px;
  width: 40px;
  height: 40px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  padding: 8px;
  flex-shrink: 0;
}
.nav-toggle-bar { display: block; height: 2px; width: 100%; background: var(--text); border-radius: 2px; transition: transform 0.2s ease, opacity 0.2s ease; }
.nav-toggle.active .nav-toggle-bar:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.nav-toggle.active .nav-toggle-bar:nth-child(2) { opacity: 0; }
.nav-toggle.active .nav-toggle-bar:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* ---- Buttons ---- */
.btn {
  display: inline-block;
  padding: 10px 20px;
  border-radius: 8px;
  border: 1px solid transparent;
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  text-align: center;
}
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-outline { background: transparent; border-color: var(--border); color: var(--text); }
.btn-outline:hover { border-color: var(--primary); color: var(--primary); }
.btn-success { background: var(--success); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-sm { padding: 6px 14px; font-size: 0.85rem; }
.btn-lg { padding: 16px 34px; font-size: 1.15rem; border-radius: 12px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-block { display: block; width: 100%; }

/* ---- Cards / sections ---- */
.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 26px;
  margin: 24px 0;
}
.hero {
  text-align: center;
  padding: 60px 20px;
}
.hero h1 { font-size: 2.2rem; margin-bottom: 10px; }
.hero p { color: var(--muted); font-size: 1.1rem; max-width: 640px; margin: 0 auto; }
.hero-logo { height: 96px; margin-bottom: 20px; }

.features { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 20px; margin: 30px 0; }
.feature { background: var(--card-bg); border: 1px solid var(--border); border-radius: var(--radius); padding: 22px; }

/* ---- Forms ---- */
.form-group { margin-bottom: 18px; }
label { display: block; font-weight: 600; margin-bottom: 6px; font-size: 0.92rem; }
input[type=text], input[type=password], input[type=email], input[type=number],
select, textarea {
  width: 100%;
  padding: 11px 13px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 1rem;
  background: #fff;
  color: var(--text);
}
textarea { resize: vertical; }
.form-narrow { max-width: 420px; margin: 40px auto; }
.form-actions { margin-top: 22px; }
.hint { color: var(--muted); font-size: 0.85rem; margin-top: 4px; }

/* ---- Alerts ---- */
.alert { padding: 13px 16px; border-radius: 8px; margin: 16px 0; font-weight: 500; }
.alert-success { background: #e4f7ee; color: var(--success); border: 1px solid #b9ecd6; }
.alert-error, .alert-danger { background: #fdeceb; color: var(--danger); border: 1px solid #f7c6c2; }
.alert-info { background: #eaf1fe; color: var(--primary-dark); border: 1px solid #cfe0fd; }
.alert-warning { background: #fdf3e2; color: #92680f; border: 1px solid #f5dfab; }

/* ---- Tables ---- */
table { width: 100%; border-collapse: collapse; margin: 10px 0; }
th, td { padding: 11px 12px; border-bottom: 1px solid var(--border); text-align: left; font-size: 0.94rem; }
th { color: var(--muted); font-weight: 600; text-transform: uppercase; font-size: 0.76rem; letter-spacing: 0.04em; }
tr:hover td { background: #fafbfe; }
.table-actions { display: flex; gap: 10px; }
.table-wrap { overflow-x: auto; }

.badge { display: inline-block; padding: 3px 10px; border-radius: 20px; font-size: 0.76rem; font-weight: 700; }
.badge-admin { background: #ece6fb; color: #6737c9; }
.badge-student { background: #e0f0fd; color: #1c78c4; }
.badge-pass { background: #e4f7ee; color: var(--success); }
.badge-fail { background: #fdeceb; color: var(--danger); }
.badge-active { background: #e4f7ee; color: var(--success); }
.badge-inactive { background: #f1f2f6; color: var(--muted); }

/* ---- Footer ---- */
.site-footer { text-align: center; padding: 26px 0; color: var(--muted); font-size: 0.85rem; }

/* ===================== ADMIN LAYOUT ===================== */
.admin-wrap { display: flex; min-height: 100vh; }
.admin-sidebar {
  width: 230px; flex-shrink: 0; background: #1b2338; color: #cbd3ea;
  padding: 20px 0; position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.admin-sidebar .brand-name { color: #fff; }
.admin-sidebar-header { padding: 0 20px 18px; border-bottom: 1px solid #2c3555; margin-bottom: 12px; }
.admin-sidebar a {
  display: block; padding: 11px 20px; color: #cbd3ea; font-weight: 500; border-left: 3px solid transparent;
}
.admin-sidebar a:hover, .admin-sidebar a.active {
  background: #262f4c; color: #fff; text-decoration: none; border-left-color: var(--primary);
}
.admin-sidebar .section-label { padding: 16px 20px 6px; font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.05em; color: #6a7495; }
.admin-main { flex: 1; padding: 30px; max-width: 1200px; }
.admin-topbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 22px; flex-wrap: wrap; gap: 10px; }
.admin-topbar h1 { margin: 0; font-size: 1.5rem; }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 18px; margin-bottom: 26px; }
.stat-card { background: var(--card-bg); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; }
.stat-card .stat-value { font-size: 1.9rem; font-weight: 700; color: var(--primary); }
.stat-card .stat-label { color: var(--muted); font-size: 0.85rem; }

/* ===================== Distraction-free exam page ===================== */
.exam-fullscreen-body { padding-top: 10px; }
.exam-top-actions {
  position: fixed;
  top: 14px;
  left: 14px;
  z-index: 500;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}
[dir="rtl"] .exam-top-actions { left: auto; right: 14px; }
.exam-home-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--card-bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 8px 16px;
  font-weight: 600;
  font-size: 0.9rem;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}
.exam-home-btn:hover { border-color: var(--primary); color: var(--primary); text-decoration: none; }
@media (max-width: 480px) {
  .exam-top-actions { top: 8px; left: 8px; }
  [dir="rtl"] .exam-top-actions { right: 8px; }
  .exam-home-btn { padding: 7px 12px; font-size: 0.8rem; }
}

/* ===================== Lesson hub (3-icon menu) ===================== */
.lesson-hub { max-width: 760px; margin: 20px auto; }
.hub-tiles {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
  margin: 30px 0;
}
.hub-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  background-color: var(--hub-tile-bg, var(--card-bg));
  background-image: var(--hub-tile-bg-img, none);
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  border-style: solid;
  border-color: var(--hub-tile-frame-color, var(--border));
  border-width: var(--hub-tile-frame-width, 1px);
  border-radius: 16px;
  padding: 30px 16px;
  text-align: center;
  color: var(--text);
  transition: border-color 0.15s ease, transform 0.15s ease;
}
.hub-tile:hover { border-color: var(--primary); transform: translateY(-2px); text-decoration: none; }
.hub-tile-icon { font-size: 2.6rem; line-height: 1; }
.hub-tile-icon-img {
  width: var(--hub-img-size, 72px);
  height: var(--hub-img-size, 72px);
  object-fit: contain;
  border-radius: 10px;
  background: var(--hub-img-frame-bg, transparent);
  border-style: solid;
  border-width: var(--hub-img-frame-width, 0px);
  border-color: var(--hub-img-frame-color, transparent);
}
.hub-tile-label { font-weight: 700; font-size: 1rem; }
.hub-tile-disabled { opacity: 0.45; cursor: not-allowed; }
.hub-tile-disabled:hover { transform: none; border-color: var(--hub-tile-frame-color, var(--border)); }
@media (max-width: 640px) {
  .hub-tiles { grid-template-columns: 1fr; }
}

/* ===================== Exam picker lists (Word Exams / Question Exams) ===================== */
.exam-list-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
  margin: 20px 0;
}
.exam-list-card {
  display: block;
  background-color: var(--exlist-bg, var(--card-bg));
  background-image: var(--exlist-bg-img, none);
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  border-style: solid;
  border-color: var(--exlist-frame-color, var(--border));
  border-width: var(--exlist-frame-width, 1px);
  border-radius: 14px;
  padding: 20px;
  color: var(--text);
  transition: border-color 0.15s ease, transform 0.15s ease;
}
.exam-list-card:hover { border-color: var(--primary); transform: translateY(-2px); text-decoration: none; }
.exam-list-card h3 { margin: 0 0 6px; }
.exam-list-card p { margin: 0; }

/* Review Lessons list cards - like .exam-list-card but with admin-configurable size */
.review-list-card {
  display: flex;
  flex-direction: column;
  justify-content: center;
  width: var(--rvlist-card-width, 260px);
  min-height: var(--rvlist-card-height, 160px);
  max-width: 100%;
  background-color: var(--rvlist-bg, var(--card-bg));
  background-image: var(--rvlist-bg-img, none);
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  border-style: solid;
  border-color: var(--rvlist-frame-color, var(--border));
  border-width: var(--rvlist-frame-width, 1px);
  border-radius: 14px;
  padding: 20px;
  color: var(--text);
  transition: border-color 0.15s ease, transform 0.15s ease;
}
.review-list-card:hover { border-color: var(--primary); transform: translateY(-2px); text-decoration: none; }
.review-list-card h3 { margin: 0 0 6px; }
.review-list-card p { margin: 0; }
.review-list-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  margin: 20px 0;
}

/* ===================== Lesson Review page (3 customizable sections) ===================== */
.lr-section {
  border-radius: var(--radius);
  padding: 24px;
  margin: 20px 0;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
}
.lr-section-image { text-align: center; }
.lr-section-image img { max-width: 100%; border-radius: 12px; display: inline-block; }
.lr-section-text { white-space: pre-line; line-height: 1.8; }
.lr-section-ar { direction: rtl; }
.lr-word { transition: background-color 0.1s ease; border-radius: 3px; }
.lr-word-active { background-color: var(--lr-highlight-color, #fff59d); box-shadow: 0 0 0 2px var(--lr-highlight-color, #fff59d); }

/* ===================== STUDENT / EXAM ===================== */
.exam-shell { max-width: 720px; margin: 30px auto; }
.exam-progress { text-align: center; color: var(--muted); margin-bottom: 10px; font-weight: 600; }
.exam-card {
  background-color: var(--examcard-bg, var(--card-bg));
  background-size: cover; background-position: center; background-repeat: no-repeat;
  border: 1px solid var(--border); border-radius: 18px;
  padding: 40px; text-align: center;
}
.exam-word-image {
  width: var(--frame-size, 260px);
  max-width: 80vw;
  aspect-ratio: 1 / 1;
  height: auto;
  margin: 0 auto 20px;
  background: var(--frame-bg, #f4f6fb);
  border: var(--frame-border-width, 0px) solid var(--frame-border-color, transparent);
  border-radius: 14px; display: flex; align-items: center; justify-content: center;
  overflow: hidden;
}
.exam-word-image img { max-width: 100%; max-height: 100%; object-fit: contain; }
.exam-word-text { font-size: 2.4rem; font-weight: 800; color: var(--text); margin: 10px 0 6px; letter-spacing: 0.02em; }
.exam-word-text-ar { font-size: 1.4rem; font-weight: 600; color: var(--muted); margin: 0 0 26px; direction: rtl; }
.exam-buttons { display: flex; gap: 14px; justify-content: center; flex-wrap: wrap; }
.exam-btn {
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  border: var(--btn-frame-width, 2px) solid var(--btn-frame-color, var(--border));
  background-color: var(--btn-bg, #fff);
  background-size: cover; background-position: center; background-repeat: no-repeat;
  border-radius: 14px;
  padding: calc(18px * var(--btn-scale, 1)) calc(26px * var(--btn-scale, 1));
  min-width: calc(120px * var(--btn-scale, 1)); cursor: pointer; font-weight: 600;
  color: var(--btn-text, var(--text));
  font-size: var(--btn-font-size, inherit);
}
.exam-btn .icon { font-size: calc(1.8rem * var(--btn-scale, 1)); }
.exam-btn:hover { border-color: var(--primary); color: var(--primary); }
.exam-btn.recording { border-color: var(--danger); color: var(--danger); animation: pulse 1s infinite; }
.exam-btn:disabled { opacity: 0.45; cursor: not-allowed; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(224,71,63,0.4); } 70% { box-shadow: 0 0 0 12px rgba(224,71,63,0); } 100% { box-shadow: 0 0 0 0 rgba(224,71,63,0); } }

.exam-feedback { margin-top: 24px; font-size: 1.1rem; font-weight: 700; min-height: 30px; }
.exam-feedback.correct { color: var(--success); }
.exam-feedback.wrong { color: var(--danger); }
.exam-attempts-left { color: var(--muted); font-size: 0.9rem; margin-top: 6px; }

.feedback-overlay {
  position: fixed; inset: 0; background: rgba(20,26,44,0.55);
  display: flex; align-items: center; justify-content: center; z-index: 999;
}
.feedback-box {
  background: #fff; border-radius: 20px; padding: 40px 50px; text-align: center;
  animation: pop 0.25s ease-out;
}
@keyframes pop { from { transform: scale(0.7); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.feedback-box .big-icon { font-size: 4.5rem; margin-bottom: 10px; }
.feedback-box.correct .big-icon { color: var(--success); }
.feedback-box.wrong .big-icon { color: var(--danger); }
.feedback-box img.feedback-gif { width: 160px; height: 160px; object-fit: contain; margin-top: 8px; }
.feedback-box p { font-size: 1.3rem; font-weight: 700; margin: 6px 0 0; }

.grade-lesson-form { max-width: 480px; margin: 40px auto; text-align: center; }

/* ---- Result / report ---- */
.report-card { max-width: 700px; margin: 30px auto; }
.report-header { text-align: center; margin-bottom: 20px; }
.report-header img { height: 70px; margin-bottom: 10px; }
.result-summary { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px,1fr)); gap: 16px; margin: 24px 0; }
.result-summary .box { text-align: center; padding: 18px; border-radius: 12px; background: #f4f6fb; }
.result-summary .box .num { font-size: 1.8rem; font-weight: 800; }
.pass-banner { text-align: center; padding: 16px; border-radius: 12px; font-size: 1.3rem; font-weight: 800; margin: 20px 0; }
.pass-banner.pass { background: #e4f7ee; color: var(--success); }
.pass-banner.fail { background: #fdeceb; color: var(--danger); }

/* ---- Editable page sections (CMS blocks on Home / Contact) ---- */
.page-sections { display: flex; flex-direction: column; gap: 22px; margin: 30px 0; }
.page-section {
  display: flex; gap: 26px; align-items: center;
  background: var(--card-bg); border: 1px solid var(--border); border-radius: var(--radius); padding: 26px;
}
.page-section.no-image { display: block; }
.page-section .section-image { flex: 0 0 240px; }
.page-section .section-image img { width: 100%; border-radius: 10px; display: block; object-fit: cover; max-height: 220px; }
.page-section .section-body { flex: 1; min-width: 0; }
.page-section h3 { margin-top: 0; }
.page-section p { color: var(--muted); white-space: pre-line; margin-bottom: 0; }
.page-section:nth-child(even) { flex-direction: row-reverse; }
[dir="rtl"] .page-section:nth-child(even) { flex-direction: row; }
@media (max-width: 640px) {
  .page-section, .page-section:nth-child(even) { flex-direction: column; }
  .page-section .section-image { flex: none; width: 100%; }
}

@media print {
  .site-header, .site-footer, .no-print { display: none !important; }
  body { background: #fff; }
  .report-card { margin: 0; max-width: 100%; }
}

@media (max-width: 720px) {
  .admin-wrap { flex-direction: column; }
  .admin-sidebar { width: 100%; height: auto; position: static; }
  .admin-main { padding: 18px; }
}

/* ===================== Mobile/tablet hamburger nav ===================== */
@media (max-width: 768px) {
  .nav-toggle { display: flex; }
  .brand { order: 1; }
  .header-actions { order: 2; }
  .main-nav {
    display: none;
    order: 3;
    flex-direction: column;
    align-items: stretch;
    width: 100%;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 12px;
    margin-top: 8px;
    gap: 4px;
  }
  .main-nav.nav-open { display: flex; }
  .main-nav a { padding: 10px 8px; border-radius: 6px; }
  .main-nav a:hover { background: var(--bg); text-decoration: none; }
  .main-nav .btn { width: 100%; text-align: center; margin-top: 4px; }
  .header-actions .lang-switch { padding: 5px 10px; font-size: 0.8rem; }
}

/* ===================== Responsive: phones & small tablets ===================== */
@media (max-width: 600px) {
  .hero { padding: 40px 16px; }
  .hero h1 { font-size: 1.6rem; }
  .hero p { font-size: 1rem; }
  .hero-logo { height: 64px; }

  .card { padding: 18px; }
  .exam-card { padding: 22px 16px; }
  .exam-word-text { font-size: 1.7rem; margin: 8px 0 4px; }
  .exam-word-text-ar { font-size: 1.1rem; margin: 0 0 18px; }
  .exam-btn { padding: calc(12px * var(--btn-scale, 1)) calc(16px * var(--btn-scale, 1)); min-width: calc(96px * var(--btn-scale, 1)); font-size: calc(0.85 * var(--btn-font-size, 1rem)); }
  .exam-btn .icon { font-size: calc(1.4rem * var(--btn-scale, 1)); }
  .exam-buttons { gap: 10px; }

  .feedback-box { padding: 26px 22px; }
  .feedback-box .big-icon { font-size: 3.2rem; }
  .feedback-box img.feedback-gif { width: 110px; height: 110px; }

  .brand-name { font-size: 1rem; }
  .main-nav { gap: 10px; }
  .btn-lg { padding: 13px 24px; font-size: 1rem; }

  .report-header img { height: 50px; }
  .result-summary .box .num { font-size: 1.4rem; }
  .pass-banner { font-size: 1.05rem; }
}

@media (max-width: 380px) {
  .exam-buttons { flex-direction: column; align-items: stretch; }
  .exam-btn { flex-direction: row; justify-content: center; }
}

/* ===================== RTL (Arabic) adjustments ===================== */
[dir="rtl"] body { font-family: "Segoe UI", Tahoma, Arial, sans-serif; }
[dir="rtl"] th, [dir="rtl"] td { text-align: right; }
[dir="rtl"] .admin-sidebar a { border-left-color: transparent; border-right: 3px solid transparent; }
[dir="rtl"] .admin-sidebar a:hover, [dir="rtl"] .admin-sidebar a.active { border-left-color: transparent; border-right-color: var(--primary); }
[dir="rtl"] .badge, [dir="rtl"] .exam-btn .icon { direction: ltr; }

/* ===================== QUESTION EXAM PAGE / CARD (admin-configurable) ===================== */
.qpage-wrap {
  border-radius: 14px;
  padding: 18px;
}
.qcard { background-size: cover; background-position: center; background-repeat: no-repeat; }

/* ===================== LESSON / EXAM SCOPE TEXT STYLE (admin-configurable) ===================== */
/* Applies across every page/card/block/button tagged with .txt-lesson or
   .txt-exam. Blank admin settings leave the CSS variable undefined, so the
   `inherit` fallback keeps the site's normal look untouched. Elements that
   already set their own inline color/font-size (e.g. Lesson Review image
   and text sections) are unaffected, since inline styles always win. */
.txt-lesson,
.txt-lesson h1, .txt-lesson h2, .txt-lesson h3,
.txt-lesson p, .txt-lesson span, .txt-lesson label, .txt-lesson li,
.txt-lesson td, .txt-lesson th, .txt-lesson .hint, .txt-lesson .btn {
  color: var(--lesson-text-color, inherit);
  font-size: var(--lesson-text-size, inherit);
}

.txt-exam,
.txt-exam h1, .txt-exam h2, .txt-exam h3,
.txt-exam p, .txt-exam span, .txt-exam label, .txt-exam li,
.txt-exam td, .txt-exam th, .txt-exam .hint, .txt-exam .btn {
  color: var(--exam-text-color, inherit);
  font-size: var(--exam-text-size, inherit);
}
[dir="rtl"] .exam-word-text { direction: ltr; } /* English vocabulary word stays LTR even in an RTL page */
