/* ==========================================================================
   Uncle Kwaku — Custom Theme & Exam Paper Design System
   Fast, lightweight, mobile-optimized, and print-ready.
   ========================================================================== */

:root {
  /* Color Palette */
  --primary-950: #0a1128;
  --primary-900: #101f42;
  --primary-800: #1b356f;
  --primary-600: #2563eb;
  --primary-500: #3b82f6;
  --primary-100: #e0e7ff;
  --primary-50:  #eef2ff;

  --accent-gold: #f59e0b;
  --accent-gold-dark: #d97706;
  --accent-gold-light: #fef3c7;

  --surface-bg: #f8fafc;
  --surface-card: #ffffff;
  --surface-subtle: #f1f5f9;
  --surface-hover: #e2e8f0;

  --text-main: #0f172a;
  --text-muted: #475569;
  --text-subtle: #94a3b8;
  --text-inverse: #ffffff;

  --border-light: #e2e8f0;
  --border-focus: #3b82f6;

  --success-bg: #ecfdf5;
  --success-border: #10b981;
  --success-text: #065f46;

  --danger-bg: #fef2f2;
  --danger-border: #ef4444;
  --danger-text: #991b1b;

  /* Typography */
  --font-sans: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --font-serif: 'Source Serif 4', 'Charter', Georgia, Cambria, 'Times New Roman', serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;

  /* Elevation */
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.08), 0 2px 4px -2px rgb(0 0 0 / 0.06);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.08), 0 4px 6px -4px rgb(0 0 0 / 0.04);
}

/* Base Reset & Layout */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-sans);
  background-color: var(--surface-bg);
  color: var(--text-main);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* Global Top Navigation */
.app-navbar {
  background: linear-gradient(135deg, var(--primary-950) 0%, var(--primary-900) 100%);
  color: var(--text-inverse);
  padding: 0.75rem 1.5rem;
  border-bottom: 2px solid var(--accent-gold);
  box-shadow: var(--shadow-md);
  position: sticky;
  top: 0;
  z-index: 50;
}

