/* =========================================================
   iTest Web — עיצוב ראשי
   ========================================================= */
:root {
  --primary: #1e3a8a;
  --primary-hover: #1d4ed8;
  --primary-light: #eff6ff;
  --accent: #f59e0b;
  --highlight-bg: rgba(253, 224, 71, 0.42);
  --highlight-border: #eab308;
  --hover-bg: rgba(59, 130, 246, 0.14);
  --bg-app: #f1f5f9;
  --bg-panel: #ffffff;
  --text-main: #0f172a;
  --text-muted: #475569;
  --border: #cbd5e1;
  --danger: #dc2626;
  --success: #16a34a;
  --radius: 10px;
  --shadow: 0 4px 14px rgba(15, 23, 42, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: 'Heebo', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background-color: var(--bg-app);
  color: var(--text-main);
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Top Toolbar */
header.toolbar {
  background: var(--primary);
  color: #ffffff;
  padding: 10px 18px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.18);
  z-index: 20;
  flex-shrink: 0;
}

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

.brand-badge {
  background: var(--accent);
  color: #0f172a;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 1.05rem;
  letter-spacing: 0.4px;
}

.brand h1 {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 600;
}

.toolbar-group {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 13px;
  border-radius: 8px;
  border: 1px solid transparent;
  font-family: inherit;
  font-size: 0.92rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn-sm {
  padding: 5px 10px;
  font-size: 0.84rem;
}

.btn-light {
  background: #ffffff;
  color: var(--primary);
}

.btn-light:hover:not(:disabled) {
  background: #e2e8f0;
}

.btn-accent {
  background: var(--accent);
  color: #0f172a;
  font-weight: 600;
}

.btn-accent:hover:not(:disabled) {
  background: #d97706;
  color: #ffffff;
}

.btn-outline-white {
  background: rgba(255, 255, 255, 0.12);
  color: #ffffff;
  border-color: rgba(255, 255, 255, 0.28);
}

.btn-outline-white:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.24);
}

.btn-danger {
  background: var(--danger);
  color: #ffffff;
}

.btn-danger:hover:not(:disabled) {
  background: #b91c1c;
}

.btn-primary {
  background: var(--primary);
  color: #ffffff;
}

.btn-primary:hover:not(:disabled) {
  background: var(--primary-hover);
}

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

.btn-secondary:hover:not(:disabled) {
  background: #cbd5e1;
}

.control-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(255, 255, 255, 0.14);
  padding: 5px 10px;
  border-radius: 8px;
  font-size: 0.88rem;
}

.control-pill select {
  cursor: pointer;
  background: #ffffff;
  color: var(--text-main);
  border: none;
  border-radius: 5px;
  padding: 3px 6px;
  font-family: inherit;
  font-size: 0.85rem;
}

/* Status Sub-bar */
.status-bar {
  background: #e2e8f0;
  border-bottom: 1px solid var(--border);
  padding: 6px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.88rem;
  color: var(--text-muted);
  gap: 12px;
  flex-wrap: wrap;
  flex-shrink: 0;
}

.status-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 500;
  color: var(--text-main);
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #94a3b8;
}

.dot.speaking {
  background: var(--success);
  box-shadow: 0 0 0 4px rgba(22, 163, 74, 0.22);
  animation: pulse 1.2s infinite;
}

.dot.paused {
  background: var(--accent);
}

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

/* Live Spoken Subtitle Strip */
.live-caption-bar {
  background: #fefce8;
  border-bottom: 1px solid #fde047;
  padding: 6px 18px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.92rem;
  color: #713f12;
  flex-shrink: 0;
}

.caption-badge {
  background: #fde047;
  color: #0f172a;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 5px;
  font-size: 0.8rem;
  white-space: nowrap;
}

