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

:root {
  --primary: #0ea5e9;
  --primary-dark: #0284c7;
  --primary-light: #e0f2fe;
  --bg: #f8fafc;
  --surface: #ffffff;
  --text: #0f172a;
  --text-secondary: #64748b;
  --border: #e2e8f0;
  --success: #16a34a;
  --success-light: #dcfce7;
  --error: #ef4444;
  --error-light: #fef2f2;
  --warning: #f59e0b;
  --danger: #ef4444;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
  --transition: 0.2s ease;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Noto Sans TC", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

.hidden { display: none !important; }

/* ===== App Layout ===== */
.app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ===== Header ===== */
.header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 20px 0;
}

.header-inner {
  max-width: 720px;
  margin: 0 auto;
  padding: 0 24px;
  text-align: center;
}

.logo-link {
  text-decoration: none;
  display: inline-block;
}

.logo {
  font-size: 28px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.5px;
}

.logo-ai {
  color: var(--primary);
  margin-left: 4px;
  font-weight: 800;
}

.tagline {
  color: var(--text-secondary);
  font-size: 14px;
  margin-top: 4px;
}

/* ===== Main Content ===== */
.main {
  flex: 1;
  max-width: 720px;
  width: 100%;
  margin: 0 auto;
  padding: 32px 24px;
}

/* ===== Views ===== */
.view { display: none; }
.view.active { display: block; animation: fadeIn 0.3s ease; }

/* ===== Interview List (Task 1) ===== */
.list-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
}

.interview-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  color: var(--text-secondary);
  text-align: center;
}

.empty-icon { opacity: 0.3; margin-bottom: 16px; }
.empty-title { font-size: 18px; font-weight: 600; margin-bottom: 4px; }
.empty-desc { font-size: 14px; }

.interview-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  transition: box-shadow var(--transition);
}

.interview-card:hover { box-shadow: var(--shadow-md); }

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

.card-info { display: flex; align-items: baseline; gap: 10px; }
.card-name { font-size: 16px; font-weight: 700; }
.card-role { font-size: 13px; color: var(--text-secondary); }

.card-status {
  font-size: 11px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 12px;
  white-space: nowrap;
}

.status-done { background: var(--success-light); color: var(--success); }
.status-progress { background: var(--primary-light); color: var(--primary-dark); }

.card-topic {
  font-size: 14px;
  color: var(--text);
  margin-bottom: 12px;
  line-height: 1.5;
}

.card-meta {
  display: flex;
  gap: 16px;
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 12px;
}

.card-actions {
  display: flex;
  gap: 8px;
}

.btn-sm {
  padding: 6px 16px;
  font-size: 13px;
  border-radius: 6px;
}

.btn-danger-outline {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 6px 10px;
  border-radius: 6px;
  transition: all var(--transition);
}

.btn-danger-outline:hover {
  border-color: var(--danger);
  color: var(--danger);
  background: var(--error-light);
}

/* ===== Modal ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 300;
  animation: fadeIn 0.2s ease;
}

.modal {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 28px;
  max-width: 400px;
  width: 90%;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
}

.modal h3 { font-size: 18px; margin-bottom: 8px; }
.modal p { font-size: 14px; color: var(--text-secondary); margin-bottom: 20px; }

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.btn-danger {
  background: var(--danger);
  color: white;
  border: none;
  padding: 8px 20px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}

.btn-danger:hover { opacity: 0.9; }

/* ===== Steps Indicator ===== */
.steps {
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 36px;
}

.step {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.step-circle {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 2px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
  background: var(--surface);
  transition: all var(--transition);
}

.step.active .step-circle {
  border-color: var(--primary);
  background: var(--primary);
  color: white;
}

.step.done .step-circle {
  border-color: var(--primary);
  background: var(--primary-light);
  color: var(--primary);
}

.step.done .step-circle::after {
  content: '\2713';
  font-size: 16px;
  font-weight: 700;
}

.step.done .step-number { display: none; }

.step-label {
  font-size: 11px;
  color: var(--text-secondary);
  font-weight: 500;
  white-space: nowrap;
}

.step.active .step-label {
  color: var(--primary);
  font-weight: 600;
}

.step-line {
  width: 40px;
  height: 2px;
  background: var(--border);
  margin: 0 6px;
  margin-bottom: 20px;
  transition: background var(--transition);
}

.step-line.done { background: var(--primary); }

/* ===== Panels ===== */
.panel {
  display: none;
  animation: fadeIn 0.3s ease;
}

.panel.active { display: block; }

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

.panel-title {
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 8px;
}

.panel-desc {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 24px;
}

/* ===== Form ===== */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-group.full-width { margin-top: 16px; }

label {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

.required { color: var(--error); }

input, textarea, select {
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 15px;
  font-family: inherit;
  background: var(--surface);
  color: var(--text);
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
}

input:focus, textarea:focus, select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.15);
}

