/* Theory Examination Tools CSS: Graph Sheet, Formula Palette, Drawing Board, Voice Dictation */

:root,
[data-theme="light"] {
  --tt-primary: var(--primary, #4f46e5);
  --tt-primary-hover: var(--primary-dark, #4338ca);
  --tt-surface: var(--bg-card, #ffffff);
  --tt-bg: var(--bg-app, #f5f7fb);
  --tt-border: var(--border-light, #e4e8f0);
  --tt-text: var(--text-main, #0b1220);
  --tt-text-muted: var(--text-muted, #64748b);
  --tt-danger: var(--accent-rose, #e11d48);
  --tt-success: var(--accent-emerald, #059669);
}

[data-theme="dark"] {
  --tt-primary: var(--primary, #818cf8);
  --tt-primary-hover: var(--primary-light, #a5b4fc);
  --tt-surface: var(--bg-card, #0f1524);
  --tt-bg: var(--bg-app, #070b14);
  --tt-border: var(--border-light, #1f2a40);
  --tt-text: var(--text-main, #eef2fb);
  --tt-text-muted: var(--text-muted, #8b97b1);
  --tt-danger: var(--accent-rose, #fb7185);
  --tt-success: var(--accent-emerald, #34d399);
}

/* Toolbelt Container */
.theory-toolbelt {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
  padding: 0.45rem 0.65rem;
  background: rgba(37, 99, 235, 0.05);
  border: 1px solid rgba(37, 99, 235, 0.2);
  border-bottom: none;
  border-top-left-radius: 8px;
  border-top-right-radius: 8px;
  user-select: none;
}

.theory-tool-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.32rem 0.65rem;
  border-radius: 6px;
  font-size: 0.76rem;
  font-weight: 700;
  background: var(--tt-surface);
  border: 1px solid var(--tt-border);
  color: var(--tt-text);
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.theory-tool-btn:hover {
  background: var(--tt-bg);
  border-color: var(--tt-primary);
  color: var(--tt-primary);
  transform: translateY(-1px);
}

.theory-tool-btn.active {
  background: var(--tt-primary);
  color: #ffffff;
  border-color: var(--tt-primary);
}

.theory-tool-btn.btn-voice.recording {
  background: #dc2626;
  color: #ffffff;
  border-color: #b91c1c;
  animation: tt-pulse 1.4s infinite;
}

@keyframes tt-pulse {
  0% { box-shadow: 0 0 0 0 rgba(220, 38, 38, 0.5); }
  70% { box-shadow: 0 0 0 8px rgba(220, 38, 38, 0); }
  100% { box-shadow: 0 0 0 0 rgba(220, 38, 38, 0); }
}

/* Formula Palette Dropdown / Drawer */
.formula-palette-panel {
  display: none;
  background: var(--tt-surface);
  border: 1px solid var(--tt-border);
  border-top: none;
  padding: 0.65rem;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
  margin-bottom: 0.5rem;
}

.formula-tabs {
  display: flex;
  gap: 0.3rem;
  overflow-x: auto;
  border-bottom: 1px solid var(--tt-border);
  padding-bottom: 0.35rem;
  margin-bottom: 0.5rem;
}

.formula-tab-btn {
  background: none;
  border: none;
  padding: 0.25rem 0.55rem;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--tt-text-muted);
  cursor: pointer;
  border-radius: 4px;
}

.formula-tab-btn.active {
  background: rgba(37, 99, 235, 0.12);
  color: var(--tt-primary);
}

.formula-items-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  max-height: 140px;
  overflow-y: auto;
}

.formula-item-chip {
  padding: 0.3rem 0.55rem;
  background: var(--tt-bg);
  border: 1px solid var(--tt-border);
  border-radius: 4px;
  font-size: 0.82rem;
  font-family: 'Times New Roman', Georgia, serif;
  font-weight: 700;
  color: var(--tt-text);
  cursor: pointer;
  transition: all 0.1s ease;
  min-width: 28px;
  text-align: center;
}

.formula-item-chip:hover {
  background: var(--tt-primary);
  color: #ffffff;
  border-color: var(--tt-primary);
}

/* Attachments preview below textarea */
.theory-attachments-strip {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  flex-wrap: wrap;
  margin-top: 0.5rem;
  padding: 0.4rem 0.6rem;
  background: rgba(16, 185, 129, 0.05);
  border: 1px dashed rgba(16, 185, 129, 0.35);
  border-radius: 6px;
}

.theory-attachment-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.25rem 0.5rem;
  background: var(--tt-surface);
  border: 1px solid var(--tt-border);
  border-radius: 6px;
  font-size: 0.74rem;
  font-weight: 600;
}

.theory-attachment-thumb {
  width: 28px;
  height: 28px;
  object-fit: cover;
  border-radius: 4px;
  border: 1px solid var(--tt-border);
  cursor: pointer;
}

.theory-attachment-delete {
  background: none;
  border: none;
  color: var(--tt-danger);
  cursor: pointer;
  font-size: 0.85rem;
  padding: 0 2px;
  display: flex;
  align-items: center;
}

/* Modals for Graph Sheet & Drawing Board */
.tt-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.tt-modal-window {
  background: var(--tt-surface);
  border: 1px solid var(--tt-border);
  border-radius: 12px;
  box-shadow: 0 20px 45px rgba(0, 0, 0, 0.35);
  display: flex;
  flex-direction: column;
  width: 95vw;
  max-width: 900px;
  height: 88vh;
  max-height: 720px;
  overflow: hidden;
}

.tt-modal-header {
  padding: 0.65rem 1rem;
  border-bottom: 1px solid var(--tt-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--tt-bg);
}

.tt-modal-title {
  font-size: 0.92rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.tt-modal-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}

.tt-modal-toolbar {
  padding: 0.4rem 0.75rem;
  border-bottom: 1px solid var(--tt-border);
  display: flex;
  align-items: center;
  gap: 0.45rem;
  flex-wrap: nowrap; /* Keep measurement on same line as all buttons */
  overflow-x: auto;
  background: var(--tt-surface);
  user-select: none;
  scrollbar-width: thin;
}

.tt-modal-toolbar::-webkit-scrollbar {
  height: 4px;
}
.tt-modal-toolbar::-webkit-scrollbar-thumb {
  background: var(--tt-border);
  border-radius: 4px;
}

.tt-toolbar-item {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  white-space: nowrap;
  flex-shrink: 0;
}

.tt-toolbar-label {
  font-size: 0.74rem;
  font-weight: 700;
  color: var(--tt-text);
  white-space: nowrap;
  margin: 0;
}

.tt-modal-canvas-wrap {
  flex: 1;
  position: relative;
  overflow: auto;
  background: #f1f5f9;
  display: flex;
  align-items: center;
  justify-content: center;
}

.tt-modal-footer {
  padding: 0.65rem 1rem;
  border-top: 1px solid var(--tt-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--tt-bg);
}

/* Canvas styling */
.tt-canvas {
  background: #ffffff;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
  cursor: crosshair;
  touch-action: none;
}

/* Graph Sheet Millimetre paper pattern */
.tt-graph-canvas {
  background-color: #fafbfc;
  cursor: crosshair;
}

/* Controls inside Graph modal */
.graph-coords-inspector {
  position: absolute;
  bottom: 10px;
  left: 10px;
  background: rgba(15, 23, 42, 0.85);
  color: #f8fafc;
  padding: 0.3rem 0.6rem;
  border-radius: 4px;
  font-size: 0.72rem;
  font-family: monospace;
  pointer-events: none;
}

/* Voice Dictation Live Banner */
.voice-dictation-banner {
  display: none;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.75rem;
  background: rgba(239, 68, 68, 0.08);
  border: 1px solid rgba(239, 68, 68, 0.3);
  border-radius: 6px;
  margin-bottom: 0.5rem;
  font-size: 0.76rem;
  color: #dc2626;
}

.voice-wave-anim {
  display: inline-flex;
  gap: 2px;
  align-items: center;
  height: 12px;
}

.voice-wave-bar {
  width: 2px;
  height: 100%;
  background: #dc2626;
  border-radius: 1px;
  animation: tt-wave 0.8s ease-in-out infinite alternate;
}

.voice-wave-bar:nth-child(2) { animation-delay: 0.2s; }
.voice-wave-bar:nth-child(3) { animation-delay: 0.4s; }

@keyframes tt-wave {
  0% { height: 3px; }
  100% { height: 12px; }
}

/* Fullscreen Mode for Modals */
.tt-modal-window.is-fullscreen {
  width: 100vw !important;
  max-width: 100vw !important;
  height: 100vh !important;
  max-height: 100vh !important;
  border-radius: 0 !important;
  border: none !important;
}

.tt-modal-window.is-fullscreen .tt-modal-canvas-wrap {
  height: calc(100vh - 110px);
}

/* Colour Picker Box & Quick Swatches in Handwriting Board */
.tt-color-picker-box {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: var(--tt-bg);
  border: 1px solid var(--tt-border);
  padding: 0.18rem 0.45rem;
  border-radius: 6px;
  flex-shrink: 0;
}

.tt-color-picker-box input[type="color"] {
  width: 22px;
  height: 22px;
  border: 1px solid var(--tt-border);
  border-radius: 4px;
  padding: 0;
  background: none;
  cursor: pointer;
}

.tt-quick-swatches {
  display: inline-flex;
  align-items: center;
  gap: 3px;
}

.tt-swatch-dot {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 1px solid rgba(0, 0, 0, 0.25);
  cursor: pointer;
  padding: 0;
  transition: transform 0.12s ease;
}

.tt-swatch-dot:hover {
  transform: scale(1.25);
}

/* Draft Save status & button */
.theory-draft-status {
  font-size: 0.72rem;
  font-weight: 700;
  color: #059669;
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  margin-left: 0.4rem;
  transition: opacity 0.3s ease;
}

.theory-tool-btn.btn-save-draft {
  background: rgba(16, 185, 129, 0.08);
  border-color: rgba(16, 185, 129, 0.35);
  color: #059669;
}

.theory-tool-btn.btn-save-draft:hover {
  background: #059669;
  color: #ffffff;
}

/* Scientific Calculator Window & Controls */
.tt-calc-window {
  max-width: 420px;
  height: auto;
  max-height: 94vh;
  box-shadow: 0 25px 65px rgba(0, 0, 0, 0.5);
  border-radius: 14px;
}

.tt-calc-screen {
  background: #090d16;
  color: #f8fafc;
  padding: 0.75rem 1rem;
  text-align: right;
  border-bottom: 2px solid #1e293b;
  user-select: text;
}

.tt-calc-subdisplay {
  font-size: 0.76rem;
  color: #94a3b8;
  min-height: 1.15rem;
  font-family: 'JetBrains Mono', 'Courier New', monospace;
  overflow-x: auto;
  white-space: nowrap;
}

.tt-calc-maindisplay {
  font-size: 1.6rem;
  font-weight: 800;
  color: #38bdf8;
  font-family: 'JetBrains Mono', 'Courier New', monospace;
  letter-spacing: -0.5px;
  overflow-x: auto;
  white-space: nowrap;
  margin-top: 0.15rem;
}

.tt-calc-mode-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.7rem;
  color: #cbd5e1;
  margin-bottom: 0.25rem;
}

.tt-calc-mode-badge {
  background: #1e293b;
  border: 1px solid #475569;
  color: #38bdf8;
  font-weight: 800;
  padding: 0.15rem 0.45rem;
  border-radius: 4px;
  cursor: pointer;
}

.tt-calc-keypad {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 0.35rem;
  padding: 0.65rem;
  background: var(--tt-surface);
}

.tt-calc-btn {
  padding: 0.55rem 0.2rem;
  font-size: 0.85rem;
  font-weight: 700;
  border-radius: 6px;
  border: 1px solid var(--tt-border);
  background: var(--tt-bg);
  color: var(--tt-text);
  cursor: pointer;
  transition: all 0.1s ease;
  text-align: center;
}

.tt-calc-btn:hover {
  background: var(--tt-primary);
  color: #ffffff;
  border-color: var(--tt-primary);
}

.tt-calc-btn.sci {
  background: rgba(37, 99, 235, 0.08);
  color: var(--tt-primary);
  font-size: 0.76rem;
}

.tt-calc-btn.op {
  background: rgba(245, 158, 11, 0.12);
  color: #d97706;
  font-size: 0.95rem;
}

.tt-calc-btn.action {
  background: rgba(239, 68, 68, 0.1);
  color: #dc2626;
  font-weight: 800;
}

.tt-calc-btn.equals {
  background: var(--tt-primary);
  color: #ffffff;
  grid-column: span 2;
  font-size: 1.1rem;
}

/* =========================================================================
   Segmented Timer Display: HH:MM:SS with Hr, Min, Sec at Top
   ========================================================================= */
.st-timer-segmented {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  user-select: none;
  vertical-align: middle;
}

.timer-segment {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-width: 1.7rem;
}

.timer-unit-label {
  font-size: 0.58rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted, #64748b);
  line-height: 1;
  margin-bottom: 2px;
}

.timer-digit {
  font-family: 'JetBrains Mono', 'Courier New', monospace;
  font-size: 1.05rem;
  font-weight: 800;
  line-height: 1.1;
  color: inherit;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.timer-sep {
  font-size: 1.05rem;
  font-weight: 800;
  line-height: 1.1;
  align-self: flex-end;
  margin-bottom: 2px;
  opacity: 0.55;
  color: inherit;
}


