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

:root {
  --font: 'Inter', system-ui, -apple-system, sans-serif;

  /* Neutrals */
  --gray-50:  #f8fafc;
  --gray-100: #f1f5f9;
  --gray-200: #e2e8f0;
  --gray-300: #cbd5e1;
  --gray-400: #94a3b8;
  --gray-500: #64748b;
  --gray-600: #475569;
  --gray-700: #334155;
  --gray-800: #1e293b;
  --gray-900: #0f172a;

  /* Brand */
  --brand-50:  #eff6ff;
  --brand-100: #dbeafe;
  --brand-200: #bfdbfe;
  --brand-500: #3b82f6;
  --brand-600: #2563eb;
  --brand-700: #1d4ed8;
  --brand-900: #1e3a5f;

  /* Accent teal */
  --teal-500: #14b8a6;
  --teal-600: #0d9488;

  /* Danger */
  --red-500: #ef4444;
  --red-600: #dc2626;
  --red-50:  #fef2f2;

  /* Success */
  --green-50:  #f0fdf4;
  --green-500: #22c55e;
  --green-700: #15803d;

  /* Warning */
  --amber-50:  #fffbeb;
  --amber-500: #f59e0b;
  --amber-700: #b45309;

  /* Layout */
  --sidebar-w: 220px;
  --topbar-h: 72px;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 18px;

  /* Shadows */
  --shadow-xs: 0 1px 2px 0 rgb(0 0 0 / .05);
  --shadow-sm: 0 1px 3px 0 rgb(0 0 0 / .1), 0 1px 2px -1px rgb(0 0 0 / .1);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / .1), 0 2px 4px -2px rgb(0 0 0 / .1);
}

html { font-family: var(--font); font-size: 14px; color: var(--gray-800); background: var(--gray-100); -webkit-font-smoothing: antialiased; }
body { min-height: 100vh; }

/* ─── App layout ─────────────────────────────────────────────────────────── */
.app-layout {
  display: flex;
  min-height: 100vh;
}

/* ─── Sidebar ────────────────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--gray-900);
  display: flex;
  flex-direction: column;
  padding: 0;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 18px 18px;
  border-bottom: 1px solid rgb(255 255 255 / .07);
}

.brand-icon {
  width: 34px; height: 34px;
  background: var(--brand-600);
  border-radius: var(--radius-md);
  display: flex; align-items: center; justify-content: center;
  color: white;
  flex-shrink: 0;
}

.brand-name {
  display: block;
  font-size: 14px;
  font-weight: 700;
  color: white;
  letter-spacing: -.01em;
}

.brand-sub {
  display: block;
  font-size: 11px;
  color: var(--gray-500);
  margin-top: 1px;
}

.sidebar-nav {
  flex: 1;
  padding: 16px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-section-label {
  display: block;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--gray-600);
  padding: 0 8px;
  margin-bottom: 6px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 10px;
  border-radius: var(--radius-md);
  color: var(--gray-400);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  transition: background .15s, color .15s;
}

.nav-item:hover {
  background: rgb(255 255 255 / .06);
  color: var(--gray-200);
}

.nav-item.active {
  background: rgb(59 130 246 / .15);
  color: var(--brand-200);
}

.sidebar-footer {
  padding: 14px 14px 18px;
  border-top: 1px solid rgb(255 255 255 / .07);
}

.disclaimer-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgb(239 68 68 / .12);
  color: #fca5a5;
  border: 1px solid rgb(239 68 68 / .2);
  border-radius: var(--radius-md);
  padding: 7px 10px;
  font-size: 11px;
  font-weight: 600;
  line-height: 1.3;
}

.sidebar-version {
  font-size: 10px;
  color: var(--gray-600);
  margin-top: 10px;
  padding: 0 2px;
}

/* ─── Main content ───────────────────────────────────────────────────────── */
.main-content {
  flex: 1;
  margin-left: var(--sidebar-w);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ─── Topbar ─────────────────────────────────────────────────────────────── */
.topbar {
  height: var(--topbar-h);
  background: white;
  border-bottom: 1px solid var(--gray-200);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  position: sticky;
  top: 0;
  z-index: 50;
}

.page-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--gray-900);
  letter-spacing: -.02em;
}

.page-subtitle {
  display: block;
  font-size: 12px;
  color: var(--gray-500);
  margin-top: 2px;
  font-weight: 400;
}