.app-navbar-inner {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand-badge {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  text-decoration: none;
  color: inherit;
}

.brand-avatar {
  width: 2.5rem;
  height: 2.5rem;
  background-color: var(--accent-gold);
  border: 2px solid #ffffff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.35rem;
  box-shadow: var(--shadow-sm);
}

.brand-title {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.brand-tagline {
  font-size: 0.75rem;
  color: var(--primary-100);
  opacity: 0.85;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.nav-link {
  color: var(--primary-100);
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 500;
  padding: 0.4rem 0.75rem;
  border-radius: 0.375rem;
  transition: all 0.15s ease;
}

.nav-link:hover {
  background-color: rgba(255, 255, 255, 0.1);
  color: var(--text-inverse);
}

.nav-link.admin-pill {
  background-color: rgba(245, 158, 11, 0.15);
  border: 1px solid var(--accent-gold);
  color: var(--accent-gold);
}

.nav-link.admin-pill:hover {
  background-color: var(--accent-gold);
  color: var(--primary-950);
}

/* Chat Layout & Container */
.chat-shell {
  max-width: 800px;
  margin: 1.5rem auto;
  height: calc(100vh - 6.5rem);
  display: flex;
  flex-direction: column;
  background-color: var(--surface-card);
  border: 1px solid var(--border-light);
  border-radius: 1rem;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}

.chat-header {
  background: var(--primary-900);
  color: var(--text-inverse);
  padding: 1rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.chat-header-title {
  font-weight: 700;
  font-size: 1.05rem;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.75rem;
  color: #86efac;
}

.status-dot {
  width: 0.5rem;
  height: 0.5rem;
  background-color: #22c55e;
  border-radius: 50%;
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(0.85); }
}

.chat-feed {
  flex: 1;
  overflow-y: auto;
  padding: 1.25rem;
  background-color: var(--surface-bg);
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  scroll-behavior: smooth;
}

/* Chat Bubbles */
.bubble-row {
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
  animation: fadeIn 0.2s ease-out;
}

.bubble-row.user {
  justify-content: flex-end;
}

.bubble-avatar {
  width: 2.25rem;
  height: 2.25rem;
  background-color: var(--accent-gold);
  border: 2px solid #ffffff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  flex-shrink: 0;
  box-shadow: var(--shadow-sm);
}

.bubble-content {
  max-width: 85%;
  padding: 0.85rem 1.15rem;
  border-radius: 1.125rem;
  font-size: 0.935rem;
  line-height: 1.55;
  box-shadow: var(--shadow-sm);
}

.bubble-content.assistant {
  background-color: var(--surface-card);
  border: 1px solid var(--border-light);
  border-top-left-radius: 0.25rem;
  color: var(--text-main);
}

.bubble-content.user {
  background-color: var(--primary-600);
  color: var(--text-inverse);
  border-top-right-radius: 0.25rem;
}

/* Clarification Card & Chips */
.clarification-box {
  background: var(--surface-card);
  border: 1px solid #fed7aa;
  border-left: 4px solid var(--accent-gold);
  padding: 1rem 1.25rem;
  border-radius: 0.75rem;
  max-width: 90%;
  box-shadow: var(--shadow-sm);
}

.clarification-title {
  font-weight: 600;
  margin-bottom: 0.75rem;
  color: var(--text-main);
}

.chip-group {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.chip-btn {
  background: var(--primary-50);
  color: var(--primary-800);
  border: 1.5px solid var(--primary-100);
  padding: 0.4rem 0.85rem;
  border-radius: 2rem;
  font-size: 0.825rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.chip-btn:hover {
  background: var(--primary-600);
  color: var(--text-inverse);
  border-color: var(--primary-600);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

/* Academic Exam Question Card */
.exam-card {
  background-color: var(--surface-card);
  border: 1px solid var(--border-light);
  border-radius: 0.875rem;
  padding: 1.25rem;
  margin-bottom: 1rem;
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.2s ease, border-color 0.2s ease;
  position: relative;
}

.exam-card:hover {
  box-shadow: var(--shadow-md);
  border-color: #cbd5e1;
}

.exam-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.75rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px dashed var(--border-light);
}

.exam-badge-group {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.exam-badge {
  font-size: 0.725rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding: 0.25rem 0.55rem;
  border-radius: 0.375rem;
}

.exam-badge.course {
  background-color: var(--primary-50);
  color: var(--primary-800);
  border: 1px solid var(--primary-100);
}

.exam-badge.meta {
  background-color: var(--surface-subtle);
  color: var(--text-muted);
}

.marks-badge {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
}

.scenario-context {
  background-color: #fdf4ff;
  border-left: 3px solid #d946ef;
  padding: 0.75rem 1rem;
  border-radius: 0.375rem;
  margin-bottom: 0.85rem;
  font-size: 0.875rem;
  color: #4a044e;
  font-style: italic;
}

.question-content {
  font-family: var(--font-serif);
  font-size: 1.05rem;
  line-height: 1.65;
  color: #1e293b;
  margin-bottom: 1rem;
  white-space: pre-line;
}

.figure-frame {
  margin: 1rem 0;
  background: #faf5ff;
  border: 1.5px solid #e9d5ff;
  border-radius: 0.625rem;
  padding: 0.75rem;
  text-align: center;
}

.figure-img {
  max-height: 18rem;
  max-width: 100%;
  object-fit: contain;
  border-radius: 0.375rem;
  border: 1px solid #d8b4fe;
  background: #ffffff;
  display: block;
  margin: 0 auto;
  transition: transform 0.15s ease;
}

.figure-img:hover {
  transform: scale(1.01);
}

/* Interactive MCQ Choice List */
.mcq-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 1.25rem;
}

.mcq-choice {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  border-radius: 0.5rem;
  border: 1.5px solid var(--border-light);
  background-color: #ffffff;
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
}

.mcq-choice:hover {
  background-color: var(--surface-subtle);
  border-color: #94a3b8;
}

.mcq-letter {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 1.65rem;
  height: 1.65rem;
  border-radius: 0.375rem;
  background-color: var(--surface-subtle);
  font-family: var(--font-mono);
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-muted);
  flex-shrink: 0;
}

.mcq-text {
  font-size: 0.925rem;
  color: var(--text-main);
  line-height: 1.45;
  flex: 1;
}

/* Selected & Evaluated MCQ states */
.mcq-choice.is-correct {
  background-color: var(--success-bg) !important;
  border-color: var(--success-border) !important;
  color: var(--success-text) !important;
}

.mcq-choice.is-correct .mcq-letter {
  background-color: var(--success-border);
  color: #ffffff;
}

.mcq-choice.is-incorrect {
  background-color: var(--danger-bg) !important;
  border-color: var(--danger-border) !important;
  color: var(--danger-text) !important;
}

.mcq-choice.is-incorrect .mcq-letter {
  background-color: var(--danger-border);
  color: #ffffff;
}

/* Solution / Action Footer */
.exam-card-footer {
  border-top: 1px solid var(--border-light);
  padding-top: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.action-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.btn-reveal {
  background: none;
  border: none;
  color: var(--primary-600);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.35rem 0.5rem;
  border-radius: 0.375rem;
}

.btn-reveal:hover {
  background-color: var(--primary-50);
}

.btn-solve {
  background-color: #faf5ff;
  border: 1.5px solid #e9d5ff;
  color: #7e22ce;
  font-size: 0.85rem;
  font-weight: 700;
  padding: 0.45rem 0.85rem;
  border-radius: 0.5rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  transition: all 0.15s ease;
}

.btn-solve:hover {
  background-color: #f3e8ff;
  border-color: #c084fc;
}

.solution-box {
  background-color: #faf5ff;
  border: 1px solid #e9d5ff;
  border-radius: 0.625rem;
  padding: 1rem;
  font-size: 0.925rem;
  line-height: 1.6;
  color: #3b0764;
  animation: fadeIn 0.2s ease-out;
}

.marking-scheme-box {
  background-color: var(--success-bg);
  border: 1px solid #a7f3d0;
  border-radius: 0.625rem;
  padding: 0.85rem 1rem;
  font-size: 0.9rem;
  color: var(--success-text);
  animation: fadeIn 0.2s ease-out;
}

/* Chat Input Bar */
.chat-input-bar {
  padding: 0.85rem 1.25rem;
  background-color: var(--surface-card);
  border-top: 1px solid var(--border-light);
}

.chat-input-form {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.chat-input {
  flex: 1;
  padding: 0.75rem 1.15rem;
  background-color: var(--surface-subtle);
  border: 1.5px solid transparent;
  border-radius: 2rem;
  font-size: 0.935rem;
  color: var(--text-main);
  outline: none;
  transition: all 0.15s ease;
}

.chat-input:focus {
  background-color: #ffffff;
  border-color: var(--primary-500);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.chat-submit-btn {
  width: 2.75rem;
  height: 2.75rem;
  border-radius: 50%;
  background: var(--primary-900);
  color: var(--text-inverse);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  transition: all 0.15s ease;
  flex-shrink: 0;
  box-shadow: var(--shadow-sm);
}

.chat-submit-btn:hover {
  background: var(--primary-600);
  transform: scale(1.05);
}

.chat-disclaimer {
  text-align: center;
  font-size: 0.725rem;
  color: var(--text-subtle);
  margin-top: 0.4rem;
}

/* Animations & HTMX State Helpers */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}

.fade-in {
  animation: fadeIn 0.2s ease-out;
}

.htmx-indicator {
  display: none;
}
.htmx-request .htmx-indicator {
  display: inline-block;
}
.htmx-request.htmx-indicator {
  display: inline-block;
}

/* Print Optimization (for studying / saving paper PDFs) */
@media print {
  .app-navbar, .chat-input-bar, .btn-solve, .btn-reveal, .brand-avatar, .status-pill {
    display: none !important;
  }
  body, .chat-shell, .chat-feed {
    background: #ffffff !important;
    border: none !important;
    box-shadow: none !important;
    height: auto !important;
    overflow: visible !important;
    max-width: 100% !important;
    padding: 0 !important;
    margin: 0 !important;
  }
  .exam-card {
    page-break-inside: avoid;
    break-inside: avoid;
    border: 1px solid #94a3b8 !important;
    margin-bottom: 2rem !important;
  }
  .question-content {
    font-size: 11pt !important;
  }
}


/* ==========================================================================
   Admin Workspace Styles (Clean, Structured, Desktop & Mobile Optimized)
   ========================================================================== */

.admin-container {
  max-width: 1200px;
  margin: 1.5rem auto;
  padding: 0 1rem;
}

.admin-page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
}

.admin-page-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--primary-950);
}

.admin-card {
  background: var(--surface-card);
  border: 1px solid var(--border-light);
  border-radius: 0.75rem;
  padding: 1.5rem;
  box-shadow: var(--shadow-sm);
  margin-bottom: 1.5rem;
}

.admin-card-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--primary-900);
  margin-bottom: 1rem;
}

/* Form controls */
.form-row {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: flex-end;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.form-label {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 0.025em;
}

.form-input, .form-select, .form-textarea {
  padding: 0.5rem 0.75rem;
  border: 1.5px solid var(--border-light);
  border-radius: 0.375rem;
  font-size: 0.875rem;
  font-family: inherit;
  color: var(--text-main);
  background: #ffffff;
  outline: none;
  transition: border-color 0.15s ease;
}

.form-input:focus, .form-select:focus, .form-textarea:focus {
  border-color: var(--primary-500);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.12);
}

.btn-primary {
  background: var(--primary-900);
  color: var(--text-inverse);
  padding: 0.55rem 1.15rem;
  border-radius: 0.375rem;
  font-weight: 600;
  font-size: 0.875rem;
  border: none;
  cursor: pointer;
  transition: all 0.15s ease;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.btn-primary:hover {
  background: var(--primary-600);
  transform: translateY(-1px);
}

.btn-secondary {
  background: var(--surface-subtle);
  color: var(--text-main);
  padding: 0.55rem 1rem;
  border-radius: 0.375rem;
  font-weight: 600;
  font-size: 0.875rem;
  border: 1px solid var(--border-light);
  cursor: pointer;
}

.btn-secondary:hover {
  background: var(--surface-hover);
}

/* Exam Cards Grid */
.exam-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 1.25rem;
}

.exam-item-card {
  background: var(--surface-card);
  border: 1.5px solid var(--border-light);
  border-radius: 0.75rem;
  padding: 1.25rem;
  text-decoration: none;
  color: inherit;
  display: block;
  box-shadow: var(--shadow-sm);
  transition: all 0.15s ease;
}

.exam-item-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--primary-500);
}

