/* Atlas Clínico — design system
   Tema escuro é o padrão. Tema claro: html[data-theme="light"] (gravado em localStorage atlas_theme).
   Mobile-first: estilos base valem pro celular; telas maiores entram por min-width. */

:root {
  color-scheme: dark;

  /* superfícies */
  --bg: #0b0f12;
  --panel: #141a1f;
  --panel-2: #10161a;
  --bg-2: #0f1418;
  --user-bubble: #1b232a;

  /* texto */
  --text: #e9eef2;
  --text-2: #c9d3db;
  --muted: #9aa7b2;
  --placeholder: #8794a0;

  /* marca */
  --accent: #5be49b;
  --accent-ink: #05140c;
  --accent-soft: rgba(91, 228, 155, .12);
  --accent-hover: #86eeb8;

  /* bordas */
  --border: #26313a;
  --border-soft: #1e272e;
  --border-strong: #5f6c78;

  /* estados */
  --ok: #5be49b;
  --ok-soft: rgba(91, 228, 155, .12);
  --warn: #f2b544;
  --warn-soft: rgba(242, 181, 68, .12);
  --danger: #ff8a80;
  --danger-soft: rgba(255, 138, 128, .12);

  --shadow: 0 10px 30px rgba(0, 0, 0, .45);
  --overlay: rgba(0, 0, 0, .6);

  /* espaçamento */
  --s1: 4px;
  --s2: 8px;
  --s3: 12px;
  --s4: 16px;
  --s5: 20px;
  --s6: 24px;
  --s8: 32px;
  --s10: 40px;
  --s12: 48px;

  /* raios */
  --r-sm: 8px;
  --r: 12px;
  --r-lg: 16px;
  --r-full: 999px;

  --tap: 44px;

  --font: "Instrument Sans", system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: "DM Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --t: 160ms ease;
}

/* ---------------------------------------------------------- tema claro */
html[data-theme="light"] {
  color-scheme: light;

  --bg: #f6f7f9;
  --panel: #ffffff;
  --panel-2: #f1f4f8;
  --bg-2: #ffffff;
  --user-bubble: #e8eef8;

  --text: #10233f;
  --text-2: #33465f;
  --muted: #55657a;
  --placeholder: #5e6d80;

  --accent: #1f5bd6;
  --accent-ink: #ffffff;
  --accent-soft: #eef3fd;
  --accent-hover: #16449f;

  --border: #dce2ea;
  --border-soft: #e8ecf2;
  --border-strong: #7d8a9c;

  --ok: #17704b;
  --ok-soft: #e7f4ee;
  --warn: #8a4b0f;
  --warn-soft: #fff4e5;
  --danger: #b42318;
  --danger-soft: #fdedec;

  --shadow: 0 10px 30px rgba(16, 35, 63, .08);
  --overlay: rgba(16, 35, 63, .4);
}

/* ---------------------------------------------------------- base */

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, p, ul, ol, figure { margin: 0; }
ul, ol { padding: 0; }
a { color: inherit; text-decoration: none; }

button {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
}

svg { display: block; }

::selection { background: var(--accent); color: var(--accent-ink); }

/* ---------------------------------------------------------- texto utilitário */

.mono { font-family: var(--mono); }

.eyebrow {
  font-family: var(--mono);
  font-size: 12px;
  line-height: 16px;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--muted);
}

.text-muted { color: var(--muted); }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* ---------------------------------------------------------- botões */

.btn-primary,
.btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s2);
  min-height: var(--tap);
  padding: 0 var(--s5);
  border-radius: 10px;
  font-size: 15px;
  font-weight: 600;
  line-height: 1.2;
  white-space: nowrap;
  transition: background var(--t), color var(--t), border-color var(--t);
}

.btn-primary {
  background: var(--accent);
  color: var(--accent-ink);
  border: 1px solid var(--accent);
}
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-primary:disabled { opacity: .65; cursor: progress; }

.btn-secondary {
  background: transparent;
  border: 1px solid var(--border-strong);
  color: var(--text);
}
.btn-secondary:hover { border-color: var(--accent); color: var(--accent); }

.btn-lg {
  min-height: 52px;
  padding: 0 var(--s6);
  border-radius: var(--r);
  font-size: 17px;
}

.btn-primary:focus-visible,
.btn-secondary:focus-visible,
a:focus-visible,
button:focus-visible,
summary:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ---------------------------------------------------------- cartões */

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--s5);
}

/* ---------------------------------------------------------- campos */

.field { display: flex; flex-direction: column; gap: 6px; }

.label {
  font-size: 14px;
  line-height: 18px;
  font-weight: 600;
  color: var(--text);
}
.label-hint { font-weight: 400; color: var(--muted); }

.input {
  width: 100%;
  min-height: 48px;
  background: var(--panel-2);
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  padding: 0 14px;
  color: var(--text);
  font: inherit;
  font-size: 16px;
  transition: border-color var(--t), box-shadow var(--t);
}
textarea.input { padding: 12px 14px; line-height: 1.45; resize: vertical; }
select.input {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 40px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%238794a0' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
}
.input::placeholder { color: var(--placeholder); }
.input:focus {
  outline: 0;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

/* ---------------------------------------------------------- selos */

.badge,
.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 13px;
  line-height: 18px;
  font-weight: 600;
  padding: 4px 12px;
  border-radius: var(--r-full);
}
.pill { font-weight: 500; }

/* ---------------------------------------------------------- toggle de tema */

.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--tap);
  height: var(--tap);
  flex-shrink: 0;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  cursor: pointer;
  transition: color var(--t), border-color var(--t), background var(--t);
}
.theme-toggle:hover { color: var(--accent); border-color: var(--accent); }

/* ---------------------------------------------------------- layout */

.container {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 var(--s4);
}

/* ---------------------------------------------------------- marca */

.logo,
.auth-logo {
  display: inline-flex;
  align-items: center;
  font-size: 20px;
  line-height: 26px;
  font-weight: 700;
  letter-spacing: -.02em;
  white-space: nowrap;
  color: var(--text);
}
.logo sup,
.auth-logo sup {
  font-family: var(--mono);
  font-size: 12px;
  line-height: 0;
  font-weight: 500;
  margin-left: 2px;
  color: var(--accent);
  align-self: flex-start;
  margin-top: 6px;
}

/* ---------------------------------------------------------- ajustes do chat no tema claro
   (o chat.css usa tokens; estas regras cobrem superfícies que ele pinta direto) */
html[data-theme="light"] .toast { background: var(--panel); box-shadow: var(--shadow); }
html[data-theme="light"] #overlay { background: var(--overlay); }
html[data-theme="light"] .modal-overlay { background: var(--overlay); }
html[data-theme="light"] #sidebar { background: var(--panel); }
html[data-theme="light"] #btnNova { color: var(--accent); }
html[data-theme="light"] .chip-cmd:hover { color: var(--accent); }
html[data-theme="light"] .msg-user .msg-bubble { background: var(--user-bubble); }

/* ---------------------------------------------------------- scrollbar */

* { scrollbar-width: thin; scrollbar-color: var(--border) transparent; }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: var(--r-full); }
::-webkit-scrollbar-thumb:hover { background: var(--border-strong); }

/* ---------------------------------------------------------- telas maiores */

@media (min-width: 768px) {
  .container { padding: 0 var(--s6); }
  .card { padding: var(--s6); }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { transition-duration: 1ms !important; animation-duration: 1ms !important; }
}