input::placeholder, textarea::placeholder { color: #94a3b8; }
textarea { resize: vertical; }

.input-error {
  border-color: var(--error) !important;
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1) !important;
}

.field-error {
  font-size: 12px;
  color: var(--error);
  min-height: 16px;
}

/* ===== Mode Selector (Task 2) ===== */
.mode-selector {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 4px;
}

.mode-option input[type="radio"] {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.mode-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border: 2px solid var(--border);
  border-radius: 10px;
  cursor: pointer;
  transition: all var(--transition);
  background: var(--surface);
}

.mode-option input[type="radio"]:checked + .mode-card {
  border-color: var(--primary);
  background: var(--primary-light);
}

.mode-card:hover { border-color: var(--primary); }

.mode-icon {
  flex-shrink: 0;
  color: var(--primary);
}

.mode-info {
  display: flex;
  flex-direction: column;
}

.mode-info strong {
  font-size: 14px;
  color: var(--text);
}

.mode-info span {
  font-size: 12px;
  color: var(--text-secondary);
  font-weight: 400;
  line-height: 1.4;
}

/* ===== Buttons ===== */
.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 28px;
  flex-wrap: wrap;
}

.btn {
  padding: 10px 24px;
  border: none;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  font-family: inherit;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

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

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

.btn-primary:hover:not(:disabled) {
  background: var(--primary-dark);
  box-shadow: var(--shadow-md);
}

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

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

/* ===== Spinner ===== */
.spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ===== Step 2: Interview Header ===== */
.step2-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 24px;
  gap: 16px;
}

.step2-header .panel-title { margin-bottom: 8px; }

.interviewee-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--primary-light);
  color: var(--primary-dark);
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 16px;
}

.question-progress {
  text-align: right;
  flex-shrink: 0;
}

.progress-text {
  font-size: 13px;
  color: var(--text-secondary);
}

.progress-bar {
  width: 120px;
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  margin-top: 8px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--primary);
  border-radius: 3px;
  width: 0%;
  transition: width 0.3s ease;
}

/* ===== Active Question Card ===== */
.active-question {
  background: var(--surface);
  border: 2px solid var(--primary);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow-md);
}

.question-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.question-number {
  font-size: 12px;
  font-weight: 700;
  color: var(--primary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.question-category {
  font-size: 11px;
  font-weight: 600;
  color: var(--primary-dark);
  background: var(--primary-light);
  padding: 2px 10px;
  border-radius: 10px;
}

.question-text {
  font-size: 18px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 20px;
  line-height: 1.5;
}

/* ===== TTS Button (Task 3) ===== */
.btn-tts {
  background: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px 8px;
  cursor: pointer;
  color: var(--text-secondary);
  transition: all var(--transition);
  display: inline-flex;
  align-items: center;
  margin-left: auto;
}

.btn-tts:hover { color: var(--primary); border-color: var(--primary); }
.btn-tts.playing { color: var(--primary); border-color: var(--primary); background: var(--primary-light); }

/* ===== Recording Controls ===== */
.record-section {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 16px;
}

.btn-record {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  border: 2px solid var(--border);
  border-radius: 24px;
  background: var(--surface);
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  font-family: inherit;
}

.btn-record:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.btn-record.recording {
  border-color: var(--error);
  color: var(--error);
  background: var(--error-light);
  animation: pulse 1.5s ease-in-out infinite;
}

.btn-record.transcribing {
  border-color: var(--warning);
  color: var(--warning);
  opacity: 0.7;
  pointer-events: none;
}

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.3); }
  50% { box-shadow: 0 0 0 8px rgba(239, 68, 68, 0); }
}

.mic-icon {
  width: 20px;
  height: 20px;
}

.record-timer {
  font-size: 16px;
  font-weight: 700;
  color: var(--error);
  font-variant-numeric: tabular-nums;
}

/* ===== Recording Wave Animation ===== */
.recording-wave {
  display: flex;
  align-items: center;
  gap: 3px;
  height: 24px;
}

.recording-wave span {
  display: block;
  width: 3px;
  height: 8px;
  background: var(--error);
  border-radius: 2px;
  animation: wave 1s ease-in-out infinite;
}

.recording-wave span:nth-child(1) { animation-delay: 0s; }
.recording-wave span:nth-child(2) { animation-delay: 0.1s; }
.recording-wave span:nth-child(3) { animation-delay: 0.2s; }
.recording-wave span:nth-child(4) { animation-delay: 0.3s; }
.recording-wave span:nth-child(5) { animation-delay: 0.4s; }

@keyframes wave {
  0%, 100% { height: 8px; }
  50% { height: 24px; }
}

/* ===== Transcript Area (inline, under recording) ===== */
.transcript-area {
  background: #f1f5f9;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 16px;
  margin-bottom: 16px;
}