.caption-text {
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Main Workspace Split */
main.workspace {
  display: flex;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  gap: 14px;
  padding: 14px;
}

/* Exam Viewer Column */
section.viewer-pane {
  flex: 1.45;
  min-width: 0;
  min-height: 0;
  background: #cbd5e1;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}

.viewer-header {
  background: var(--bg-panel);
  padding: 8px 14px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 0.9rem;
  flex-shrink: 0;
}

.viewer-scroll {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
}

/* Rendered PDF Page Container */
.pdf-page-wrapper {
  position: relative;
  flex-shrink: 0;
  background: #ffffff;
  box-shadow: var(--shadow);
  border-radius: 4px;
  overflow: hidden;
}

.pdf-page-badge {
  position: absolute;
  top: 8px;
  left: 8px;
  background: rgba(15, 23, 42, 0.72);
  color: #ffffff;
  font-size: 0.78rem;
  padding: 2px 8px;
  border-radius: 4px;
  z-index: 10;
  pointer-events: none;
}

.pdf-page-wrapper canvas {
  display: block;
}

.interactive-text-layer {
  position: absolute;
  inset: 0;
  z-index: 5;
}

.readable-line {
  position: absolute;
  cursor: pointer;
  border-radius: 4px;
  transition: background-color 0.12s ease;
  border-bottom: 2px solid transparent;
}

.readable-line:hover {
  background-color: var(--hover-bg);
  border-bottom-color: #3b82f6;
}

.readable-line.active-reading {
  background-color: var(--highlight-bg) !important;
  border-bottom: 2px solid var(--highlight-border) !important;
}

/* Built-in Demo Exam Styling */
.demo-exam-sheet {
  flex-shrink: 0;
  background: #ffffff;
  width: 100%;
  max-width: 780px;
  padding: 36px 42px;
  border-radius: 6px;
  box-shadow: var(--shadow);
  line-height: 1.75;
}

.demo-exam-header {
  border-bottom: 2px solid #0f172a;
  padding-bottom: 14px;
  margin-bottom: 22px;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
}

.demo-line {
  padding: 4px 8px;
  margin: 3px 0;
  border-radius: 5px;
  cursor: pointer;
  transition: background 0.12s;
  border-right: 3px solid transparent;
}

.demo-line:hover {
  background: var(--hover-bg);
  border-right-color: #3b82f6;
}

.demo-line.active-reading {
  background: var(--highlight-bg);
  border-right-color: var(--highlight-border);
  font-weight: 500;
}

.ltr-block {
  direction: ltr;
  text-align: left;
  font-family: 'Segoe UI', Arial, sans-serif;
  background: #f8fafc;
  padding: 14px 18px;
  border-radius: 8px;
  border: 1px solid #e2e8f0;
  margin: 12px 0;
}

.ltr-block .demo-line {
  border-right: none;
  border-left: 3px solid transparent;
}

.ltr-block .demo-line:hover {
  border-left-color: #3b82f6;
}

.ltr-block .demo-line.active-reading {
  border-left-color: var(--highlight-border);
}

.math-box {
  background: #fefce8;
  border: 1px solid #fde047;
  padding: 12px 16px;
  border-radius: 8px;
  margin: 10px 0;
}

/* Dictation & Answer Column */
aside.dictation-pane {
  flex: 1;
  min-width: 330px;
  max-width: 480px;
  min-height: 0;
  background: var(--bg-panel);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow);
  overflow: hidden;
}

aside.dictation-pane.hidden {
  display: none;
}

.pane-header {
  padding: 12px 16px;
  background: #f8fafc;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.pane-header h2 {
  margin: 0;
  font-size: 1.02rem;
  color: var(--primary);
}

.lang-select {
  padding: 4px 8px;
  border-radius: 6px;
  border: 1px solid var(--border);
  font-family: inherit;
}

.dictation-controls {
  padding: 12px 16px;
  background: #f1f5f9;
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.mic-btn {
  background: var(--danger);
  color: #ffffff;
  font-weight: 600;
}

.mic-btn.recording {
  background: #15803d;
  animation: pulse 1.2s infinite;
}

.punct-bar {
  padding: 8px 16px;
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  border-bottom: 1px solid #e2e8f0;
  background: #ffffff;
}

.punct-label {
  font-size: 0.82rem;
  color: #64748b;
  align-self: center;
}

.punct-btn {
  background: #f1f5f9;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  padding: 3px 9px;
  font-size: 0.84rem;
  cursor: pointer;
  font-family: inherit;
}

.punct-btn:hover {
  background: #e2e8f0;
}

.interim-preview {
  padding: 6px 16px;
  font-size: 0.85rem;
  color: #2563eb;
  background: #eff6ff;
  min-height: 28px;
  border-bottom: 1px solid #dbeafe;
  font-style: italic;
}

textarea#answerEditor {
  flex: 1;
  width: 100%;
  border: none;
  padding: 16px;
  font-family: inherit;
  font-size: 1.05rem;
  line-height: 1.7;
  resize: none;
  outline: none;
  color: var(--text-main);
}

.pane-footer {
  padding: 10px 16px;
  background: #f8fafc;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.word-count {
  font-size: 0.83rem;
  color: #64748b;
}

/* Voice Settings Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.5);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 50;
}

.modal-backdrop.open {
  display: flex;
}

.modal-card {
  background: #ffffff;
  border-radius: 12px;
  padding: 22px;
  width: 92%;
  max-width: 460px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.25);
}

.modal-card h3 {
  margin-top: 0;
  color: var(--primary);
}

.modal-desc {
  font-size: 0.88rem;
  color: #475569;
  margin-top: -6px;
}

.form-group {
  margin-bottom: 14px;
}

.form-group label {
  display: block;
  font-weight: 600;
  margin-bottom: 5px;
  font-size: 0.9rem;
}

.form-group select {
  width: 100%;
  padding: 8px;
  border-radius: 6px;
  border: 1px solid var(--border);
  font-family: inherit;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 18px;
}

@media (max-width: 900px) {
  body {
    height: auto;
    overflow: auto;
  }
  main.workspace {
    flex-direction: column;
    overflow: visible;
  }
  section.viewer-pane {
    min-height: 520px;
  }
  aside.dictation-pane {
    max-width: 100%;
    min-height: 360px;
  }
}


/* Teacher Prep Mode Styles */
.btn-teacher {
  background: #0f766e;
  color: #ffffff;
  border-color: rgba(255, 255, 255, 0.25);
}

.btn-teacher:hover:not(:disabled) {
  background: #115e59;
}

.btn-success {
  background: var(--success);
  color: #ffffff;
  font-weight: 600;
}

.btn-success:hover:not(:disabled) {
  background: #15803d;
}

.prepared-badge {
  background: #dcfce7;
  color: #166534;
  border: 1px solid #86efac;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

.readable-line.teacher-edited {
  border-bottom: 2px dashed #16a34a;
}

.modal-card-wide {
  max-width: 820px;
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  padding: 20px;
}

.teacher-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.teacher-filter-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 12px 0;
}

.teacher-filter-bar input {
  flex: 1;
  padding: 7px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-family: inherit;
  font-size: 0.9rem;
}

.edited-counter {
  background: #eff6ff;
  color: var(--primary);
  font-weight: 600;
  font-size: 0.84rem;
  padding: 5px 10px;
  border-radius: 6px;
  white-space: nowrap;
}

.teacher-lines-list {
  flex: 1;
  min-height: 220px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #f8fafc;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.teacher-line-row {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.teacher-line-row.is-edited {
  border-color: #22c55e;
  background: #f0fdf4;
}

.teacher-line-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 0.8rem;
  color: #64748b;
}

.teacher-line-input-wrap {
  display: flex;
  gap: 8px;
  align-items: center;
}

.teacher-line-input {
  flex: 1;
  padding: 7px 10px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  font-family: inherit;
  font-size: 0.95rem;
  color: var(--text-main);
}

.teacher-line-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(30, 58, 138, 0.14);
}

.teacher-modal-footer {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
