/* =========================================================
   base.css — identidade visual da Agenda Clínicas
   (mesma linguagem visual do sistema de referência, com a
   paleta verde da Agenda Clínicas)

   Princípios: calma e respiro · cartões brancos sem contorno,
   só com sombra · cantos de 24 px nos cartões · botões em
   pílula · Literata nos títulos, Manrope nos textos · uma ação
   principal por área · movimentos suaves.

   Para mudar o visual inteiro, mude os tokens abaixo.
   ========================================================= */

/* ---------- fontes (OFL, auto-hospedadas em /fonts) ---------- */
@font-face { font-family: 'Manrope'; font-style: normal; font-weight: 400; font-display: swap; src: url('/fonts/manrope-latin-400-normal.woff2') format('woff2'); }
@font-face { font-family: 'Manrope'; font-style: normal; font-weight: 500; font-display: swap; src: url('/fonts/manrope-latin-500-normal.woff2') format('woff2'); }
@font-face { font-family: 'Manrope'; font-style: normal; font-weight: 600; font-display: swap; src: url('/fonts/manrope-latin-600-normal.woff2') format('woff2'); }
@font-face { font-family: 'Manrope'; font-style: normal; font-weight: 700; font-display: swap; src: url('/fonts/manrope-latin-700-normal.woff2') format('woff2'); }
@font-face { font-family: 'Literata'; font-style: normal; font-weight: 400; font-display: swap; src: url('/fonts/literata-latin-400-normal.woff2') format('woff2'); }
@font-face { font-family: 'Literata'; font-style: normal; font-weight: 500; font-display: swap; src: url('/fonts/literata-latin-500-normal.woff2') format('woff2'); }
@font-face { font-family: 'Literata'; font-style: normal; font-weight: 600; font-display: swap; src: url('/fonts/literata-latin-600-normal.woff2') format('woff2'); }
@font-face { font-family: 'Literata'; font-style: italic; font-weight: 500; font-display: swap; src: url('/fonts/literata-latin-500-italic.woff2') format('woff2'); }

/* ---------- tokens ---------- */
:root {
  /* paleta verde da Agenda Clínicas */
  --brand-deep: #0a3a36;      /* faixas escuras, títulos */
  --brand-green: #0f766e;     /* principal */
  --brand-green-2: #0b5d57;   /* hover do principal */
  --brand-mint: #cdebe5;      /* claro, sobre fundos escuros */
  --brand-gold: #f59e0b;      /* só detalhes: marcador ativo, selo "Novo", ponto do símbolo */

  --background: #f4f5f3;
  --foreground: #1b2321;
  --heading: #0a3a36;
  --card: #ffffff;
  --primary: #0f766e;
  --primary-foreground: #ffffff;
  --primary-hover: #0b5d57;
  --secondary: #e3f1ee;         /* fundo do item ativo, botão secundário */
  --secondary-foreground: #0a3a36;
  --muted: #eef1ee;
  --muted-foreground: #5d6866;
  --accent: #edf6f4;            /* hover suave */
  --destructive: #b42318;
  --warning: #8a5a00;
  --warning-soft: #fff4df;
  --success: #0b6b4f;
  --success-soft: #e4f4ec;
  --info: #0f766e;
  --info-soft: #e3f1ee;
  --border: #e3e8e5;
  --input: #d3ddd9;
  --ring: #0b5d57;
  --overlay: rgb(8 30 28 / 0.32);

  --font-sans: 'Manrope', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-display: 'Literata', Georgia, 'Times New Roman', serif;

  --r-card: 24px;    /* cartões de primeiro nível */
  --r-modal: 16px;   /* janelas */
  --r-campo: 12px;   /* campos */
  --r-item: 12px;    /* itens de menu */

  --shadow-soft: 0 1px 2px rgb(8 46 42 / 0.04), 0 6px 20px -12px rgb(8 46 42 / 0.14);
  --shadow-float: 0 2px 6px rgb(8 46 42 / 0.06), 0 16px 40px -12px rgb(8 46 42 / 0.24);

  --ease-soft: cubic-bezier(0.28, 0.11, 0.32, 1);
  --ease-soft-in-out: cubic-bezier(0.4, 0, 0.6, 1);

  /* fundo "Luz": grão fino de papel + manchas de luz quase imperceptíveis */
  --texture-grain: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220'%3E%3Cfilter id='g'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0.04 0 0 0 0 0.36 0 0 0 0 0.33 0 0 0 0.3 -0.12'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23g)'/%3E%3C/svg%3E");
  --texture-light:
    radial-gradient(55rem 38rem at 0% 0%, rgb(205 235 229 / 0.7), transparent 70%),
    radial-gradient(45rem 32rem at 100% 0%, rgb(245 158 11 / 0.1), transparent 70%),
    radial-gradient(55rem 40rem at 100% 100%, rgb(15 118 110 / 0.08), transparent 70%);
}

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { background: var(--background); -webkit-text-size-adjust: 100%; }
body {
  margin: 0; color: var(--foreground); font-family: var(--font-sans); font-size: 15px; line-height: 1.5;
  text-rendering: optimizeLegibility; -webkit-font-smoothing: antialiased;
}
body::before { content: ''; position: fixed; inset: 0; z-index: -1; pointer-events: none; background-image: var(--texture-grain), var(--texture-light); }
h1, h2, h3 { font-family: var(--font-display); font-weight: 500; letter-spacing: -0.01em; color: var(--heading); text-wrap: balance; line-height: 1.2; }
h1 { font-size: 32px; margin: 0 0 4px; }
h2 { font-size: 24px; margin: 0 0 4px; }
h3 { font-size: 18px; margin: 0; }
h4 { margin: 0; text-wrap: balance; }
p, li, dd, label, figcaption { text-wrap: pretty; }
a { color: var(--primary); }
::selection { background: var(--brand-mint); color: var(--brand-deep); }
:focus-visible { outline: 2px solid color-mix(in srgb, var(--ring) 50%, transparent); outline-offset: 2px; }
.sub { color: var(--muted-foreground); margin: 0 0 20px; font-size: 15px; }
.vazio { color: var(--muted-foreground); }
.flex1 { flex: 1; }
.ico { flex: none; display: block; }
.font-display { font-family: var(--font-display); }

