:root {
  --aws-dark: #0f172a;
  --aws-header: #232f3e;
  --aws-orange: #ff9900;
  --aws-orange-hover: #ec8b00;
  --aws-blue: #0073bb;
  --aws-blue-light: #e7f3fe;
  --bg-main: #f8fafc;
  --bg-card: #ffffff;
  --text-primary: #1e293b;
  --text-secondary: #64748b;
  --border-color: #e2e8f0;
  --success-bg: #dcfce7;
  --success-border: #22c55e;
  --success-text: #15803d;
  --error-bg: #fee2e2;
  --error-border: #ef4444;
  --error-text: #b91c1c;
  --warning-bg: #fef3c7;
  --warning-border: #f59e0b;
  --warning-text: #b45309;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

body {
  background-color: var(--bg-main);
  color: var(--text-primary);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Header */
header {
  background-color: var(--aws-header);
  color: white;
  padding: 12px 20px;
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.header-container {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}

.logo-area {
  display: flex;
  align-items: center;
  gap: 10px;
}

.logo-badge {
  background: var(--aws-orange);
  color: var(--aws-header);
  font-weight: 800;
  padding: 4px 8px;
  border-radius: 6px;
  font-size: 14px;
}

.logo-title {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.5px;
}

.logo-sub {
  font-size: 11px;
  color: #94a3b8;
}

.nav-tabs {
  display: flex;
  gap: 6px;
  background: #1e293b;
  padding: 4px;
  border-radius: 8px;
}

.tab-btn {
  background: transparent;
  border: none;
  color: #94a3b8;
  padding: 6px 14px;
  font-size: 13px;
  font-weight: 600;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  gap: 6px;
}

.tab-btn.active {
  background: var(--aws-blue);
  color: white;
}

.tab-btn:hover:not(.active) {
  color: white;
  background: rgba(255, 255, 255, 0.05);
}

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

.lang-selector {
  display: flex;
  background: #1e293b;
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid #334155;
}

.lang-btn {
  background: transparent;
  border: none;
  color: #94a3b8;
  padding: 5px 10px;
  font-size: 12px;
  cursor: pointer;
  font-weight: 600;
  transition: all 0.2s;
}

.lang-btn.active {
  background: var(--aws-orange);
  color: var(--aws-header);
}

.sync-btn {
  background: #334155;
  color: white;
  border: none;
  padding: 5px 12px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
}

.sync-btn:hover {
  background: #475569;
}

/* Main Container */
main {
  flex: 1;
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
  padding: 20px;
}

/* Filter Bar */
.filter-bar {
  background: white;
  padding: 14px 18px;
  border-radius: 12px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
  margin-bottom: 20px;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  border: 1px solid var(--border-color);
}

.filter-select {
  padding: 8px 12px;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  background: #f8fafc;
  color: var(--text-primary);
  font-size: 13px;
  font-weight: 500;
  outline: none;
  cursor: pointer;
}

.filter-select:focus {
  border-color: var(--aws-blue);
}

.search-box {
  flex: 1;
  min-width: 200px;
  position: relative;
}

.search-input {
  width: 100%;
  padding: 8px 12px 8px 32px;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  font-size: 13px;
  background: #f8fafc;
  outline: none;
}

.search-input:focus {
  border-color: var(--aws-blue);
  background: white;
}

.search-icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-secondary);
  font-size: 14px;
}

.stats-pill {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  padding: 6px 12px;
  background: #f1f5f9;
  border-radius: 20px;
}

/* Layout Grid */
.layout-grid {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 20px;
  align-items: start;
}

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

/* Question Card */
.quiz-card {
  background: var(--bg-card);
  border-radius: 14px;
  border: 1px solid var(--border-color);
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
  padding: 24px;
}

.card-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 16px;
  flex-wrap: wrap;
  gap: 10px;
}

.badge-row {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  align-items: center;
}

.q-badge {
  background: var(--aws-header);
  color: white;
  font-size: 12px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 6px;
}

.domain-badge {
  background: var(--aws-blue-light);
  color: var(--aws-blue);
  font-size: 11px;
  font-weight: 600;
  padding: 4px 8px;
  border-radius: 6px;
}

.service-badge {
  background: #f1f5f9;
  color: #475569;
  font-size: 11px;
  font-weight: 600;
  padding: 4px 8px;
  border-radius: 6px;
}