.exam-item-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
}

.exam-item-code {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--primary-950);
}

.status-badge {
  font-size: 0.725rem;
  font-weight: 700;
  padding: 0.25rem 0.6rem;
  border-radius: 1rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.status-badge.published {
  background: #dcfce7;
  color: #166534;
  border: 1px solid #86efac;
}

.status-badge.draft {
  background: #fef9c3;
  color: #854d0e;
  border: 1px solid #fde047;
}

/* Editor Layout (Two columns) */
.editor-layout {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 1.5rem;
}

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

.sticky-panel {
  position: sticky;
  top: 5rem;
}


/* ==========================================================================
   Admin Question Card & Form Styling
   ========================================================================== */

.admin-q-card {
  background: var(--surface-card);
  border: 1.5px solid var(--border-light);
  border-radius: 0.75rem;
  padding: 1.25rem;
  margin-bottom: 1.25rem;
  box-shadow: var(--shadow-sm);
  transition: all 0.15s ease;
}

.admin-q-card:hover {
  border-color: #cbd5e1;
  box-shadow: var(--shadow-md);
}

.admin-q-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px dashed var(--border-light);
}

.admin-q-meta {
  font-size: 0.8rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.admin-q-meta a {
  color: var(--primary-600);
  text-decoration: underline;
}

.admin-q-content {
  font-family: var(--font-serif);
  font-size: 1.025rem;
  line-height: 1.6;
  color: #1e293b;
  margin-bottom: 0.85rem;
  white-space: pre-line;
}

.admin-q-options {
  list-style: none;
  margin-bottom: 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.admin-q-option-item {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  font-size: 0.9rem;
  color: var(--text-main);
}

.admin-q-option-letter {
  font-weight: 700;
  color: var(--text-subtle);
  font-family: var(--font-mono);
  width: 1.25rem;
}

.admin-warning-box {
  background: #fffbeb;
  border: 1px solid #fde68a;
  color: #92400e;
  padding: 0.5rem 0.75rem;
  border-radius: 0.375rem;
  font-size: 0.8rem;
  margin-bottom: 0.75rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.admin-q-answer {
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  color: #166534;
  padding: 0.5rem 0.75rem;
  border-radius: 0.375rem;
  font-size: 0.85rem;
  margin-bottom: 0.75rem;
}

.admin-subquestions-tree {
  margin-left: 1.5rem;
  margin-top: 1rem;
  padding-left: 1rem;
  border-left: 2px solid #e9d5ff;
}

.admin-subquestions-title {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  color: #7e22ce;
  letter-spacing: 0.05em;
  margin-bottom: 0.75rem;
}

.admin-card-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-top: 1rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border-light);
}

.btn-link {
  background: none;
  border: none;
  font-size: 0.825rem;
  font-weight: 600;
  cursor: pointer;
  padding: 0.25rem 0.5rem;
  border-radius: 0.25rem;
  text-decoration: underline;
}

.btn-link.edit {
  color: var(--primary-600);
}

.btn-link.delete {
  color: #dc2626;
}

.btn-link:hover {
  background: var(--surface-subtle);
}

/* Edit Form In-Place */
.admin-edit-form {
  background: #eff6ff;
  border: 2px solid #bfdbfe;
  border-radius: 0.75rem;
  padding: 1.25rem;
  margin-bottom: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

/* Upload Dropzone */
.upload-dropzone {
  display: block;
  border: 2px dashed #cbd5e1;
  border-radius: 0.75rem;
  padding: 2.5rem 1.5rem;
  text-align: center;
  cursor: pointer;
  background: #ffffff;
  transition: all 0.15s ease;
}

.upload-dropzone:hover {
  border-color: var(--primary-500);
  background: #f8fafc;
}

.upload-icon {
  font-size: 2.5rem;
  margin-bottom: 0.5rem;
  display: block;
}

.upload-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-main);
  display: block;
}

