/* Practice Mode shell overrides kept separate from the quiz engine. */

/* The global sidebar now provides Home, Tutorial and theme controls.
   Hide the legacy copies only during Practice Mode; Exam Mode keeps its
   existing controls until the dedicated Exam integration is completed. */
body.practice-session .top-right-controls {
  display: none;
}

body.practice-session .top-controls > button {
  display: none !important;
}

body.practice-session .top-controls {
  display: block;
}

body.practice-session .top-controls .controls {
  width: 100%;
}

body.practice-session #subjectFilter {
  width: 100%;
}

.review-mistakes-launcher {
  margin-top: 24px;
  padding: 16px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  border: 1px solid #bbf7d0;
  border-radius: 16px;
  background: linear-gradient(135deg, #f0fdf4, #f8fffa);
}

.review-mistakes-launcher-copy {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.review-mistakes-launcher-icon {
  width: 38px;
  height: 38px;
  flex: 0 0 38px;
  display: grid;
  place-items: center;
  border-radius: 11px;
  background: #dcfce7;
  color: #15803d;
  font-size: 1.35rem;
  font-weight: 800;
}

.review-mistakes-launcher-copy strong,
.review-mistakes-launcher-copy span {
  display: block;
}

.review-mistakes-launcher-copy strong {
  margin-bottom: 3px;
  color: #14532d;
  font-size: .95rem;
}

.review-mistakes-launcher-copy span {
  color: #4b5563;
  font-size: .79rem;
  line-height: 1.45;
}

#review-btn,
#backToPracticeBtn {
  border: 0;
  border-radius: 11px;
  font-family: inherit;
  font-weight: 800;
  cursor: pointer;
  transition: transform .18s ease, box-shadow .18s ease, background .18s ease;
}

#review-btn {
  flex: 0 0 auto;
  padding: 11px 15px;
  background: #16a34a;
  color: #fff;
  box-shadow: 0 7px 18px rgba(22, 163, 74, .18);
}

#review-btn:hover {
  background: #15803d;
  transform: translateY(-1px);
  box-shadow: 0 9px 22px rgba(22, 163, 74, .23);
}

.review-mistakes-banner {
  margin: 0 0 22px;
  padding: 17px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  border: 1px solid #bbf7d0;
  border-radius: 15px;
  background: #f0fdf4;
}

.review-mistakes-banner[hidden] {
  display: none !important;
}

.review-mistakes-eyebrow {
  display: block;
  margin-bottom: 4px;
  color: #16a34a;
  font-size: .65rem;
  font-weight: 800;
  letter-spacing: .09em;
}

.review-mistakes-banner strong {
  display: block;
  color: #14532d;
  font-size: 1rem;
}

.review-mistakes-banner p {
  margin: 4px 0 0;
  color: #4b5563;
  font-size: .78rem;
  line-height: 1.45;
}

#backToPracticeBtn {
  flex: 0 0 auto;
  padding: 10px 13px;
  border: 1px solid #86efac;
  background: #fff;
  color: #166534;
}

#backToPracticeBtn:hover {
  background: #dcfce7;
  transform: translateY(-1px);
}

body.review-mistakes-active .top-controls {
  opacity: .58;
  pointer-events: none;
}

body.dark-mode .review-mistakes-launcher,
body.dark-mode .review-mistakes-banner {
  background: #17311f;
  border-color: #245c35;
}

body.dark-mode .review-mistakes-launcher-icon {
  background: #20472c;
  color: #86efac;
}

body.dark-mode .review-mistakes-launcher-copy strong,
body.dark-mode .review-mistakes-banner strong {
  color: #bbf7d0;
}

body.dark-mode .review-mistakes-launcher-copy span,
body.dark-mode .review-mistakes-banner p {
  color: #c4cbd3;
}

body.dark-mode #backToPracticeBtn {
  background: #1d2720;
  border-color: #347449;
  color: #bbf7d0;
}

body.dark-mode #backToPracticeBtn:hover {
  background: #24402d;
}

body.dark-mode .ai-explanation-box {
  background: #1b1f23;
  border-color: #343a40;
  color: #f3f4f6;
}

body.dark-mode .ai-explanation-header,
body.dark-mode .ai-section h4 {
  color: #f3f4f6;
}

body.dark-mode .ai-section p {
  color: #d1d5db;
}

body.dark-mode .ai-key-concept {
  background: #2a2412;
  border-color: #6b5a1f;
}

body.dark-mode .ai-key-concept h4 {
  color: #fbbf24;
}

body.dark-mode .ai-key-concept p {
  color: #fde68a;
}