.rec-indicator {
  display: flex;
  align-items: center;
  gap: 7px;
  background: var(--red-50);
  border: 1px solid #fecaca;
  color: var(--red-600);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 600;
}

.rec-indicator.hidden { display: none; }

.rec-dot {
  width: 8px; height: 8px;
  background: var(--red-500);
  border-radius: 50%;
  animation: pulse-dot 1.2s ease-in-out infinite;
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: .5; transform: scale(.8); }
}

/* ─── Content grid ───────────────────────────────────────────────────────── */
.content-grid {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 20px;
  padding: 24px 28px;
  align-items: start;
}

/* ─── Panels ─────────────────────────────────────────────────────────────── */
.panel {
  background: white;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-xl);
  overflow: hidden;
  box-shadow: var(--shadow-xs);
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 22px;
  border-bottom: 1px solid var(--gray-100);
}

.panel-label {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--gray-500);
}

/* Status tags */
.status-tag {
  font-size: 11px;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 999px;
}

.status-idle {
  background: var(--gray-100);
  color: var(--gray-500);
}

.status-active {
  background: #dcfce7;
  color: var(--green-700);
}

.status-recording {
  background: var(--red-50);
  color: var(--red-600);
}

/* ─── Camera panel ───────────────────────────────────────────────────────── */
.video-wrapper {
  position: relative;
  background: var(--gray-900);
  aspect-ratio: 16/9;
}

#preview {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.video-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: var(--gray-600);
  font-size: 13px;
  font-weight: 500;
  background: var(--gray-900);
  transition: opacity .3s;
}

.video-overlay.hidden { opacity: 0; pointer-events: none; }

.camera-controls {
  display: flex;
  gap: 10px;
  padding: 14px 18px;
  border-top: 1px solid var(--gray-100);
  flex-wrap: wrap;
}

/* ─── Buttons ────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 16px;
  border-radius: var(--radius-md);
  font-family: var(--font);
  font-size: 13px;
  font-weight: 600;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background .15s, box-shadow .15s, opacity .15s;
  white-space: nowrap;
}

.btn:disabled {
  opacity: .38;
  cursor: not-allowed;
  pointer-events: none;
}

.btn-primary {
  background: var(--brand-600);
  color: white;
  border-color: var(--brand-700);
  box-shadow: 0 1px 2px rgb(37 99 235 / .3);
}

.btn-primary:hover { background: var(--brand-700); }

.btn-danger {
  background: var(--red-500);
  color: white;
  border-color: var(--red-600);
  box-shadow: 0 1px 2px rgb(239 68 68 / .3);
}

.btn-danger:hover { background: var(--red-600); }

.btn-outline {
  background: white;
  color: var(--gray-700);
  border-color: var(--gray-300);
}

.btn-outline:hover { background: var(--gray-50); }

/* ─── Config panel ───────────────────────────────────────────────────────── */
.config-panel {
  display: flex;
  flex-direction: column;
}

.config-panel .panel-header {
  flex-shrink: 0;
}

.field-group {
  padding: 14px 18px 0;
}

.field-group:last-of-type {
  padding-bottom: 0;
}

.field-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--gray-700);
  margin-bottom: 6px;
}

.field-input {
  width: 100%;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-md);
  padding: 8px 12px;
  font-family: var(--font);
  font-size: 13px;
  color: var(--gray-800);
  background: var(--gray-50);
  transition: border-color .15s, box-shadow .15s;
  outline: none;
}

.field-input:focus {
  border-color: var(--brand-500);
  box-shadow: 0 0 0 3px rgb(59 130 246 / .12);
  background: white;
}

.field-textarea {
  min-height: 100px;
  resize: vertical;
  line-height: 1.55;
}

.suggestions-box {
  margin: 14px 18px 18px;
  background: var(--gray-50);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-lg);
  padding: 12px 14px;
}

.suggestions-header {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--gray-500);
  margin-bottom: 10px;
}

.suggestions-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.suggestions-list li {
  font-size: 12.5px;
  color: var(--gray-600);
  padding-left: 14px;
  position: relative;
  line-height: 1.4;
}

.suggestions-list li::before {
  content: '';
  position: absolute;
  left: 0;
  top: 7px;
  width: 5px; height: 5px;
  background: var(--brand-500);
  border-radius: 50%;
}

/* ─── Result section (removida — resultado agora fica no main-slot) ──────── */

/* ─── Main slot ──────────────────────────────────────────────────────────── */
.main-slot {
  display: contents; /* passa o filho direto para o grid */
}