.bookmark-btn {
  background: transparent;
  border: none;
  font-size: 20px;
  cursor: pointer;
  color: #cbd5e1;
  transition: all 0.2s;
}

.bookmark-btn.active {
  color: #f59e0b;
}

/* Prompt */
.question-prompt {
  font-size: 16px;
  font-weight: 600;
  line-height: 1.6;
  margin-bottom: 20px;
}

.prompt-en {
  margin-bottom: 10px;
}

.prompt-vi {
  padding: 10px 14px;
  background: #f8fafc;
  border-left: 3px solid var(--aws-blue);
  border-radius: 0 8px 8px 0;
  font-size: 14px;
  color: #334155;
  font-weight: 400;
}

.multi-notice {
  display: inline-block;
  background: #fef3c7;
  color: #92400e;
  font-size: 12px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 4px;
  margin-bottom: 12px;
}

/* Options */
.options-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 24px;
}

.option-item {
  border: 1.5px solid var(--border-color);
  border-radius: 10px;
  padding: 14px 16px;
  background: #ffffff;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  gap: 12px;
  align-items: flex-start;
}

.option-item:hover {
  border-color: #94a3b8;
  background: #f8fafc;
}

.option-item.selected {
  border-color: var(--aws-blue);
  background: var(--aws-blue-light);
}

.option-item.correct {
  border-color: var(--success-border);
  background: var(--success-bg);
}

.option-item.incorrect {
  border-color: var(--error-border);
  background: var(--error-bg);
}

.option-letter {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #e2e8f0;
  font-weight: 700;
  font-size: 13px;
  color: var(--text-primary);
  flex-shrink: 0;
}

.option-item.selected .option-letter {
  background: var(--aws-blue);
  color: white;
}

.option-item.correct .option-letter {
  background: var(--success-border);
  color: white;
}

.option-item.incorrect .option-letter {
  background: var(--error-border);
  color: white;
}

.option-content {
  flex: 1;
}

.option-text-en {
  font-size: 14px;
  line-height: 1.5;
  font-weight: 500;
}

.option-text-vi {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 4px;
  font-weight: 400;
}

/* Actions */
.card-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  padding-top: 16px;
  border-top: 1px solid var(--border-color);
}

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

.btn {
  padding: 10px 18px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.btn-primary {
  background: var(--aws-orange);
  color: var(--aws-header);
}

.btn-primary:hover {
  background: var(--aws-orange-hover);
}

.btn-secondary {
  background: #e2e8f0;
  color: var(--text-primary);
}

.btn-secondary:hover {
  background: #cbd5e1;
}

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

.btn-outline:hover {
  background: #f1f5f9;
  color: var(--text-primary);
}

/* Feedback & Explanation Box */
.explanation-box {
  margin-top: 20px;
  padding: 18px;
  border-radius: 10px;
  background: #f8fafc;
  border: 1px solid var(--border-color);
}

.status-alert {
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 700;
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.status-alert.correct {
  background: var(--success-bg);
  color: var(--success-text);
  border: 1px solid var(--success-border);
}

.status-alert.incorrect {
  background: var(--error-bg);
  color: var(--error-text);
  border: 1px solid var(--error-border);
}

.dump-warning {
  background: var(--warning-bg);
  color: var(--warning-text);
  border: 1px solid var(--warning-border);
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 14px;
}

.exp-section {
  margin-bottom: 14px;
}

.exp-title {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-secondary);
  letter-spacing: 0.5px;
  margin-bottom: 6px;
}

.exp-body {
  font-size: 14px;
  line-height: 1.6;
  color: var(--text-primary);
}

.exp-body-vi {
  padding: 10px 12px;
  background: #eff6ff;
  border-radius: 8px;
  color: #1e3a8a;
  margin-top: 8px;
  font-size: 13.5px;
}

.distractor-card {
  background: #fffbeb;
  border: 1px solid #fef3c7;
  padding: 10px 14px;
  border-radius: 8px;
  margin-top: 10px;
  font-size: 13px;
}

.docs-link {
  display: inline-block;
  margin-top: 12px;
  color: var(--aws-blue);
  font-weight: 600;
  font-size: 13px;
  text-decoration: none;
}

.docs-link:hover {
  text-decoration: underline;
}

/* Sidebar Navigator */
.sidebar {
  background: var(--bg-card);
  border-radius: 14px;
  border: 1px solid var(--border-color);
  padding: 18px;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
}

.sidebar-title {
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.nav-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
  max-height: 480px;
  overflow-y: auto;
  padding-right: 4px;
}

.nav-grid::-webkit-scrollbar {
  width: 5px;
}

.nav-grid::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 4px;
}

