/* ===== RESET & BASE ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --primary: #DD0000;
  --primary-dark: #b80000;
  --primary-light: #fde8e8;
  --accent: #0ea5e9;
  --success: #16a34a;
  --warning: #d97706;
  --danger: #dc2626;
  --bg: #f8fafc;
  --surface: #ffffff;
  --border: #e2e8f0;
  --text: #1e293b;
  --text-muted: #64748b;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 4px 16px rgba(0,0,0,0.06);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.12);
}

body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
}

/* ===== AUTH PAGE ===== */
.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #1e3a8a 0%, #0ea5e9 100%);
}

.auth-container {
  background: var(--surface);
  border-radius: 16px;
  padding: 40px;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow-lg);
}

.auth-logo { text-align: center; margin-bottom: 28px; }
.auth-logo h1 { font-size: 28px; color: var(--text); font-weight: 800; }
.auth-logo h1 span { color: var(--primary); }
.auth-logo p { color: var(--text-muted); font-size: 14px; margin-top: 4px; }

.auth-tabs {
  display: flex;
  background: var(--bg);
  border-radius: var(--radius);
  padding: 4px;
  margin-bottom: 24px;
}

.tab-btn {
  flex: 1;
  padding: 10px;
  border: none;
  background: transparent;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-muted);
  transition: all 0.2s;
}

.tab-btn.active {
  background: var(--surface);
  color: var(--primary);
  box-shadow: var(--shadow);
  font-weight: 600;
}

.auth-form { display: flex; flex-direction: column; gap: 16px; }
.auth-form.hidden { display: none; }

.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group label { font-size: 13px; font-weight: 600; color: var(--text); }
.form-group input {
  padding: 11px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-size: 15px;
  outline: none;
  transition: border-color 0.2s;
}
.form-group input:focus { border-color: var(--primary); }

.btn-primary {
  padding: 12px;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: var(--radius);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
  margin-top: 4px;
}
.btn-primary:hover { background: var(--primary-dark); }
.btn-primary:active { transform: scale(0.98); }

.error-msg { color: var(--danger); font-size: 13px; text-align: center; min-height: 18px; }

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

/* Sidebar */
.sidebar {
  width: 240px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 24px 0;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  z-index: 100;
}

.sidebar-logo {
  padding: 0 20px 24px;
  border-bottom: 1px solid var(--border);
}
.sidebar-logo h2 { font-size: 18px; font-weight: 800; color: var(--text); }
.sidebar-logo h2 span { color: var(--primary); }
.sidebar-logo small { color: var(--text-muted); font-size: 12px; }

.sidebar-nav { flex: 1; padding: 16px 12px; display: flex; flex-direction: column; gap: 4px; overflow-y: auto; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius);
  text-decoration: none;
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 500;
  transition: all 0.2s;
  cursor: pointer;
  border: none;
  background: transparent;
  width: 100%;
  text-align: left;
}
.nav-item:hover { background: var(--bg); color: var(--text); }
.nav-item.active { background: var(--primary-light); color: var(--primary); font-weight: 600; }
.nav-item .icon { font-size: 18px; width: 22px; text-align: center; }

.sidebar-footer {
  padding: 16px 12px 0;
  border-top: 1px solid var(--border);
}
.user-info {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius);
  background: var(--bg);
  margin-bottom: 8px;
}
.avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--primary);
  color: white;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 15px;
}
.user-name { font-size: 13px; font-weight: 600; }
.user-role { font-size: 11px; color: var(--text-muted); }

.btn-logout {
  width: 100%;
  padding: 9px;
  background: transparent;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-muted);
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s;
}
.btn-logout:hover { border-color: var(--danger); color: var(--danger); }

/* Main Content */
.main-content {
  margin-left: 240px;
  flex: 1;
  padding: 32px;
}

.page-header { margin-bottom: 28px; }
.page-header h1 { font-size: 24px; font-weight: 700; }
.page-header p { color: var(--text-muted); font-size: 14px; margin-top: 4px; }

/* Dashboard hero */
.dashboard-hero {
  text-align: center;
  padding: 60px 20px 40px;
}
.dashboard-hero h1 {
  font-size: 32px;
  font-weight: 800;
  color: var(--text);
  margin-bottom: 8px;
}
.hero-subtitle {
  font-size: 18px;
  color: var(--primary);
  font-weight: 600;
  margin-bottom: 28px;
}
.hero-quote {
  max-width: 520px;
  margin: 0 auto;
  font-size: 16px;
  font-style: italic;
  color: var(--text-muted);
  line-height: 1.7;
  border-left: 3px solid var(--primary);
  padding: 12px 20px;
  text-align: left;
  background: var(--surface);
  border-radius: 0 10px 10px 0;
}
.quote-vi {
  margin-top: 10px;
  font-size: 14px;
  font-style: normal;
  color: var(--text);
  opacity: 0.7;
  line-height: 1.6;
}
.hero-quote cite {
  display: block;
  margin-top: 8px;
  font-size: 13px;
  font-style: normal;
  font-weight: 600;
  color: var(--primary);
  text-align: right;
}