.upload-subtitle {
  font-size: 0.825rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
  display: block;
}

/* --- PAGINATION STYLES --- */
.pagination-container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
  margin-top: 2rem;
  padding: 1.25rem 0.5rem;
  border-top: 1px solid var(--border-light);
}

.pagination-info {
  font-size: 0.875rem;
  color: var(--text-muted);
}

.pagination-controls {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.pagination-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2.25rem;
  height: 2.25rem;
  padding: 0 0.65rem;
  border-radius: 0.5rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-main);
  background: #ffffff;
  border: 1px solid var(--border-light);
  text-decoration: none;
  transition: all 0.15s ease;
}

.pagination-btn:hover:not(.disabled):not(.active) {
  background: var(--surface-subtle);
  border-color: var(--border-medium);
  color: var(--navy);
}

.pagination-btn.active {
  background: var(--navy);
  color: #ffffff;
  border-color: var(--navy);
}

.pagination-btn.disabled {
  opacity: 0.45;
  cursor: not-allowed;
  pointer-events: none;
}

.pagination-ellipsis {
  padding: 0 0.25rem;
  color: var(--text-subtle);
  font-size: 0.85rem;
}

.page-size-selector {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.825rem;
  color: var(--text-muted);
}

.page-size-link {
  text-decoration: none;
  padding: 0.2rem 0.45rem;
  border-radius: 0.35rem;
  font-weight: 600;
  border: 1px solid var(--border-light);
  background: #ffffff;
  color: var(--text-muted);
  font-size: 0.8rem;
}