.q-box {
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 700;
  border: 1px solid var(--border-color);
  background: #f8fafc;
  cursor: pointer;
  transition: all 0.15s;
}

.q-box:hover {
  background: #e2e8f0;
}

.q-box.current {
  outline: 2px solid var(--aws-orange);
  outline-offset: 1px;
}

.q-box.correct {
  background: var(--success-bg);
  border-color: var(--success-border);
  color: var(--success-text);
}

.q-box.incorrect {
  background: var(--error-bg);
  border-color: var(--error-border);
  color: var(--error-text);
}

.q-box.bookmarked {
  position: relative;
}

.q-box.bookmarked::after {
  content: "★";
  position: absolute;
  top: 1px;
  right: 2px;
  font-size: 8px;
  color: #f59e0b;
}

/* Exam Mode Container */
.exam-header {
  background: white;
  padding: 16px 20px;
  border-radius: 12px;
  border: 1px solid var(--border-color);
  margin-bottom: 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}

.timer-box {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 20px;
  font-weight: 800;
  color: var(--aws-header);
  background: #f1f5f9;
  padding: 6px 16px;
  border-radius: 8px;
}

.timer-box.warning {
  color: #dc2626;
  background: #fee2e2;
  animation: pulse 1s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}

/* Score Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 20px;
}

.modal-content {
  background: white;
  width: 100%;
  max-width: 550px;
  border-radius: 16px;
  padding: 28px;
  box-shadow: 0 20px 25px -5px rgba(0,0,0,0.2);
  text-align: center;
}

.score-circle {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  margin: 0 auto 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 28px;
}

.score-circle.pass {
  background: var(--success-bg);
  color: var(--success-text);
  border: 4px solid var(--success-border);
}

.score-circle.fail {
  background: var(--error-bg);
  color: var(--error-text);
  border: 4px solid var(--error-border);
}

/* Sync Dialog */
.sync-modal textarea {
  width: 100%;
  height: 150px;
  padding: 10px;
  font-family: monospace;
  font-size: 12px;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  margin: 12px 0;
}


/* ==================== INTERACTIVE GLOSSARY STYLES ==================== */
.glossary-term {
  border-bottom: 1.5px dashed #0284c7;
  cursor: pointer;
  color: #0369a1;
  font-weight: 600;
  transition: all 0.2s ease;
  border-radius: 3px;
  padding: 0 3px;
  display: inline;
}

.glossary-term:hover {
  background-color: #e0f2fe;
  color: #0c4a6e;
}

.glossary-term::after {
  content: " ⓘ";
  font-size: 10px;
  opacity: 0.6;
  font-weight: normal;
}

.glossary-modal-content {
  background: white;
  width: 100%;
  max-width: 600px;
  border-radius: 16px;
  padding: 26px;
  box-shadow: 0 25px 50px -12px rgba(15, 23, 42, 0.3);
  text-align: left;
  max-height: 88vh;
  overflow-y: auto;
  position: relative;
  animation: modalSlideUp 0.25s ease-out;
}

@keyframes modalSlideUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

.glossary-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 12px;
}

.glossary-title {
  font-size: 18px;
  font-weight: 800;
  color: var(--aws-header);
}

.glossary-cat-badge {
  display: inline-block;
  background: #e0f2fe;
  color: #0369a1;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 12px;
  margin-top: 4px;
}

.glossary-section {
  margin-bottom: 16px;
  background: #f8fafc;
  padding: 12px 16px;
  border-radius: 10px;
  border: 1px solid var(--border-color);
}

.glossary-sec-title {
  font-size: 13px;
  font-weight: 700;
  color: #475569;
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.glossary-sec-body {
  font-size: 14px;
  line-height: 1.6;
  color: #1e293b;
}

.glossary-close-btn {
  background: #f1f5f9;
  border: none;
  font-size: 18px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #64748b;
  transition: all 0.2s;
}

.glossary-close-btn:hover {
  background: #e2e8f0;
  color: #0f172a;
}