/* Dashboard action cards */
.dashboard-actions {
  display: flex;
  gap: 20px;
  justify-content: center;
  padding: 0 20px;
  max-width: 500px;
  margin: 0 auto;
}
.dash-action-card {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 32px 20px;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: 16px;
  text-decoration: none;
  transition: all 0.2s;
  box-shadow: var(--shadow);
}
.dash-action-card:hover {
  border-color: var(--primary);
  transform: translateY(-3px);
  box-shadow: var(--shadow-lg);
}
.dash-action-icon { font-size: 36px; }
.dash-action-label {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
}

/* Cards */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 20px;
  box-shadow: var(--shadow);
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}
.stat-card .stat-icon { font-size: 28px; margin-bottom: 8px; }
.stat-card .stat-value { font-size: 28px; font-weight: 800; color: var(--primary); }
.stat-card .stat-label { font-size: 13px; color: var(--text-muted); margin-top: 2px; }

/* Reading list */
.reading-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

.reading-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
  color: inherit;
  display: block;
}
.reading-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); border-color: var(--primary); }

.reading-card .badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  margin-bottom: 10px;
}
.badge-new { background: #dcfce7; color: #16a34a; }
.badge-read { background: #e0e7ff; color: #4f46e5; }
.badge-done { background: #dbeafe; color: #1d4ed8; }
.badge-inprogress { background: #fef9c3; color: #a16207; }

.reading-card h3 { font-size: 15px; font-weight: 600; margin-bottom: 6px; }
.reading-card p { font-size: 13px; color: var(--text-muted); line-height: 1.5; }
.reading-card .card-meta {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-muted);
}

/* ===== READING PAGE ===== */
.reading-page { height: 100vh; display: flex; flex-direction: column; overflow: hidden; }

.reading-topbar {
  display: flex;
  align-items: center;
  padding: 0 20px;
  height: 56px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  gap: 16px;
  flex-shrink: 0;
}

.back-btn {
  display: flex; align-items: center; gap: 6px;
  color: var(--text-muted); text-decoration: none;
  font-size: 14px; font-weight: 500;
  padding: 6px 10px; border-radius: 8px;
  transition: all 0.2s;
}
.back-btn:hover { background: var(--bg); color: var(--text); }

.reading-topbar h2 {
  flex: 1;
  font-size: 15px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Language toggle */
.lang-controls {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.lang-group {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  background: var(--bg);
  border-radius: 20px;
  border: 1px solid var(--border);
}
.lang-group label { font-size: 12px; color: var(--text-muted); font-weight: 500; }

.toggle-switch {
  position: relative;
  width: 44px;
  height: 22px;
  display: inline-block;
}
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background: #cbd5e1;
  border-radius: 22px;
  transition: 0.2s;
}
.toggle-slider::before {
  content: '';
  position: absolute;
  width: 16px; height: 16px;
  left: 3px; bottom: 3px;
  background: white;
  border-radius: 50%;
  transition: 0.2s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}
.toggle-switch input:checked + .toggle-slider { background: var(--primary); }
.toggle-switch input:checked + .toggle-slider::before { transform: translateX(22px); }

.toggle-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--primary);
  min-width: 20px;
}

/* Split screen */
.reading-body {
  display: flex;
  flex: 1;
  overflow: hidden;
}

.reading-pane {
  flex: 1;
  overflow-y: auto;
  padding: 24px 28px;
}

.reading-pane:first-child {
  border-right: 2px solid var(--border);
}

.pane-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}
.pane-header h3 { font-size: 14px; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; }

.passage-content {
  font-size: 15px;
  line-height: 1.85;
  color: var(--text);
}
.passage-content p { margin-bottom: 14px; }

/* Highlight colors */
.hl-green  { background: #bbf7d0; border-radius: 2px; padding: 0 1px; }
.hl-blue   { background: #bae6fd; border-radius: 2px; padding: 0 1px; }
.hl-yellow { background: #fef08a; border-radius: 2px; padding: 0 1px; }
.hl-red    { background: #fecaca; border-radius: 2px; padding: 0 1px; }
.hl-pink   { background: #fbcfe8; border-radius: 2px; padding: 0 1px; }
/* Find reminder popup */
#find-reminder {
  position: fixed;
  top: 70px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 9998;
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--text);
  color: white;
  padding: 10px 16px;
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.3);
  font-size: 14px;
  animation: slideDown 0.3s ease;
}
@keyframes slideDown {
  from { opacity: 0; transform: translateX(-50%) translateY(-20px); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}
.reminder-label {
  font-size: 12px;
  color: rgba(255,255,255,0.6);
  white-space: nowrap;
}
.reminder-word {
  font-weight: 500;
  color: rgba(255,255,255,0.9);
  font-size: 14px;
  max-width: 500px;
  line-height: 1.5;
}
.reminder-close {
  background: rgba(255,255,255,0.15);
  border: none;
  color: white;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.reminder-close:hover { background: rgba(255,255,255,0.3); }

/* Sentence markers [ ] – xoay vòng 4 màu */
.sent-marked {
  border-radius: 3px;
  padding: 2px 0;
}
.sent-marked::before {
  font-weight: 700;
  font-size: 0.9em;
}
.sent-marked::after {
  font-weight: 700;
  font-size: 0.9em;
}

.sent-color-0 { background: rgba(59,130,246,0.10); }
.sent-color-0::before { content: '[ '; color: #3b82f6; }
.sent-color-0::after  { content: ' ]'; color: #3b82f6; }

.sent-color-1 { background: rgba(234,179,8,0.12); }
.sent-color-1::before { content: '[ '; color: #ca8a04; }
.sent-color-1::after  { content: ' ]'; color: #ca8a04; }

.sent-color-2 { background: rgba(16,185,129,0.10); }
.sent-color-2::before { content: '[ '; color: #059669; }
.sent-color-2::after  { content: ' ]'; color: #059669; }

.sent-color-3 { background: rgba(168,85,247,0.10); }
.sent-color-3::before { content: '[ '; color: #9333ea; }
.sent-color-3::after  { content: ' ]'; color: #9333ea; }

.hl-strikethrough { text-decoration: line-through; text-decoration-thickness: 2px; }
.hl-underline-red { text-decoration: underline; text-decoration-color: #ef4444; text-decoration-thickness: 2px; text-underline-offset: 3px; }
.hl-strikethrough.hl-underline-red { text-decoration: line-through underline; text-decoration-color: #ef4444; text-decoration-thickness: 2px; }

/* Highlight popup */
#highlight-popup {
  position: fixed;
  z-index: 1000;
  background: var(--text);
  border-radius: 10px;
  padding: 8px;
  display: none;
  flex-direction: column;
  gap: 4px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.25);
  min-width: 200px;
  max-height: 70vh;
  overflow-y: auto;
}

.popup-colors {
  display: flex;
  gap: 6px;
  padding: 4px 6px;
  align-items: center;
}
.color-btn {
  width: 22px; height: 22px;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.3);
  cursor: pointer;
  transition: transform 0.1s;
}
.color-btn:hover { transform: scale(1.2); border-color: white; }
.color-btn.c-green  { background: #22c55e; }
.color-btn.c-blue   { background: #38bdf8; }
.color-btn.c-yellow { background: #facc15; }
.color-btn.c-red    { background: #f87171; }
.color-btn.c-pink   { background: #f472b6; }

.popup-divider { height: 1px; background: rgba(255,255,255,0.15); margin: 2px 0; }

.popup-action {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border-radius: 7px;
  color: white;
  font-size: 13px;
  cursor: pointer;
  transition: background 0.15s;
}
.popup-action:hover { background: rgba(255,255,255,0.12); }
.popup-action .icon { font-size: 15px; }

/* Synonym input */
.synonym-input-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
}
.synonym-input-row input {
  flex: 1;
  padding: 6px 10px;
  background: rgba(255,255,255,0.12);
  border: 1px solid rgba(255,255,255,0.25);
  border-radius: 6px;
  color: white;
  font-size: 13px;
  outline: none;
}
.synonym-input-row input::placeholder { color: rgba(255,255,255,0.45); }
.synonym-input-row input:focus { border-color: var(--accent); }
.synonym-save-btn {
  padding: 6px 12px;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 6px;
  font-size: 12px;
  cursor: pointer;
  font-weight: 600;
}

/* Question groups */
.question-group {
  margin-bottom: 24px;
  border: 1.5px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  background: var(--surface);
}
.group-header {
  background: linear-gradient(135deg, #fff0f0 0%, #ffe8e8 100%);
  border-bottom: 1.5px solid var(--border);
  padding: 14px 18px;
}
.group-range {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--primary);
  letter-spacing: 0.5px;
  margin-bottom: 6px;
}
.group-instruction {
  font-size: 14px;
  color: var(--text);
  line-height: 1.7;
  margin-bottom: 8px;
}
.group-options {
  margin-top: 10px;
  padding: 10px 14px;
  background: rgba(255,255,255,0.7);
  border-radius: 8px;
  border: 1px solid rgba(221,0,0,0.15);
}
.group-option-item {
  font-size: 13px;
  color: var(--text);
  padding: 3px 0;
  line-height: 1.5;
}
.group-questions {
  padding: 14px 18px;
}

/* Questions pane */
.question-item {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  margin-bottom: 14px;
}
.question-item:last-child { margin-bottom: 0; }
.question-item .q-number {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 0.5px;
  margin-bottom: 6px;
}
.question-item .q-text {
  font-size: 15px;
  font-weight: 500;
  color: var(--text);
  margin-bottom: 10px;
  line-height: 1.6;
}
.answer-box {
  background: #f0fdf4;
  border: 1.5px solid #86efac;
  border-radius: 8px;
  padding: 10px 14px;
  margin-bottom: 8px;
}
.answer-box .answer-label {
  font-size: 11px;
  font-weight: 700;
  color: #16a34a;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.answer-box .answer-text {
  font-size: 14px;
  font-weight: 600;
  color: #15803d;
  margin-top: 2px;
}

.why-section { margin-top: 8px; }
.why-toggle {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 13px;
  color: var(--primary);
  cursor: pointer;
  font-weight: 500;
  padding: 4px 0;
  background: none;
  border: none;
}
.why-toggle:hover { text-decoration: underline; }
.why-content {
  margin-top: 8px;
  padding: 10px 14px;
  background: var(--primary-light);
  border-radius: 8px;
  font-size: 13px;
  color: #1e40af;
  line-height: 1.6;
  display: none;
}
.why-content.open { display: block; }

/* Synonym inline tag (hiện ngay cạnh từ được bôi trong bài) */
.synonym-inline {
  display: inline-block;
  margin-left: 4px;
  padding: 1px 7px;
  background: #ede9fe;
  color: #6d28d9;
  border-radius: 10px;
  font-size: 12px;
  font-weight: 600;
  vertical-align: middle;
  line-height: 1.6;
  white-space: nowrap;
}

/* Hộp giải thích "Tại sao lại như vậy?" – luôn hiển thị */
.why-box {
  margin-top: 10px;
  padding: 10px 14px;
  background: var(--primary-light);
  border-radius: 8px;
  font-size: 13px;
  color: #1e40af;
  line-height: 1.6;
  display: flex;
  gap: 7px;
  align-items: flex-start;
}
.why-box .why-icon { flex-shrink: 0; font-size: 15px; margin-top: 1px; }

/* Nút "nằm ở đoạn nào?" */
.find-para-btn {
  margin-top: 10px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: transparent;
  border: 1.5px solid var(--primary);
  color: var(--primary);
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}
.find-para-btn:hover {
  background: var(--primary-light);
}

/* Flash animation cho đoạn văn */
@keyframes para-flash {
  0%   { background-color: transparent; }
  15%  { background-color: #fef08a; }
  50%  { background-color: #fde047; }
  85%  { background-color: #fef08a; }
  100% { background-color: transparent; }
}
.para-flash {
  animation: para-flash 1.4s ease;
  border-radius: 6px;
}

/* Vocabulary panel */
.vocab-panel {
  width: 300px;
  background: var(--surface);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  flex-shrink: 0;
}

.vocab-panel-header {
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.vocab-panel-header h3 { font-size: 14px; font-weight: 700; }

.vocab-tabs {
  display: flex;
  border-bottom: 1.5px solid var(--border);
  padding: 0 12px;
}
.vocab-tab {
  flex: 1;
  padding: 10px 8px;
  background: none;
  border: none;
  border-bottom: 2.5px solid transparent;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  text-align: center;
  transition: all 0.15s;
}
.vocab-tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}
.vocab-tab:hover { color: var(--text); }
.tab-badge {
  display: inline-block;
  background: var(--border);
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 10px;
  margin-left: 4px;
}
.vocab-tab.active .tab-badge {
  background: var(--primary-light);
  color: var(--primary);
}

.vocab-panel-body { flex: 1; overflow-y: auto; padding: 12px; }

.vocab-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 10px 12px;
  border-radius: 8px;
  background: var(--bg);
  border: 1px solid var(--border);
  margin-bottom: 8px;
  font-size: 13px;
}
.vocab-item .vocab-word { font-weight: 700; color: var(--text); }
.vocab-item .vocab-syn { color: var(--text-muted); margin-top: 2px; }
.vocab-item .vocab-syn span { color: var(--primary); font-weight: 500; }
.vocab-delete {
  margin-left: auto;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 16px;
  line-height: 1;
  padding: 0 2px;
}
.vocab-delete:hover { color: var(--danger); }

/* Vocab panel: 2/3 list + 1/3 notes */
.vocab-panel-body {
  flex: 2;
  overflow-y: auto;
  padding: 12px;
  min-height: 0; /* bắt buộc để flex shrink hoạt động */
}

/* Export bar (giữa vocab list và notes) */
.vocab-export-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 14px;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  flex-shrink: 0;
}
.export-trigger-btn {
  padding: 5px 12px;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 7px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}
.export-trigger-btn:hover { background: var(--primary-dark); }

/* Notes: 1/3 */
.note-area {
  flex: 1;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-height: 0;
}
.note-area label { font-size: 12px; font-weight: 600; color: var(--text-muted); }
.note-area textarea {
  flex: 1;
  width: 100%;
  min-height: 0;
  padding: 8px 10px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
  resize: none;
  outline: none;
  font-family: inherit;
  line-height: 1.5;
}
.note-area textarea:focus { border-color: var(--primary); }
.note-save-btn {
  padding: 7px 16px;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 7px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  align-self: flex-end;
}
.note-save-btn:hover { background: var(--primary-dark); }

/* Modal xuất từ vựng */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,0.55);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal-box {
  background: var(--surface);
  border-radius: 14px;
  padding: 24px;
  width: 100%;
  max-width: 520px;
  box-shadow: var(--shadow-lg);
  max-height: 90vh;
  overflow-y: auto;
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.modal-header h3 { font-size: 17px; font-weight: 700; }
.modal-close {
  background: none; border: none;
  font-size: 22px; cursor: pointer;
  color: var(--text-muted); line-height: 1;
}
.modal-close:hover { color: var(--text); }

.export-platform-btns {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
}
.platform-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 14px 10px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  transition: all 0.15s;
}
.platform-btn:hover { border-color: var(--primary); color: var(--primary); }
.platform-btn.active { border-color: var(--primary); background: var(--primary-light); color: var(--primary); }

.export-instruction {
  font-size: 13px;
  color: var(--text-muted);
  background: var(--bg);
  border-radius: 8px;
  padding: 10px 12px;
  margin-bottom: 12px;
  line-height: 1.6;
}
.export-textarea {
  width: 100%;
  min-height: 160px;
  padding: 10px 12px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-family: 'Courier New', monospace;
  font-size: 13px;
  background: #f8fafc;
  resize: vertical;
  outline: none;
  cursor: text;
}

/* Scrollbar styling */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

/* Utility */
.hidden { display: none !important; }
.flex { display: flex; }
.gap-2 { gap: 8px; }

/* Export/Import buttons */
.topbar-btn-outline {
  padding: 8px 14px !important;
  font-size: 13px !important;
  background: transparent !important;
  border: 1.5px solid rgba(255,255,255,0.3) !important;
  color: var(--text-muted) !important;
}
.topbar-btn-outline:hover {
  background: var(--primary-light) !important;
  border-color: var(--primary) !important;
  color: var(--primary) !important;
}

/* Grading mode */
.grading-error {
  border-color: #dc2626 !important;
  background: #fef2f2 !important;
  box-shadow: 0 0 0 2px rgba(220,38,38,0.3);
}

/* Admin action buttons */
.admin-action-btn {
  padding: 4px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: transparent;
  font-size: 12px;
  cursor: pointer;
  color: var(--text-muted);
  white-space: nowrap;
}
.admin-action-btn:hover { background: var(--bg); color: var(--text); }
.admin-delete-btn:hover { background: #fef2f2; color: var(--danger); border-color: var(--danger); }

/* ===== LISTENING PAGE ===== */

/* Audio Player */
.audio-player-section {
  padding: 18px;
  border-bottom: 1.5px solid var(--border);
  background: linear-gradient(135deg, #fff0f0 0%, #fff8f8 100%);
}
.audio-player {
  background: var(--surface);
  border-radius: 12px;
  padding: 14px 18px;
  box-shadow: var(--shadow);
}
.player-controls {
  display: flex;
  align-items: center;
  gap: 12px;
}
.player-btn {
  width: 42px; height: 42px;
  border-radius: 50%;
  border: none;
  background: var(--primary);
  color: white;
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s;
}
.player-btn:hover { background: var(--primary-dark); }
.player-progress-wrap {
  flex: 1;
  height: 8px;
  background: var(--border);
  border-radius: 4px;
  cursor: pointer;
  overflow: hidden;
}
.player-progress {
  height: 100%;
  background: var(--primary);
  border-radius: 4px;
  width: 0%;
  transition: width 0.2s linear;
}
.player-time {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 600;
  white-space: nowrap;
  min-width: 80px;
  text-align: right;
}
.player-speed {
  display: flex;
  gap: 6px;
  margin-top: 10px;
  justify-content: center;
}
.speed-btn {
  padding: 4px 10px;
  border: 1.5px solid var(--border);
  border-radius: 14px;
  background: transparent;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  color: var(--text-muted);
  transition: all 0.15s;
}
.speed-btn.active {
  background: var(--primary);
  border-color: var(--primary);
  color: white;
}
.speed-btn:hover { border-color: var(--primary); color: var(--primary); }
.speed-btn.active:hover { color: white; }

/* Fill-in-the-blank Questions */
.listening-questions {
  padding: 18px;
  font-size: 15px;
  line-height: 2;
  color: var(--text);
}
.listening-section {
  margin-bottom: 20px;
}
.section-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 10px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.section-content { line-height: 2.2; }
.blank-wrap {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin: 2px 4px;
  vertical-align: middle;
}
.blank-num {
  font-size: 11px;
  font-weight: 700;
  color: white;
  background: var(--primary);
  border-radius: 10px;
  padding: 1px 7px;
  min-width: 22px;
  text-align: center;
}
.blank-input {
  width: 140px;
  padding: 4px 10px;
  border: 2px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s;
}
.blank-input:focus { border-color: var(--primary); }
.blank-input.blank-correct {
  border-color: #16a34a;
  background: #f0fdf4;
  color: #15803d;
  font-weight: 600;
}
.blank-input.blank-wrong {
  border-color: #dc2626;
  background: #fef2f2;
  color: #dc2626;
  text-decoration: line-through;
}
.answer-hint {
  font-size: 12px;
  font-weight: 600;
  color: #16a34a;
  margin-left: 4px;
  white-space: nowrap;
}

/* Subtitle Panel */
.subtitle-content {
  padding: 12px;
  max-height: calc(100vh - 160px);
  overflow-y: auto;
}
.subtitle-line {
  display: flex;
  gap: 10px;
  padding: 8px 12px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s;
  margin-bottom: 4px;
  line-height: 1.6;
}
.subtitle-line:hover { background: var(--bg); }
.subtitle-line.sub-active {
  background: var(--primary-light);
  border-left: 3px solid var(--primary);
}
.sub-time {
  font-size: 11px;
  font-weight: 600;
  color: var(--primary);
  min-width: 40px;
  padding-top: 2px;
  flex-shrink: 0;
}
.sub-text {
  font-size: 14px;
  color: var(--text);
}

/* ===== TRANSLATION PAGE ===== */
.trans-layout {
  display: flex;
  margin-top: 60px;
  min-height: calc(100vh - 60px);
}
.trans-body {
  flex: 1;
  padding: 20px;
  min-width: 0;
}
.trans-section {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: 12px;
  margin-bottom: 20px;
  overflow: hidden;
}
.trans-section-header {
  background: linear-gradient(135deg, #fff0f0 0%, #fff8f8 100%);
  padding: 12px 18px;
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--primary);
  border-bottom: 1.5px solid var(--border);
}

/* Câu gốc */
.trans-original {
  padding: 20px;
  font-size: 18px;
  line-height: 2;
  color: var(--text);
  user-select: text;
  cursor: text;
}
.orig-word {
  display: inline;
  border-radius: 3px;
  padding: 1px 0;
  transition: background 0.15s;
}
.orig-done {
  opacity: 0.4;
  text-decoration: line-through;
}
.chip-remaining {
  border-style: dashed !important;
  opacity: 0.5;
  border-color: var(--text-muted) !important;
  background: var(--bg) !important;
}
.remaining-hint {
  font-size: 10px;
  color: var(--text-muted);
  text-align: center;
  font-style: italic;
}
/* Translation inputs */
.trans-input {
  width: 100%;
  padding: 5px 8px;
  border: 1.5px solid var(--border);
  border-radius: 6px;
  font-size: 12px;
  font-family: inherit;
  outline: none;
  text-align: center;
}
.trans-input:focus { border-color: var(--primary); }
.hint-btn {
  padding: 3px 8px;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: transparent;
  font-size: 10px;
  color: var(--text-muted);
  cursor: pointer;
  white-space: nowrap;
}
.hint-btn:hover { background: var(--primary-light); color: var(--primary); border-color: var(--primary); }

.finalize-btn {
  padding: 4px 10px;
  border: 1.5px solid var(--success);
  border-radius: 6px;
  background: #f0fdf4;
  color: var(--success);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}
.finalize-btn:hover { background: var(--success); color: white; }
.word-divider {
  display: inline-block;
  cursor: pointer;
  color: transparent;
  width: 8px;
  text-align: center;
  position: relative;
  vertical-align: middle;
  transition: all 0.15s;
  border-radius: 2px;
  margin: 0 1px;
}
.word-divider:hover {
  color: var(--primary);
  background: var(--primary-light);
  width: 14px;
  font-weight: 700;
}
.word-divider.divider-cut {
  color: var(--primary);
  background: var(--primary);
  width: 3px;
  margin: 0 3px;
  border-radius: 2px;
}

/* Cut popup */
#cut-popup {
  position: fixed;
  z-index: 1000;
  background: var(--text);
  border-radius: 10px;
  padding: 6px;
  display: none;
  flex-direction: column;
  box-shadow: 0 8px 24px rgba(0,0,0,0.25);
}
#cut-popup .popup-action {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 14px; border-radius: 7px; color: white;
  font-size: 14px; font-weight: 600; cursor: pointer;
}
#cut-popup .popup-action:hover { background: rgba(255,255,255,0.12); }

/* Câu xé – inline horizontal */
.trans-cuts-inline {
  padding: 16px 18px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-height: 60px;
  align-items: flex-start;
}
.cuts-placeholder {
  color: var(--text-muted);
  font-size: 13px;
  text-align: center;
  width: 100%;
  padding: 12px;
}

/* Mỗi cụm = 1 cột dọc (chip + dropdowns bên dưới) */
.cut-column {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  min-width: 80px;
}
.cut-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: var(--primary-light);
  border: 1.5px solid var(--primary);
  border-radius: 8px;
  padding: 7px 10px;
  font-size: 14px;
  font-weight: 600;
  color: var(--primary-dark);
  position: relative;
}
.cut-fn-badge {
  font-size: 10px;
  font-weight: 700;
  color: white;
  padding: 1px 5px;
  border-radius: 4px;
  line-height: 1;
}
.cut-remove {
  background: none;
  border: none;
  color: var(--primary);
  font-size: 14px;
  cursor: pointer;
  opacity: 0.5;
  padding: 0 1px;
}
.cut-remove:hover { opacity: 1; }

/* Dropdown inline dưới mỗi cụm */
.func-select-inline {
  width: 100%;
  padding: 4px 6px;
  border: 1.5px solid var(--border);
  border-radius: 6px;
  font-size: 11px;
  font-family: inherit;
  outline: none;
  background: white;
  color: var(--text);
  text-align: center;
}
.func-select-inline:focus { border-color: var(--primary); }
.func-select-inline.sub {
  border-color: #ddd;
  font-size: 10px;
  color: var(--text-muted);
}
.verb-checkbox-inline {
  display: flex;
  align-items: center;
  gap: 3px;
  font-size: 10px;
  color: var(--text-muted);
  cursor: pointer;
  justify-content: center;
}
.verb-checkbox-inline input { cursor: pointer; width: 12px; height: 12px; }
.func-locked {
  font-size: 10px;
  color: var(--text-muted);
  text-align: center;
  padding: 3px 6px;
  background: var(--bg);
  border-radius: 4px;
  font-weight: 600;
}

/* Notification bar (hover, không chắn) */
.notify-bar {
  position: fixed;
  top: 68px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 9998;
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--text);
  color: white;
  padding: 10px 18px;
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.3);
  font-size: 14px;
  max-width: 700px;
  animation: slideDown 0.3s ease;
}
.notify-bar span { line-height: 1.5; }
.notify-close {
  background: rgba(255,255,255,0.15);
  border: none; color: white;
  width: 24px; height: 24px; border-radius: 50%;
  cursor: pointer; font-size: 13px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.notify-close:hover { background: rgba(255,255,255,0.3); }
#notify-actions { display: flex; gap: 6px; flex-shrink: 0; }
#notify-actions button {
  padding: 5px 14px;
  border-radius: 8px;
  border: 1.5px solid rgba(255,255,255,0.3);
  background: transparent;
  color: white;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}
#notify-actions button:hover { background: rgba(255,255,255,0.15); }
#notify-actions button.notify-primary {
  background: var(--primary);
  border-color: var(--primary);
}

/* Theory panel */
.theory-panel {
  width: 320px;
  flex-shrink: 0;
  background: var(--surface);
  border-left: 1.5px solid var(--border);
  overflow-y: auto;
  max-height: calc(100vh - 60px);
}
.theory-header {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  background: var(--surface);
  z-index: 1;
}
.theory-header h3 { font-size: 14px; font-weight: 700; }
.theory-content { padding: 16px; }
.theory-step {
  margin-bottom: 18px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}
.theory-step:last-child { border-bottom: none; }
.theory-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.theory-step p { font-size: 13px; line-height: 1.7; color: var(--text); margin-bottom: 8px; }
.theory-box {
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 12px;
  line-height: 1.6;
  margin-bottom: 6px;
}
.theory-hot { background: #dbeafe; border-left: 3px solid #2563eb; }
.theory-viec { background: #fef3c7; border-left: 3px solid #d97706; }
.theory-dtch { background: #dcfce7; border-left: 3px solid #16a34a; }
.theory-hint { color: var(--text-muted); font-size: 11px; }
.theory-step.theory-flash {
  animation: theoryFlash 2s ease;
  border-radius: 8px;
}
@keyframes theoryFlash {
  0% { background: transparent; }
  10% { background: #fef08a; }
  100% { background: transparent; }
}
.theory-example {
  background: var(--bg);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 13px;
  line-height: 1.8;
}
.ex-dtch { color: #16a34a; margin-bottom: 4px; }
.ex-mdqh { color: #2563eb; }

/* ===== SPEAKING ===== */
.speaking-group { border: 1.5px solid var(--border); border-radius: 12px; margin-bottom: 12px; overflow: hidden; }
.speaking-group-header {
  display: flex; align-items: center; gap: 8px; padding: 14px 18px;
  cursor: pointer; border-left: 4px solid var(--primary); background: var(--bg);
  font-size: 15px; font-weight: 600; transition: background 0.15s;
}
.speaking-group-header:hover { background: var(--primary-light); }
.speaking-group-count { margin-left: auto; font-size: 12px; color: var(--text-muted); font-weight: 400; }
.speaking-group-arrow { font-size: 10px; color: var(--text-muted); transition: transform 0.2s; }
.speaking-group.open .speaking-group-arrow { transform: rotate(180deg); }
.speaking-group-body { display: none; padding: 12px 18px; }
.speaking-group.open .speaking-group-body { display: block; }
.speaking-topics-grid { display: flex; flex-wrap: wrap; gap: 8px; }
.speaking-topic-card {
  padding: 10px 16px; border: 1.5px solid var(--border); border-radius: 8px;
  text-decoration: none; color: var(--text); font-size: 14px; font-weight: 500;
  transition: all 0.15s; display: flex; align-items: center; gap: 8px;
}
.speaking-topic-card:hover { border-color: var(--primary); background: var(--primary-light); }
.topic-qcount { font-size: 11px; color: var(--text-muted); }
.topic-done { border-color: #16a34a; background: #f0fdf4; }
.topic-done-badge {
  font-size: 10px; font-weight: 700; color: white; background: #16a34a;
  padding: 1px 6px; border-radius: 4px; text-transform: uppercase;
}
.speak-reset-btn {
  margin-left: auto; padding: 4px 10px; border: 1px solid var(--border);
  border-radius: 6px; background: transparent; font-size: 12px;
  cursor: pointer; color: var(--text-muted); white-space: nowrap;
}
.speak-reset-btn:hover { background: #fef2f2; color: var(--danger); border-color: var(--danger); }

/* Speaking practice page */
.speaking-body { padding: 20px; margin-top: 60px; max-width: 100%; }
.en-hidden { filter: blur(6px); user-select: none; pointer-events: none; transition: filter 0.3s; }
.en-hidden:hover { filter: blur(3px); }
.speaking-section {
  background: var(--surface); border: 1.5px solid var(--border); border-radius: 12px;
  margin-bottom: 24px; overflow: hidden;
}
.speaking-q-header {
  background: linear-gradient(135deg, #fff0f0, #fff8f8);
  padding: 14px 18px; border-bottom: 1.5px solid var(--border);
  display: flex; align-items: center; gap: 10px;
}
.speaking-q-num { font-size: 12px; font-weight: 700; color: var(--primary); text-transform: uppercase; }
.speaking-q-text { font-size: 15px; font-weight: 600; color: var(--text); }
.speaking-idea-area { padding: 16px 18px; }
.speaking-idea {
  width: 100%; padding: 10px; border: 1.5px solid var(--border); border-radius: 8px;
  font-size: 14px; font-family: inherit; resize: vertical; min-height: 60px; margin-top: 8px; outline: none;
}
.speaking-idea:focus { border-color: var(--primary); }
.speaking-label { font-size: 12px; font-weight: 700; color: var(--text-muted); text-transform: uppercase; margin-bottom: 10px; }
.speaking-answer-vi, .speaking-answer-en { padding: 16px 18px; border-top: 1px solid var(--border); }
.speaking-vi-chunks { display: flex; flex-wrap: wrap; gap: 10px; }
.vi-chunk {
  flex: 1; min-width: 150px; border: 1.5px solid var(--border); border-radius: 10px;
  padding: 10px 12px; background: var(--bg);
}
.vi-text { font-size: 14px; color: var(--text); font-weight: 500; margin-bottom: 6px; }
.en-slot { min-height: 28px; }
.en-filled { font-size: 13px; color: var(--primary); font-weight: 600; display: block; margin-bottom: 4px; }
.en-empty { font-size: 12px; color: var(--text-muted); font-style: italic; }
.speak-btn, .mic-btn {
  padding: 3px 8px; border: 1px solid var(--border); border-radius: 5px;
  background: transparent; font-size: 11px; cursor: pointer; margin-right: 4px; margin-top: 4px;
}
.speak-btn:hover { background: var(--primary-light); color: var(--primary); }
.mic-btn:hover { background: #fef3c7; color: #d97706; }
.mic-result { font-size: 12px; margin-top: 4px; min-height: 18px; }
.speak-btn-full {
  padding: 8px 16px; border: 1.5px solid var(--primary); border-radius: 8px;
  background: transparent; color: var(--primary); font-size: 13px; font-weight: 600;
  cursor: pointer; margin-top: 10px;
}
.speak-btn-full:hover { background: var(--primary-light); }
.speaking-en-sentence {
  font-size: 16px; line-height: 2; padding: 8px 0;
}

/* Responsive */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .main-content { margin-left: 0; padding: 16px; }
  .reading-body { flex-direction: column; }
  .reading-pane { min-height: 50vh; }
  .vocab-panel { width: 100%; border-left: none; border-top: 1px solid var(--border); }
  .blank-input { width: 100px; }
}