body.dark-mode .ai-close-btn {
  background: #30343a;
  color: #f3f4f6;
}

body.dark-mode .ai-close-btn:hover {
  background: #3a4047;
}

body.dark-mode #feedback,
body.dark-mode #score,
body.dark-mode #stats,
body.dark-mode #error-count {
  color: #e5e7eb;
}

@media (max-width: 700px) {
  .review-mistakes-launcher,
  .review-mistakes-banner {
    align-items: stretch;
    flex-direction: column;
  }

  #review-btn,
  #backToPracticeBtn {
    width: 100%;
  }
}

body.dark-mode .ai-explanation-box.ai-loading {
  background: linear-gradient(135deg, #1e1b4b, #312e81, #172554);
  border-color: #4f46e5;
  color: #ffffff;
}

/* Practice Setup & Completion UI */
.practice-setup-ui, .practice-completion-ui {
  background: #ffffff;
  border-radius: 18px;
  padding: 40px;
  text-align: center;
  box-shadow: 0 10px 28px rgba(0,0,0,0.04);
  max-width: 600px;
  margin: 40px auto;
}

body.dark-mode .practice-setup-ui,
body.dark-mode .practice-completion-ui {
  background: #171a1d;
  box-shadow: 0 10px 28px rgba(0,0,0,0.2);
}

.setup-controls {
  margin: 30px 0;
  display: flex;
  flex-direction: column;
  gap: 20px;
  align-items: center;
}

.setup-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
  text-align: left;
  width: 100%;
  max-width: 300px;
}