.main-slot > .panel {
  min-height: 0;
}

.panel.hidden {
  display: none;
}

/* Result panel dentro do slot */
.result-panel-wrap {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  /* mesma altura mínima do painel de câmera (aspect-ratio 16/9 + header + controls) */
  min-height: 480px;
}

.result-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 24px 28px 28px;
}

/* Conteúdo interno do resultado */
.result-inner {
  /* sem estilo próprio — herda do pai */
}

.result-inner.result-panel {
  border-radius: var(--radius-lg);
  padding: 16px 18px;
}

.btn-sm {
  padding: 5px 11px;
  font-size: 12px;
}

/* Result panel states */
.result-panel {
  background: white;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-xl);
  padding: 24px;
  box-shadow: var(--shadow-xs);
}

.result-panel.info {
  border-color: var(--brand-200);
  background: var(--brand-50);
  color: var(--brand-700);
}

.result-panel.error {
  border-color: #fecaca;
  background: var(--red-50);
  color: var(--red-600);
}

.result-empty {
  display: flex;
  align-items: center;
  gap: 12px;
  border: 1px dashed var(--gray-300);
  border-radius: var(--radius-xl);
  padding: 28px 24px;
  color: var(--gray-400);
  font-size: 13px;
}

/* Result content */
.result-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 0;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--gray-100);
}

.result-kicker {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--gray-400);
  display: block;
  margin-bottom: 6px;
}

.result-header h3 {
  font-size: 24px;
  font-weight: 700;
  color: var(--gray-900);
  letter-spacing: -.02em;
  text-transform: capitalize;
  line-height: 1.2;
}

.status-pill {
  border-radius: 999px;
  padding: 5px 12px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  flex-shrink: 0;
}

.status-pill.ok {
  background: var(--green-50);
  color: var(--green-700);
  border: 1px solid #bbf7d0;
}

.status-pill.warning {
  background: var(--amber-50);
  color: var(--amber-700);
  border: 1px solid #fde68a;
}

.result-alert {
  background: var(--amber-50);
  border: 1px solid #fde68a;
  border-radius: var(--radius-lg);
  padding: 14px 16px;
  margin-bottom: 20px;
  font-size: 13px;
}

.result-alert strong {
  display: block;
  margin-bottom: 6px;
  color: var(--amber-700);
}

.result-alert ul {
  padding-left: 18px;
  color: var(--gray-700);
  margin-top: 6px;
}

.result-alert li { margin-top: 4px; }

.result-body-section {
  margin-top: 20px;
  padding-top: 20px;
  border-top: 1px solid var(--gray-100);
}

.result-body-section:first-of-type {
  border-top: none;
  padding-top: 0;
}

.result-body-section h4 {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--gray-400);
  margin-bottom: 10px;
}

.result-body-section p {
  font-size: 13.5px;
  line-height: 1.65;
  color: var(--gray-700);
}

.result-body-section ul {
  padding-left: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.result-body-section li {
  font-size: 13.5px;
  line-height: 1.55;
  color: var(--gray-700);
  padding-left: 16px;
  position: relative;
}

.result-body-section li::before {
  content: '';
  position: absolute;
  left: 0;
  top: 8px;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--gray-300);
  flex-shrink: 0;
}

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-top: 20px;
  padding-top: 20px;
  border-top: 1px solid var(--gray-100);
}

.metric {
  background: var(--gray-50);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-lg);
  padding: 12px 14px;
}

.metric span {
  display: block;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--gray-400);
  margin-bottom: 6px;
}

.metric strong {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--gray-800);
  overflow-wrap: anywhere;
  line-height: 1.4;
}

details {
  margin-top: 20px;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

summary {
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  color: var(--gray-600);
  padding: 10px 14px;
  background: var(--gray-50);
  user-select: none;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 6px;
}

summary::-webkit-details-marker { display: none; }

summary::before {
  content: '▶';
  font-size: 9px;
  transition: transform .2s;
}

details[open] summary::before { transform: rotate(90deg); }

pre {
  white-space: pre-wrap;
  background: var(--gray-900);
  color: #93c5fd;
  padding: 16px;
  font-size: 12px;
  line-height: 1.6;
  overflow: auto;
  max-height: 400px;
}

/* ─── Responsive ─────────────────────────────────────────────────────────── */
@media (max-width: 960px) {
  .content-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 720px) {
  .sidebar { display: none; }
  .main-content { margin-left: 0; }
  .content-grid, .result-section { padding-left: 16px; padding-right: 16px; }
  .topbar { padding: 0 16px; }
  .metrics-grid { grid-template-columns: 1fr 1fr; }
}

/* ─── Panel header actions ───────────────────────────────────────────────── */
.panel-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ─── Topbar right gap ───────────────────────────────────────────────────── */
.topbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* ─── Modal ──────────────────────────────────────────────────────────────── */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgb(0 0 0 / .5);
  backdrop-filter: blur(3px);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-backdrop.hidden {
  display: none;
}

.modal {
  background: white;
  border-radius: var(--radius-xl);
  width: 100%;
  max-width: 620px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 24px 48px rgb(0 0 0 / .18);
  overflow: hidden;
}

.modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 24px 24px 20px;
  border-bottom: 1px solid var(--gray-100);
  flex-shrink: 0;
}