/* ---------- botões (pílula) ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 40px; padding: 0 20px;
  border: 1px solid transparent; border-radius: 999px; background: var(--primary); color: var(--primary-foreground);
  font: 600 14px/1 var(--font-sans); white-space: nowrap; cursor: pointer; text-decoration: none; box-shadow: var(--shadow-soft);
  transition: color .2s var(--ease-soft-in-out), background-color .2s var(--ease-soft-in-out), border-color .2s var(--ease-soft-in-out), box-shadow .2s var(--ease-soft-in-out), transform .2s var(--ease-soft-in-out);
}
.btn:hover { background: var(--primary-hover); }
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: .5; pointer-events: none; }
.btn:focus-visible { outline: none; box-shadow: 0 0 0 3px color-mix(in srgb, var(--ring) 35%, transparent); }
.btn .ico { width: 16px; height: 16px; transition: transform .2s var(--ease-soft); }
.btn:hover .ico-seta, .btn:hover .ico-direita { transform: translateX(2px); }
.btn:hover .ico-esquerda { transform: translateX(-2px); }
.btn:hover .ico-externo { transform: translate(2px, -2px); }
.btn-ghost { background: var(--card); color: var(--primary); border-color: var(--input); box-shadow: none; }       /* "outline" */
.btn-ghost:hover { background: var(--accent); }
.btn-sec { background: var(--secondary); color: var(--secondary-foreground); box-shadow: none; }
.btn-sec:hover { background: color-mix(in srgb, var(--secondary) 70%, #fff); }
.btn-link { background: none; border: 0; box-shadow: none; color: var(--primary); height: auto; padding: 2px 4px; text-decoration: underline; text-underline-offset: 4px; }
.btn-link:hover { background: none; color: var(--primary-hover); }
.btn-perigo { background: var(--card); color: var(--destructive); border-color: #f1c9c4; box-shadow: none; }
.btn-perigo:hover { background: #fdf1ef; }
.btn-sm { height: 36px; padding: 0 16px; font-size: 13px; }
.btn-lg { height: 48px; padding: 0 28px; font-size: 15px; }
.btn-icone { width: 40px; padding: 0; }
.btn-sm.btn-icone { width: 36px; }
.btn-wpp { background: #25d366; color: #fff; }
.btn-wpp:hover { background: #1ebe5b; }
/* botão só com ícone, redondo e discreto (fechar, remover) */
.x {
  display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px; padding: 0; flex: none;
  border: 0; border-radius: 999px; background: none; color: var(--muted-foreground); font-size: 20px; line-height: 1; cursor: pointer;
  transition: background-color .2s, color .2s;
}
.x:hover { background: var(--accent); color: var(--destructive); }
.chip {
  height: 36px; padding: 0 16px; border: 1px solid var(--input); border-radius: 999px; background: var(--card); color: var(--muted-foreground);
  font: 600 13px var(--font-sans); cursor: pointer; transition: background-color .2s, color .2s, border-color .2s;
}
.chip:hover { background: var(--accent); color: var(--primary); }
.chip.on { background: var(--secondary); border-color: transparent; color: var(--primary); }

/* ---------- campos ---------- */
label { display: flex; flex-direction: column; gap: 6px; font-weight: 600; font-size: 13px; color: var(--foreground); }
input, select, textarea {
  font: 400 14px var(--font-sans); color: var(--foreground); background: var(--card);
  border: 1px solid var(--input); border-radius: var(--r-campo); padding: 0 16px; height: 44px; width: 100%; min-width: 0;
  transition: border-color .2s, box-shadow .2s;
}
textarea { height: auto; padding: 12px 16px; line-height: 1.5; resize: vertical; }
select { 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='%235d6866' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 14px center; }
input::placeholder, textarea::placeholder { color: var(--muted-foreground); opacity: .8; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--ring); box-shadow: 0 0 0 4px color-mix(in srgb, var(--ring) 18%, transparent); }
input[type=checkbox], input[type=radio] { width: 18px; height: 18px; padding: 0; flex: none; accent-color: var(--primary); border-radius: 6px; box-shadow: none; }
input[type=color] { width: 72px; height: 44px; padding: 4px; cursor: pointer; }
input[type=file] { height: auto; padding: 8px; }
label.check { flex-direction: row; align-items: center; gap: 10px; font-weight: 500; font-size: 14px; }
label.btn { flex-direction: row; gap: 8px; font-size: 14px; font-weight: 600; color: var(--primary); }
label.btn.btn-sm { font-size: 13px; }

/* ---------- cartões ---------- */
.cartao, .painel { background: var(--card); border-radius: var(--r-card); box-shadow: var(--shadow-soft); padding: 32px; }
.painel + .painel, .cartao + .cartao { margin-top: 16px; }
.painel > h1, .painel h1 { font-size: 24px; }

/* ---------- selos ---------- */
.tag {
  display: inline-flex; align-items: center; gap: 4px; padding: 2px 10px; border-radius: 999px; white-space: nowrap;
  font-size: 12px; font-weight: 600; background: var(--muted); color: var(--muted-foreground);
}
.tag-ok { background: var(--success-soft); color: var(--success); }
.tag-alerta { background: var(--warning-soft); color: var(--warning); }
.tag-aviso { background: var(--warning-soft); color: var(--warning); }
.tag-info { background: var(--info-soft); color: var(--info); }
.tag-novo { background: var(--brand-gold); color: var(--brand-deep); }
.tag-bloq { background: var(--brand-deep); color: #fff; }

/* ---------- janelas (dialog) ---------- */
dialog {
  border: 1px solid var(--border); border-radius: var(--r-modal); padding: 0; width: min(760px, calc(100% - 32px)); max-height: calc(100dvh - 48px);
  background: var(--card); color: var(--foreground); box-shadow: var(--shadow-float);
}
dialog[open] { animation: abrir .26s var(--ease-soft); }
dialog::backdrop { background: var(--overlay); animation: esmaecer .26s var(--ease-soft); }
@keyframes abrir { from { opacity: 0; transform: translateY(8px) scale(.97); } to { opacity: 1; transform: none; } }
@keyframes esmaecer { from { opacity: 0; } to { opacity: 1; } }
.dlg-cab, .dlg-rod { display: flex; align-items: center; gap: 10px; padding: 22px 28px; }
.dlg-cab { padding-bottom: 6px; }
.dlg-cab h2 { margin: 0; flex: 1; font-size: 22px; }
.dlg-rod { padding-top: 16px; border-top: 1px solid var(--border); }
.dlg-corpo { padding: 16px 28px 24px; overflow: auto; }

/* ---------- balão (tooltip) ----------
   Use data-dica="Nome" em botões só com ícone (junto com aria-label). */
[data-dica] { position: relative; }
[data-dica]::after {
  content: attr(data-dica); position: absolute; z-index: 60; pointer-events: none; white-space: nowrap;
  background: var(--brand-deep); color: #fff; font: 600 12px/1.2 var(--font-sans); padding: 7px 11px; border-radius: 8px; box-shadow: var(--shadow-float);
  opacity: 0; transform: scale(.97); transition: opacity .18s var(--ease-soft-in-out), transform .18s var(--ease-soft-in-out);
  left: calc(100% + 12px); top: 50%; translate: 0 -50%;
}
[data-dica-lado="baixo"]::after { left: 50%; top: calc(100% + 8px); translate: -50% 0; }
[data-dica-lado="cima"]::after { left: 50%; top: auto; bottom: calc(100% + 8px); translate: -50% 0; }
[data-dica]:hover::after, [data-dica]:focus-visible::after { opacity: 1; transform: none; transition-duration: .26s; transition-timing-function: var(--ease-soft); }

/* ---------- "i" de informação ---------- */
.info-tip {
  display: inline-flex; align-items: center; justify-content: center; width: 24px; height: 24px; border: 0; padding: 0; margin-left: 4px;
  border-radius: 999px; background: none; color: var(--muted-foreground); cursor: help; vertical-align: middle; transition: background-color .2s, color .2s;
}
.info-tip:hover, .info-tip:focus-visible { background: var(--accent); color: var(--primary); }
.info-tip[data-dica]::after { white-space: normal; width: 260px; font-weight: 500; line-height: 1.45; background: var(--card); color: var(--foreground); border: 1px solid var(--border); left: 50%; top: calc(100% + 8px); translate: -50% 0; padding: 12px 14px; }

/* ---------- círculo de ícone (degradê verde) ---------- */
.icone-circulo {
  display: inline-flex; align-items: center; justify-content: center; flex: none; width: 40px; height: 40px; border-radius: 999px;
  background: linear-gradient(135deg, var(--brand-green), var(--brand-deep)); color: #fff; box-shadow: var(--shadow-soft), inset 0 0 0 1px rgb(255 255 255 / .2);
}
.icone-circulo .ico { width: 18px; height: 18px; }
.icone-circulo.g { width: 56px; height: 56px; }
.icone-circulo.g .ico { width: 24px; height: 24px; }

/* ---------- rótulo pequeno acima do título ---------- */
.sobretitulo { margin: 0 0 8px; font-size: 11px; font-weight: 600; letter-spacing: .2em; text-transform: uppercase; color: var(--primary); }

/* ---------- aviso suave (StatusMessage) ---------- */
.msg-ok { display: flex; gap: 10px; align-items: flex-start; padding: 12px 16px; border-radius: 12px; background: var(--success-soft); color: var(--success); font-size: 14px; }
.msg-erro { display: flex; gap: 10px; align-items: flex-start; padding: 12px 16px; border-radius: 12px; background: #fdf0ef; color: var(--destructive); font-size: 14px; }

/* ---------- aviso flutuante (toast) ---------- */
#toast {
  position: fixed; bottom: 24px; left: 50%; z-index: 99; transform: translate(-50%, 12px); opacity: 0; pointer-events: none;
  background: var(--card); color: var(--foreground); border: 1px solid var(--border); padding: 14px 20px; border-radius: 14px;
  box-shadow: var(--shadow-float); font-weight: 600; font-size: 14px; max-width: calc(100% - 32px);
  transition: opacity .18s var(--ease-soft-in-out), transform .18s var(--ease-soft-in-out);
}
#toast.on { opacity: 1; transform: translate(-50%, 0); transition-duration: .26s; transition-timing-function: var(--ease-soft); }

/* ---------- telas de acesso (login, senha, confirmação) ---------- */
.acesso { min-height: 100svh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 48px 20px; }
.acesso-caixa { width: 100%; max-width: 400px; }
.acesso-cab { display: flex; flex-direction: column; align-items: center; text-align: center; }
.acesso-cab .sobretitulo { margin: 20px 0 0; }
.acesso-cab h1 { margin: 12px 0 0; font-size: 32px; }
.acesso-cab p { margin: 12px 0 0; color: var(--muted-foreground); font-size: 15px; line-height: 1.6; }
.acesso-cartao { margin-top: 32px; }
.acesso-rodape { margin-top: 24px; text-align: center; font-size: 12px; color: var(--muted-foreground); }
.acesso-rodape a { color: var(--muted-foreground); text-underline-offset: 2px; }
.acesso-rodape a:hover { color: var(--foreground); }

/* ---------- reduzir movimento ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms !important; transition-duration: 1ms !important; scroll-behavior: auto !important; }
}

@media (max-width: 600px) {
  .cartao, .painel { padding: 24px; }
  h1 { font-size: 28px; }
  .dlg-cab, .dlg-rod { padding-left: 20px; padding-right: 20px; }
  .dlg-corpo { padding-left: 20px; padding-right: 20px; }
}
