/* ─── Reset & Base ──────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: #f0f4f8;
  color: #1e293b;
  min-height: 100vh;
}

/* ─── Header ─────────────────────────────────────────────────────────────────── */
header {
  background: linear-gradient(135deg, #1e40af 0%, #2563eb 100%);
  color: white;
  box-shadow: 0 2px 12px rgba(37,99,235,.3);
}
.header-inner {
  max-width: 980px;
  margin: 0 auto;
  padding: 20px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
}
.logo { display: flex; align-items: center; gap: 10px; font-size: 1.4rem; font-weight: 400; }
.logo strong { font-weight: 700; }
.tagline { font-size: .85rem; opacity: .8; }

/* ─── Tabs ───────────────────────────────────────────────────────────────────── */
.tabs-wrapper {
  background: white;
  border-bottom: 1px solid #e2e8f0;
  position: sticky;
  top: 0;
  z-index: 10;
  box-shadow: 0 1px 4px rgba(0,0,0,.06);
}
.tabs { max-width: 980px; margin: 0 auto; padding: 0 24px; display: flex; gap: 4px; }
.tab {
  display: flex; align-items: center; gap: 8px;
  padding: 14px 20px; background: none; border: none;
  border-bottom: 3px solid transparent;
  font-size: .9rem; font-weight: 500; color: #64748b; cursor: pointer; transition: all .2s;
}
.tab:hover { color: #2563eb; }
.tab.active { color: #2563eb; border-bottom-color: #2563eb; }

/* ─── Main ───────────────────────────────────────────────────────────────────── */
main { max-width: 980px; margin: 0 auto; padding: 28px 24px; }
.tab-content { display: none; flex-direction: column; gap: 20px; }
.tab-content.active { display: flex; }

/* ─── Card ───────────────────────────────────────────────────────────────────── */
.card {
  background: white;
  border-radius: 12px;
  padding: 24px;
  box-shadow: 0 1px 3px rgba(0,0,0,.08), 0 4px 16px rgba(0,0,0,.04);
  border: 1px solid #e2e8f0;
}
.card-header {
  display: flex; align-items: center; gap: 12px;
  margin-bottom: 20px; padding-bottom: 14px;
  border-bottom: 1px solid #f1f5f9;
}
.card-header h2 { font-size: 1rem; font-weight: 600; color: #0f172a; flex: 1; }
.step-badge {
  width: 26px; height: 26px; background: #2563eb; color: white;
  border-radius: 50%; display: flex; align-items: center; justify-content: center;
  font-size: .75rem; font-weight: 700; flex-shrink: 0;
}

/* ─── Credentials card ───────────────────────────────────────────────────────── */
.key-status { display: flex; align-items: center; gap: 8px; }
.btn-link {
  background: none; border: none; color: #2563eb; font-size: .78rem;
  font-weight: 500; cursor: pointer; padding: 0; text-decoration: underline;
}
.creds-footer {
  display: flex; align-items: flex-end; gap: 14px; margin-top: 4px; flex-wrap: wrap;
}

/* ─── Form ───────────────────────────────────────────────────────────────────── */
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 14px; margin-bottom: 18px; }
.form-group { display: flex; flex-direction: column; gap: 5px; }
.form-group.full-width { grid-column: 1 / -1; }
.form-group label { font-size: .78rem; font-weight: 500; color: #64748b; }
.form-group input,
.form-group select {
  padding: 8px 12px; border: 1px solid #e2e8f0; border-radius: 7px;
  font-size: .88rem; color: #1e293b; background: #f8fafc;
  transition: border-color .2s, box-shadow .2s;
}
.form-group input:focus,
.form-group select:focus {
  outline: none; border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37,99,235,.1); background: white;
}

/* ─── Buttons ────────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 9px 18px; border: none; border-radius: 8px;
  font-size: .875rem; font-weight: 500; cursor: pointer; transition: all .2s;
}
.btn-primary { background: #2563eb; color: white; }
.btn-primary:hover { background: #1d4ed8; box-shadow: 0 4px 12px rgba(37,99,235,.3); }
.btn-primary:disabled { background: #94a3b8; cursor: not-allowed; box-shadow: none; }
.btn-outline { background: white; color: #2563eb; border: 1.5px solid #2563eb; }
.btn-outline:hover { background: #eff6ff; }
.btn-stop { background: #ef4444; color: white; }
.btn-stop:hover { background: #dc2626; }
.btn-sm { padding: 6px 12px; font-size: .8rem; }

/* ─── Badge ──────────────────────────────────────────────────────────────────── */
.badge { padding: 2px 8px; border-radius: 20px; font-size: .72rem; font-weight: 600; white-space: nowrap; }
.badge-success { background: #dcfce7; color: #166534; }
.badge-error   { background: #fee2e2; color: #991b1b; }

/* ─── Live Card ──────────────────────────────────────────────────────────────── */
.live-card { padding: 0; overflow: hidden; }
.live-layout { display: grid; grid-template-columns: 240px 1fr; }

/* ─── Mic Panel ──────────────────────────────────────────────────────────────── */
.mic-panel {
  background: linear-gradient(160deg, #1e3a8a 0%, #1e40af 100%);
  padding: 24px 18px;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
}
.mic-visual {
  position: relative; width: 96px; height: 96px;
  display: flex; align-items: center; justify-content: center; margin-bottom: 2px;
}
.mic-rings { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; }
.ring { position: absolute; border-radius: 50%; border: 2px solid rgba(255,255,255,.15); opacity: 0; transition: opacity .3s; }
.ring-1 { width: 68px;  height: 68px; }
.ring-2 { width: 86px;  height: 86px; }
.ring-3 { width: 104px; height: 104px; }
.mic-visual.active .ring { opacity: 1; animation: ripple 1.5s infinite; }
.mic-visual.active .ring-1 { animation-delay: 0s; }
.mic-visual.active .ring-2 { animation-delay: .3s; }
.mic-visual.active .ring-3 { animation-delay: .6s; }
@keyframes ripple {
  0%   { transform: scale(.8); opacity: .6; }
  100% { transform: scale(1.3); opacity: 0; }
}
.mic-btn {
  width: 58px; height: 58px; border-radius: 50%; border: none;
  background: white; color: #2563eb; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  z-index: 1; box-shadow: 0 4px 16px rgba(0,0,0,.2); transition: all .2s;
}
.mic-btn:hover { transform: scale(1.06); box-shadow: 0 6px 20px rgba(0,0,0,.3); }
.mic-btn.active { background: #ef4444; color: white; }
.mic-label { font-size: .8rem; color: rgba(255,255,255,.7); font-weight: 500; margin-top: 2px; }

/* Session info in mic panel */
.session-info { width: 100%; margin: 4px 0; }
.session-row { display: flex; justify-content: space-between; align-items: center; padding: 3px 0; }
.session-key { font-size: .7rem; color: rgba(255,255,255,.4); font-weight: 500; }
.session-val { font-size: .7rem; color: rgba(255,255,255,.7); font-family: monospace; max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* file drop in mic panel */
.mic-panel .file-drop-zone {
  width: 100%; border-color: rgba(255,255,255,.2); background: rgba(255,255,255,.06); padding: 12px 8px;
}
.mic-panel .file-drop-zone p { color: rgba(255,255,255,.7); font-size: .76rem; margin-bottom: 0; }
.mic-panel .file-drop-zone:hover { border-color: rgba(255,255,255,.4); background: rgba(255,255,255,.1); }
.mic-panel .btn-outline { background: transparent; color: white; border-color: rgba(255,255,255,.35); font-size: .72rem; padding: 5px 10px; }
.mic-panel .btn-outline:hover { background: rgba(255,255,255,.1); }
.mic-panel .file-info { color: rgba(255,255,255,.8); font-size: .75rem; border-color: rgba(255,255,255,.2); background: rgba(255,255,255,.06); }
.mic-panel .btn-primary { width: 100%; justify-content: center; font-size: .8rem; }

.mic-panel .divider-or { display: flex; align-items: center; width: 100%; gap: 8px; margin: 6px 0; }
.mic-panel .divider-or::before,
.mic-panel .divider-or::after { content: ''; flex: 1; height: 1px; background: rgba(255,255,255,.15); }
.mic-panel .divider-or span { font-size: .68rem; color: rgba(255,255,255,.35); font-weight: 600; }

/* ─── Results Panel ──────────────────────────────────────────────────────────── */
.results-panel { display: flex; flex-direction: column; padding: 20px; gap: 10px; }
.results-header {
  display: flex; align-items: center; justify-content: space-between; margin-bottom: 2px;
}
.results-header h3 { display: flex; align-items: center; gap: 8px; font-size: .9rem; font-weight: 600; color: #0f172a; }
.live-dot { width: 8px; height: 8px; background: #22c55e; border-radius: 50%; animation: pulse 1s infinite; }

.result-label {
  display: flex; align-items: center; gap: 5px;
  font-size: .72rem; font-weight: 600; color: #64748b;
  text-transform: uppercase; letter-spacing: .5px; margin-top: 4px;
}
.result-box {
  min-height: 80px; max-height: 110px; overflow-y: auto;
  background: #f8fafc; border: 1px solid #e2e8f0; border-radius: 8px;
  padding: 10px 12px; font-size: .875rem; line-height: 1.7; color: #1e293b;
  white-space: pre-wrap; transition: border-color .3s;
}
.result-box.live { border-color: #86efac; background: #f0fdf4; }
.result-box .placeholder { color: #94a3b8; font-style: italic; }

.results-footer { display: flex; align-items: center; gap: 10px; margin-top: 2px; }

/* ─── SOAP ───────────────────────────────────────────────────────────────────── */
.soap-section { border-top: 1px solid #f1f5f9; padding: 20px 24px; }
.soap-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.soap-header h3 { display: flex; align-items: center; gap: 7px; font-size: .9rem; font-weight: 600; color: #0f172a; }
.soap-box {
  background: #fafafa; border: 1px solid #e2e8f0; border-radius: 8px;
  padding: 14px 16px; font-size: .875rem; line-height: 1.9; color: #1e293b; white-space: pre-wrap;
}

/* ─── Recording Indicator ────────────────────────────────────────────────────── */
.recording-indicator { display: flex; align-items: center; gap: 6px; font-size: .78rem; color: #ef4444; font-weight: 600; }
.pulse { width: 8px; height: 8px; background: #ef4444; border-radius: 50%; animation: pulse 1s infinite; }
@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%       { opacity: .5; transform: scale(.8); }
}

/* ─── Status Bar ─────────────────────────────────────────────────────────────── */
.status-bar {
  display: flex; align-items: center; gap: 8px;
  padding: 9px 14px; background: white; border-radius: 8px;
  font-size: .8rem; color: #64748b; border: 1px solid #e2e8f0;
}
.status-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.status-dot.idle    { background: #94a3b8; }
.status-dot.active  { background: #22c55e; animation: pulse 1s infinite; }
.status-dot.error   { background: #ef4444; }
.status-dot.success { background: #22c55e; }

/* ─── File Drop Zone ─────────────────────────────────────────────────────────── */
.file-drop-zone {
  border: 2px dashed #cbd5e1; border-radius: 10px; padding: 20px;
  text-align: center; cursor: pointer; transition: all .2s; background: #f8fafc;
}
.file-drop-zone:hover, .file-drop-zone.drag-over { border-color: #2563eb; background: #eff6ff; }
.file-drop-zone p { font-size: .82rem; color: #64748b; margin-bottom: 4px; }
.file-drop-zone span { font-size: .75rem; color: #94a3b8; }
.file-drop-zone .hint { font-size: .72rem; color: #94a3b8; margin-top: 6px; }
.file-info {
  display: flex; align-items: center; gap: 8px;
  margin-top: 8px; padding: 7px 10px;
  background: #f0f9ff; border: 1px solid #bae6fd;
  border-radius: 7px; font-size: .78rem; color: #0369a1;
}

/* ─── X-Ray ──────────────────────────────────────────────────────────────────── */
.xray-preview-wrap {
  position: relative; display: inline-block; margin: 16px 0 12px;
  border-radius: 8px; overflow: hidden; border: 1px solid #e2e8f0;
}
.xray-preview-wrap img { display: block; max-width: 100%; max-height: 400px; }
#xray-canvas { position: absolute; top: 0; left: 0; pointer-events: none; }
.xray-results-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; align-items: start; }
.canvas-wrap { border-radius: 8px; overflow: hidden; border: 1px solid #e2e8f0; position: relative; }
.canvas-wrap img { display: block; max-width: 100%; }
.canvas-wrap canvas { position: absolute; top: 0; left: 0; pointer-events: none; }
.findings-list { display: flex; flex-direction: column; gap: 8px; }
.finding-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 12px; border-radius: 8px; border: 1px solid #e2e8f0; background: #f8fafc;
}
.finding-name { font-size: .875rem; font-weight: 500; color: #1e293b; }
.finding-tooth { font-size: .78rem; color: #64748b; }
.finding-score { font-size: .78rem; font-weight: 600; padding: 2px 8px; border-radius: 20px; }

/* ─── Utility ────────────────────────────────────────────────────────────────── */
.hidden { display: none !important; }

/* ─── Footer ─────────────────────────────────────────────────────────────────── */
footer { text-align: center; padding: 24px; font-size: .78rem; color: #94a3b8; border-top: 1px solid #e2e8f0; margin-top: 20px; }

/* ─── Responsive ─────────────────────────────────────────────────────────────── */
@media (max-width: 680px) {
  .live-layout { grid-template-columns: 1fr; }
  .xray-results-grid { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .creds-footer { flex-direction: column; }
}