.modal-title {
  font-size: 17px;
  font-weight: 700;
  color: var(--gray-900);
  letter-spacing: -.02em;
}

.modal-subtitle {
  font-size: 13px;
  color: var(--gray-500);
  margin-top: 3px;
}

.modal-close {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--gray-400);
  padding: 4px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: color .15s, background .15s;
}

.modal-close:hover {
  color: var(--gray-700);
  background: var(--gray-100);
}

.modal-body {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--gray-100);
  display: flex;
  justify-content: flex-end;
  flex-shrink: 0;
}

/* ─── Tutorial disclaimer ────────────────────────────────────────────────── */
.tutorial-disclaimer {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  background: var(--amber-50);
  border: 1px solid #fde68a;
  border-radius: var(--radius-lg);
  padding: 12px 14px;
  font-size: 13px;
  color: var(--amber-700);
  line-height: 1.5;
}

.tutorial-disclaimer svg {
  flex-shrink: 0;
  margin-top: 1px;
}

/* ─── Tutorial steps ─────────────────────────────────────────────────────── */
.tutorial-steps {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.tutorial-step {
  display: flex;
  gap: 16px;
  padding: 16px 0;
  border-bottom: 1px solid var(--gray-100);
}

.tutorial-step:first-child { padding-top: 0; }
.tutorial-step:last-child  { border-bottom: none; padding-bottom: 0; }

.step-number {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--brand-600);
  color: white;
  font-size: 12px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 1px;
}

.step-content h3 {
  font-size: 14px;
  font-weight: 700;
  color: var(--gray-900);
  margin-bottom: 5px;
  letter-spacing: -.01em;
}

.step-content p {
  font-size: 13px;
  color: var(--gray-600);
  line-height: 1.6;
}

.step-content strong {
  color: var(--gray-800);
  font-weight: 600;
}

/* ─── Tutorial tips ──────────────────────────────────────────────────────── */
.tutorial-tips {
  background: var(--gray-50);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-lg);
  padding: 16px 18px;
}

.tutorial-tips h4 {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--gray-500);
  margin-bottom: 12px;
}

.tutorial-tips ul {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.tutorial-tips li {
  font-size: 13px;
  color: var(--gray-600);
  padding-left: 16px;
  position: relative;
  line-height: 1.5;
}

.tutorial-tips li::before {
  content: '';
  position: absolute;
  left: 0;
  top: 7px;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--brand-500);
}

/* ─── Responsive modal ───────────────────────────────────────────────────── */
@media (max-width: 640px) {
  .modal { max-height: 100vh; border-radius: 0; }
  .modal-backdrop { padding: 0; align-items: flex-end; }
}

/* ─── Seção Alzheimer / MCI ──────────────────────────────────────────────── */
.alzheimer-section {
  background: #faf5ff;
  border: 1px solid #e9d5ff;
  border-radius: var(--radius-lg);
  padding: 14px 16px;
  margin-top: 20px;
}

.alzheimer-section h4 {
  display: flex;
  align-items: center;
  gap: 6px;
  color: #7c3aed;
  border-top: none;
  padding-top: 0;
  margin-bottom: 8px;
}

.alzheimer-note {
  font-size: 13.5px;
  line-height: 1.65;
  color: #4c1d95;
}

.alzheimer-indicators {
  margin-top: 10px;
  padding-left: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.alzheimer-indicators li {
  font-size: 13px;
  color: #5b21b6;
  padding-left: 16px;
  position: relative;
  line-height: 1.5;
}

.alzheimer-indicators li::before {
  content: '';
  position: absolute;
  left: 0;
  top: 7px;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #7c3aed;
}