.setup-group label {
  font-weight: 700;
  color: #475569;
  font-size: 0.9rem;
}
body.dark-mode .setup-group label { color: #cbd5e1; }

.setup-group select {
  padding: 12px;
  border-radius: 8px;
  border: 1px solid #cbd5e1;
  font-family: inherit;
  font-size: 1rem;
}
body.dark-mode .setup-group select { background: #2a2e33; border-color: #3f464e; color: #f3f4f6; }

.length-options {
  display: flex;
  gap: 15px;
  justify-content: space-between;
}
.length-options label {
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  color: #111827;
}
body.dark-mode .length-options label { color: #f3f4f6; }

.start-practice-btn {
  width: 100%;
  max-width: 300px;
  margin-top: 10px;
  padding: 14px;
  font-size: 1.1rem;
}

.illustration-placeholder {
  height: 160px;
  background: #f1f5f9;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #94a3b8;
  font-weight: 700;
  font-size: 1.2rem;
  margin-top: 30px;
}
body.dark-mode .illustration-placeholder { background: #1c2126; color: #475569; }

.completion-actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: center;
  margin-top: 30px;
}

.completion-actions button {
  width: 100%;
  max-width: 280px;
  padding: 12px;
  border-radius: 12px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  border: none;
}
.secondary-actions {
  background: #e2e8f0;
  color: #1e293b;
}
.secondary-actions:hover { background: #cbd5e1; }
body.dark-mode .secondary-actions { background: #334155; color: #f1f5f9; }
body.dark-mode .secondary-actions:hover { background: #475569; }

.tertiary-actions {
  background: transparent;
  color: #64748b;
}
.tertiary-actions:hover { color: #0f172a; text-decoration: underline; }
body.dark-mode .tertiary-actions { color: #94a3b8; }
body.dark-mode .tertiary-actions:hover { color: #f8fafc; }

/* --- Custom Dropdown --- */
.custom-select {
  position: relative;
  width: 100%;
  border-radius: 8px;
  background: #ffffff;
  border: 1px solid #cbd5e1;
  font-family: inherit;
  font-size: 1rem;
  color: #111827;
  cursor: pointer;
  user-select: none;
  outline: none;
}
.custom-select:focus-visible {
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37,99,235,0.2);
}
body.dark-mode .custom-select {
  background: #1e2329;
  border-color: #3f464e;
  color: #f3f4f6;
}

.custom-select-trigger {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 14px;
}
.custom-select-trigger svg {
  transition: transform 0.2s ease;
  color: #64748b;
}
.custom-select.open .custom-select-trigger svg {
  transform: rotate(180deg);
}

.custom-select-options {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
  max-height: 250px;
  overflow-y: auto;
  z-index: 10;
  display: none;
}
.custom-select.open .custom-select-options {
  display: block;
}
body.dark-mode .custom-select-options {
  background: #1e2329;
  border-color: #3f464e;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

.custom-option {
  padding: 10px 14px;
  color: #334155;
  transition: background 0.15s ease, color 0.15s ease;
}
.custom-option:hover {
  background: #eff6ff;
  color: #1e40af;
}
.custom-option.selected {
  background: #2563eb;
  color: #ffffff;
  font-weight: 600;
}
body.dark-mode .custom-option {
  color: #cbd5e1;
}
body.dark-mode .custom-option:hover {
  background: #172554;
  color: #bfdbfe;
}
body.dark-mode .custom-option.selected {
  background: #3b82f6;
  color: #ffffff;
}

/* --- Segmented Control --- */
.segmented-control {
  display: flex;
  background: #f1f5f9;
  border-radius: 8px;
  padding: 4px;
  gap: 4px;
}
body.dark-mode .segmented-control {
  background: #131619;
}

.segmented-control input[type="radio"] {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
  margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
}
.segmented-control label {
  flex: 1;
  text-align: center;
  padding: 10px 4px;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.95rem;
  color: #64748b;
  transition: background 0.2s, color 0.2s, box-shadow 0.2s;
  user-select: none;
}
.segmented-control label:hover {
  color: #1e293b;
}
body.dark-mode .segmented-control label {
  color: #94a3b8;
}
body.dark-mode .segmented-control label:hover {
  color: #e2e8f0;
}

.segmented-control input[type="radio"]:checked + label {
  background: #ffffff;
  color: #2563eb;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}
body.dark-mode .segmented-control input[type="radio"]:checked + label {
  background: #2a2e33;
  color: #60a5fa;
  box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}

.segmented-control input[type="radio"]:focus-visible + label {
  outline: 2px solid #2563eb;
  outline-offset: -2px;
}

/* Setup Header */
.setup-header {
  margin-bottom: 32px;
}

.setup-eyebrow {
  display: block;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  color: #2563eb;
  letter-spacing: 0.05em;
  margin-bottom: 8px;
}
body.dark-mode .setup-eyebrow {
  color: #60a5fa;
}

.setup-title {
  font-size: 2rem;
  font-weight: 700;
  color: #0f172a;
  margin: 0 0 12px 0;
  line-height: 1.2;
}
body.dark-mode .setup-title {
  color: #f8fafc;
}

.setup-subtitle {
  font-size: 1rem;
  color: #64748b;
  margin: 0;
  line-height: 1.5;
}
body.dark-mode .setup-subtitle {
  color: #94a3b8;
}

/* Setup Illustration */
.setup-illustration {
  margin-top: 40px;
  display: flex;
  justify-content: center;
}

.setup-illustration img {
  width: 100%;
  max-width: 400px; /* sensible desktop max-width */
  height: auto;
  display: block;
}

/* --- Support Modal --- */
.support-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.support-modal-overlay[hidden] {
  display: none;
}
.support-modal-card {
  background: #ffffff;
  border-radius: 16px;
  padding: 32px;
  max-width: 400px;
  width: 100%;
  text-align: center;
  box-shadow: 0 10px 25px rgba(0,0,0,0.1);
}
body.dark-mode .support-modal-card {
  background: #1e2329;
  box-shadow: 0 10px 25px rgba(0,0,0,0.3);
}
.support-modal-card h3 {
  margin: 0 0 16px 0;
  font-size: 1.25rem;
  font-weight: 700;
  color: #0f172a;
}
body.dark-mode .support-modal-card h3 {
  color: #f8fafc;
}
.support-modal-card p {
  margin: 0 0 24px 0;
  font-size: 1rem;
  color: #475569;
  line-height: 1.5;
}
body.dark-mode .support-modal-card p {
  color: #94a3b8;
}
.support-modal-actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 24px;
}
.support-primary-btn {
  display: block;
  background: #ffdd00;
  color: #222;
  padding: 14px;
  border-radius: 12px;
  text-decoration: none;
  font-weight: 700;
  transition: transform 0.2s, box-shadow 0.2s;
}
.support-primary-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 18px rgba(0,0,0,.15);
  color: #222;
}
.support-secondary-btn {
  background: #ffffff;
  color: #0f172a;
  border: 1px solid #cbd5e1;
  padding: 12px;
  font-weight: 600;
  cursor: pointer;
  border-radius: 12px;
  transition: background 0.2s, border-color 0.2s;
}
.support-secondary-btn:hover {
  background: #f8fafc;
  border-color: #94a3b8;
}
body.dark-mode .support-secondary-btn {
  background: #1e2329;
  color: #f8fafc;
  border-color: #3f464e;
}
body.dark-mode .support-secondary-btn:hover {
  background: #2a2e33;
  border-color: #475569;
}
.support-friendly-msg {
  margin: 0 !important;
  font-size: 0.85rem !important;
  color: #64748b !important;
}
body.dark-mode .support-friendly-msg {
  color: #94a3b8 !important;
}