.page-size-link.active {
  background: var(--navy);
  color: #ffffff;
  border-color: var(--navy);
}

/* ==========================================================================
   Toast Notification System (Accessible & Responsive)
   ========================================================================== */
.toast-container {
  position: fixed;
  top: 1.25rem;
  right: 1.25rem;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  pointer-events: none;
  max-width: calc(100vw - 2.5rem);
}

.toast {
  pointer-events: auto;
  min-width: 280px;
  max-width: 420px;
  padding: 0.75rem 1rem;
  border-radius: 0.5rem;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.875rem;
  line-height: 1.4;
  transition: opacity 0.25s ease, transform 0.25s ease;
  animation: slideInDown 0.25s ease-out;
}

.toast.fade-out {
  opacity: 0;
  transform: translateY(-8px);
}

.toast-error {
  background: #fef2f2;
  color: #991b1b;
  border: 1.5px solid #fecaca;
}

.toast-warning {
  background: #fffbeb;
  color: #92400e;
  border: 1.5px solid #fde68a;
}

.toast-success {
  background: #f0fdf4;
  color: #166534;
  border: 1.5px solid #bbf7d0;
}

.toast-info {
  background: #eff6ff;
  color: #1e40af;
  border: 1.5px solid #bfdbfe;
}

.toast-icon {
  font-size: 1.15rem;
  flex-shrink: 0;
}