.transcript-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 6px;
  display: block;
}

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

/* ===== Answer Area ===== */
.answer-area textarea {
  width: 100%;
  min-height: 100px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  font-size: 15px;
  resize: vertical;
}

/* ===== Step 3: Transcript List ===== */
.transcript-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.transcript-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}

.transcript-item.skipped {
  opacity: 0.6;
}

.transcript-q-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

.transcript-q {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 12px;
  line-height: 1.5;
}

.transcript-a {
  padding-left: 16px;
  border-left: 3px solid var(--primary);
}

.answer-block {
  font-size: 14px;
  color: var(--text);
  line-height: 1.7;
  white-space: pre-wrap;
}

.skipped-text {
  color: var(--text-secondary);
  font-style: italic;
}

.raw-transcript {
  margin-top: 10px;
  padding: 10px 12px;
  background: #f1f5f9;
  border-radius: 6px;
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.6;
}

.transcript-tag {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  color: var(--primary);
  background: var(--primary-light);
  padding: 1px 8px;
  border-radius: 4px;
  margin-right: 8px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* ===== Step 4: Summary Report ===== */
.summary-content {
  margin-top: 20px;
}

.summary-report {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  box-shadow: var(--shadow);
  line-height: 1.8;
}

.summary-report h3 {
  font-size: 18px;
  font-weight: 700;
  color: var(--primary-dark);
  margin: 24px 0 12px;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--primary-light);
}

.summary-report h3:first-child { margin-top: 0; }

.summary-report h4 {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  margin: 16px 0 8px;
}

.summary-report p {
  font-size: 14px;
  color: var(--text);
  margin-bottom: 8px;
}

.summary-report ul {
  padding-left: 20px;
  margin: 8px 0;
}

.summary-report li {
  font-size: 14px;
  color: var(--text);
  margin-bottom: 6px;
  line-height: 1.7;
}

.summary-report q {
  display: inline;
  font-style: italic;
  color: var(--primary-dark);
  quotes: "\201C" "\201D";
}

.summary-report strong {
  color: var(--text);
}

/* ===== Evaluation Section (Task 4) ===== */
.evaluation-section {
  margin-bottom: 32px;
}

.eval-title {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 20px;
  color: var(--text);
}

.score-circles {
  display: flex;
  justify-content: center;
  gap: 32px;
  margin-bottom: 28px;
}

.score-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.score-circle {
  position: relative;
  width: 90px;
  height: 90px;
}

.score-circle svg {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.score-bg {
  fill: none;
  stroke: var(--border);
  stroke-width: 6;
}

.score-fill {
  fill: none;
  stroke: var(--primary);
  stroke-width: 6;
  stroke-linecap: round;
}

.score-value {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  font-weight: 700;
  color: var(--text);
}

.score-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
}

/* Highlights */
.eval-highlights h4,
.eval-suggestions h4 {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 12px;
}

.highlight-cards {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 20px;
}

.highlight-card {
  background: var(--primary-light);
  border-left: 3px solid var(--primary);
  border-radius: 8px;
  padding: 14px 18px;
  font-size: 14px;
  color: var(--text);
  line-height: 1.6;
}

.highlight-card q {
  font-style: italic;
  quotes: "\201C" "\201D";
}

/* Suggestions */
.suggestion-list {
  padding-left: 20px;
}

.suggestion-list li {
  font-size: 14px;
  color: var(--text);
  margin-bottom: 8px;
  line-height: 1.6;
}

/* ===== Toast ===== */
.toast {
  position: fixed;
  bottom: 32px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: var(--text);
  color: white;
  padding: 12px 24px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
  z-index: 200;
  opacity: 0;
  transition: all 0.3s ease;
  pointer-events: none;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.toast.toast-success { background: var(--success); }
.toast.toast-error { background: var(--error); }

/* ===== Footer ===== */
.footer {
  text-align: center;
  padding: 20px;
  color: var(--text-secondary);
  font-size: 13px;
  border-top: 1px solid var(--border);
}

/* ===== Responsive ===== */
@media (max-width: 600px) {
  .form-grid { grid-template-columns: 1fr; }
  .mode-selector { grid-template-columns: 1fr; }
  .steps { gap: 0; }
  .step-line { width: 24px; }
  .step-label { font-size: 10px; }
  .main { padding: 24px 16px; }
  .step2-header { flex-direction: column; }
  .question-progress { text-align: left; }
  .progress-bar { width: 100%; }
  .record-section { flex-wrap: wrap; }
  .question-text { font-size: 16px; }
  .score-circles { gap: 16px; }
  .score-circle { width: 72px; height: 72px; }
  .score-value { font-size: 20px; }
  .list-header { flex-direction: column; gap: 12px; align-items: flex-start; }
  .form-actions { flex-direction: column; }
  .form-actions .btn { width: 100%; justify-content: center; }
}