.toast-message {
  flex: 1;
}

.toast-close {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1.2rem;
  line-height: 1;
  color: currentColor;
  opacity: 0.6;
  padding: 0.2rem;
  margin-left: 0.35rem;
  transition: opacity 0.15s ease;
}

.toast-close:hover {
  opacity: 1;
}

@keyframes slideInDown {
  from {
    opacity: 0;
    transform: translateY(-12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ==========================================================================
   Chat Typing Indicator
   ========================================================================== */
.typing-indicator-bubble {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background-color: var(--surface-card);
  border: 1px solid var(--border-light);
  border-top-left-radius: 0.25rem;
  padding: 0.65rem 1rem;
  color: var(--text-muted);
  font-size: 0.85rem;
}

.typing-dots {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  height: 0.85rem;
}

.typing-dots span {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background-color: var(--accent-gold-dark);
  animation: typingBounce 1.4s infinite ease-in-out both;
}

.typing-dots span:nth-child(1) {
  animation-delay: -0.32s;
}

.typing-dots span:nth-child(2) {
  animation-delay: -0.16s;
}

.typing-dots span:nth-child(3) {
  animation-delay: 0s;
}

@keyframes typingBounce {
  0%, 80%, 100% {
    transform: scale(0.4);
    opacity: 0.4;
  }
  40% {
    transform: scale(1.1);
    opacity: 1;
  }
}

/* ==========================================================================
   Error Bubbles & Retry Actions
   ========================================================================== */
.error-bubble {
  background: #fff7ed !important;
  border: 1.5px solid #fed7aa !important;
  color: #9a3412 !important;
}

.btn-retry-prompt {
  margin-top: 0.5rem;
  padding: 0.35rem 0.75rem;
  font-size: 0.8rem;
  background: #ea580c;
  color: #ffffff;
  border: none;
  border-radius: 0.375rem;
  cursor: pointer;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  transition: background 0.15s ease;
}

.btn-retry-prompt:hover {
  background: #c2410c;
}

.solution-error-box {
  margin-top: 0.75rem;
  padding: 0.75rem 1rem;
  border-radius: 0.5rem;
  background: #fffbeb;
  border: 1px solid #fde68a;
  color: #92400e;
}

.btn-retry {
  padding: 0.3rem 0.65rem;
  font-size: 0.75rem;
  background: #d97706;
  color: #ffffff;
  border: none;
  border-radius: 0.25rem;
  cursor: pointer;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  transition: background 0.15s ease;
}

.btn-retry:hover {
  background: #b45309;
}

/* ==========================================================================
   Voice Note Recording Button & Pulse
   ========================================================================== */
.chat-voice-btn {
  width: 2.75rem;
  height: 2.75rem;
  border-radius: 50%;
  background: #f8fafc;
  color: var(--navy);
  border: 1.5px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.15rem;
  cursor: pointer;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.chat-voice-btn:hover {
  background: #eff6ff;
  border-color: #3b82f6;
  transform: scale(1.05);
}

.chat-voice-btn.recording {
  background: #ef4444;
  color: #ffffff;
  border-color: #dc2626;
  animation: pulseRecording 1.2s infinite ease-in-out;
}

@keyframes pulseRecording {
  0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.5); }
  50% { transform: scale(1.08); box-shadow: 0 0 0 8px rgba(239, 68, 68, 0); }
  100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
}

/* ==========================================================================
   Mobile Responsive Navigation & Responsive Breakpoints
   ========================================================================== */
.nav-toggle {
  display: none;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #ffffff;
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 0.5rem;
  font-size: 1.35rem;
  line-height: 1;
  cursor: pointer;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
  user-select: none;
}

.nav-toggle:hover {
  background: rgba(255, 255, 255, 0.2);
}

@keyframes navSlideDown {
  from {
    opacity: 0;
    transform: translateY(-8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Tablet & Mobile Breakpoint (<= 880px) */
@media (max-width: 880px) {
  .app-navbar-inner {
    flex-wrap: wrap;
    position: relative;
  }

  .nav-toggle {
    display: flex;
  }

  .nav-links {
    display: none;
    width: 100%;
    flex-direction: column;
    align-items: stretch;
    gap: 0.35rem;
    margin-top: 0.75rem;
    padding-top: 0.85rem;
    border-top: 1px solid rgba(255, 255, 255, 0.12);
  }

  .nav-links.is-open {
    display: flex !important;
    animation: navSlideDown 0.2s ease-out;
  }

  .nav-link {
    min-height: 44px; /* Accessible touch target */
    display: flex;
    align-items: center;
    padding: 0.65rem 1rem;
    font-size: 0.95rem;
    border-radius: 0.5rem;
    background: rgba(255, 255, 255, 0.04);
  }

  .nav-link:hover {
    background: rgba(255, 255, 255, 0.12);
  }

  /* Chat Shell on Mobile */
  .chat-shell {
    margin: 0;
    border-radius: 0;
    border-left: none;
    border-right: none;
    border-top: none;
    height: calc(100dvh - 4.5rem);
  }

  .chat-input {
    font-size: 16px; /* Prevents iOS auto-zoom on input focus */
  }

  .bubble-content {
    max-width: 92%;
    padding: 0.75rem 0.95rem;
  }

  /* Exam Card mobile adjustments */
  .exam-card {
    padding: 1rem;
  }

  .question-content {
    font-size: 0.98rem;
  }

  .admin-page-header {
    flex-direction: column;
    align-items: stretch;
    gap: 1rem;
  }
}

/* Small Screen Breakpoint (<= 640px) */
@media (max-width: 640px) {
  .rating-buttons-grid {
    grid-template-columns: repeat(2, 1fr) !important;
  }

  .exam-hall-header {
    flex-wrap: wrap;
    gap: 0.75rem;
    padding: 0.75rem 1rem !important;
  }

  .exam-hall-layout {
    grid-template-columns: 1fr !important;
    margin: 1rem auto !important;
    padding: 0 0.75rem !important;
  }

  .exam-hall-sidebar {
    order: -1;
    position: static !important;
    margin-bottom: 1.5rem;
  }

  .flashcard-inner-card {
    padding: 1.25rem !important;
  }
}

/* Compact Phone Breakpoint (<= 480px) */
@media (max-width: 480px) {
  .app-navbar {
    padding: 0.6rem 1rem;
  }

  .brand-title {
    font-size: 1.05rem;
  }

  .brand-tagline {
    display: none; /* Hide tagline on compact mobile for clean header */
  }

  .brand-avatar {
    width: 2.25rem;
    height: 2.25rem;
    font-size: 1.15rem;
  }

  .chat-header {
    padding: 0.75rem 1rem;
  }

  .chat-input-bar {
    padding: 0.65rem 0.85rem;
  }

  .chat-submit-btn, .chat-voice-btn {
    width: 2.5rem;
    height: 2.5rem;
  }
}


