/* =====================================================================
   Clínica de Emagrecimento — Design System
   Visual clínico/wellness moderno. A cor de marca vem de --brand,
   injetada pelo PHP a partir de clinicas.cor_primaria.
   ===================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Fraunces:opsz,wght@9..144,400;9..144,500;9..144,600;9..144,700&family=Plus+Jakarta+Sans:wght@400;500;600;700;800&display=swap');

:root {
  --brand: #a9823c;            /* dourado/bronze da marca */
  --brand-700: #8a6a2e;
  --brand-50: #f6efe1;
  --brand-100: #ecdfc4;

  --ink: #1c1813;              /* grafite quente (quase preto) */
  --ink-soft: #5c5246;
  --muted: #9d9082;
  --line: #eae1d2;
  --line-strong: #dccfbb;
  --bg: #f4ede1;              /* creme */
  --surface: #ffffff;
  --surface-2: #faf6ee;

  --ok: #1f9d6b;
  --ok-bg: #e7f6ef;
  --warn: #c98a12;
  --warn-bg: #fcf3df;
  --danger: #d6443b;
  --danger-bg: #fbe9e7;
  --neutral: #6b7770;
  --neutral-bg: #eef1ef;

  --shadow-sm: 0 1px 2px rgba(20, 32, 26, .05), 0 1px 3px rgba(20, 32, 26, .04);
  --shadow: 0 4px 16px -6px rgba(20, 32, 26, .12), 0 2px 6px -3px rgba(20, 32, 26, .07);
  --shadow-lg: 0 18px 40px -16px rgba(20, 32, 26, .22);

  --r-sm: 10px;
  --r: 16px;
  --r-lg: 22px;

  --sidebar-w: 264px;
  --font-body: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
  --font-display: 'Fraunces', Georgia, serif;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--brand-700); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3, h4 { font-family: var(--font-display); font-weight: 600; color: var(--ink); letter-spacing: -.01em; margin: 0; }

/* ---------- Shell: sidebar + conteúdo ---------- */
.layout { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  background: linear-gradient(180deg, #2a2118 0%, #1b140d 100%);
  color: #d8cbb6;
  display: flex; flex-direction: column;
  position: fixed; inset: 0 auto 0 0;
  z-index: 40;
  padding: 22px 16px;
}
.sidebar .marca {
  display: flex; align-items: center; gap: 11px;
  padding: 6px 8px 18px;
  border-bottom: 1px solid rgba(255,255,255,.08);
  margin-bottom: 14px;
}
/* logo da marca (imagem) sobre cartão creme */
.sidebar .marca-logo-img {
  width: 100%; display: block; border-radius: 12px;
  background: #f4ede1; padding: 12px 14px;
  box-shadow: 0 6px 18px -8px rgba(0,0,0,.5);
}
.sidebar .marca-logo {
  width: 38px; height: 38px; border-radius: 11px;
  background: var(--brand); color: #1c1813;
  display: grid; place-items: center;
  font-family: var(--font-display); font-weight: 700; font-size: 19px;
  box-shadow: 0 6px 16px -6px var(--brand);
}
.sidebar .marca-nome { font-family: var(--font-display); font-weight: 600; color: #fff; font-size: 16px; line-height: 1.1; }
.sidebar .marca-sub { font-size: 11px; color: #b79a6a; letter-spacing: .04em; text-transform: uppercase; }

.nav-grupo { font-size: 10.5px; letter-spacing: .1em; text-transform: uppercase; color: #9a7e52; margin: 16px 10px 6px; }
.nav-link {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; border-radius: 11px;
  color: #cabba0; font-weight: 500; font-size: 14px;
  transition: background .15s, color .15s;
}
.nav-link:hover { background: rgba(255,255,255,.07); color: #fff; text-decoration: none; }
.nav-link.ativo { background: var(--brand); color: #1c1813; box-shadow: 0 8px 18px -8px var(--brand); }
.nav-link i { font-size: 18px; width: 20px; text-align: center; }
.nav-link .selo { margin-left: auto; background: var(--danger); color: #fff; font-size: 11px; font-weight: 700; padding: 1px 7px; border-radius: 999px; }
.sidebar .rodape { margin-top: auto; padding-top: 14px; border-top: 1px solid rgba(255,255,255,.08); font-size: 12px; color: #9a7e52; }

.conteudo { flex: 1; margin-left: var(--sidebar-w); min-width: 0; display: flex; flex-direction: column; }

.topbar {
  height: 66px; background: var(--surface);
  border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 16px;
  padding: 0 26px; position: sticky; top: 0; z-index: 30;
}
.topbar .menu-toggle { display: none; background: none; border: 0; font-size: 22px; color: var(--ink); cursor: pointer; }
.topbar h1 { font-size: 20px; }
.topbar .topbar-dir { margin-left: auto; display: flex; align-items: center; gap: 14px; }
.user-chip { display: flex; align-items: center; gap: 10px; padding: 5px 6px 5px 12px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line); }
.user-chip .nome { font-size: 13px; font-weight: 600; line-height: 1.05; }
.user-chip .papel { font-size: 11px; color: var(--muted); text-transform: capitalize; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--brand-100); color: var(--brand-700); display: grid; place-items: center; font-weight: 700; font-size: 13px; flex: none; }

.pagina { padding: 26px; max-width: 1280px; width: 100%; }

/* ---------- Cards ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow-sm); }
.card + .card { margin-top: 18px; }
.card-cabecalho { padding: 18px 20px; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 12px; }
.card-cabecalho h2 { font-size: 16px; }
.card-cabecalho .acoes { margin-left: auto; display: flex; gap: 8px; }
.card-corpo { padding: 20px; }
.p-5 { padding: 40px !important; }

/* ---------- Stat cards (dashboard) ---------- */
.grade-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 16px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 18px 20px; box-shadow: var(--shadow-sm); position: relative; overflow: hidden; }
.stat .ico { width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; font-size: 20px; margin-bottom: 14px; }
.stat .ico.b { background: var(--brand-50); color: var(--brand-700); }
.stat .ico.g { background: var(--ok-bg); color: var(--ok); }
.stat .ico.y { background: var(--warn-bg); color: var(--warn); }
.stat .ico.r { background: var(--danger-bg); color: var(--danger); }
.stat .valor { font-family: var(--font-display); font-size: 30px; font-weight: 600; line-height: 1; }
.stat .rotulo { color: var(--ink-soft); font-size: 13px; margin-top: 4px; }

/* ---------- Botões ---------- */
.btn { display: inline-flex; align-items: center; gap: 8px; font-family: var(--font-body); font-weight: 600; font-size: 14px; padding: 10px 16px; border-radius: var(--r-sm); border: 1px solid transparent; cursor: pointer; transition: filter .15s, background .15s, box-shadow .15s; line-height: 1; text-decoration: none; }
.btn:hover { text-decoration: none; }
.btn i { font-size: 16px; }
.btn-brand { background: var(--brand); color: #1c1813; box-shadow: 0 8px 18px -8px var(--brand); }
.btn-brand:hover { filter: brightness(1.06); color: #1c1813; }
.btn-claro { background: var(--surface); color: var(--ink); border-color: var(--line-strong); }
.btn-claro:hover { background: var(--surface-2); color: var(--ink); }
.btn-perigo { background: var(--danger-bg); color: var(--danger); }
.btn-perigo:hover { background: #f7ddd9; color: var(--danger); }
.btn-sm { padding: 7px 11px; font-size: 13px; }
.btn-bloco { width: 100%; justify-content: center; }
.btn-ico { padding: 8px; width: 36px; height: 36px; justify-content: center; }

/* ---------- Badges ---------- */
.badge { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 600; padding: 4px 10px; border-radius: 999px; }
.badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge-sucesso { background: var(--ok-bg); color: var(--ok); }
.badge-aviso { background: var(--warn-bg); color: var(--warn); }
.badge-perigo { background: var(--danger-bg); color: var(--danger); }
.badge-neutro { background: var(--neutral-bg); color: var(--neutral); }

/* ---------- Tabelas ---------- */
.tabela-wrap { overflow-x: auto; }
table.tabela { width: 100%; border-collapse: collapse; font-size: 14px; }
table.tabela th { text-align: left; font-size: 11.5px; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); font-weight: 700; padding: 12px 16px; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.tabela td { padding: 14px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.tabela tbody tr:last-child td { border-bottom: 0; }
table.tabela tbody tr { transition: background .12s; }
table.tabela tbody tr:hover { background: var(--surface-2); }
.cel-principal { display: flex; align-items: center; gap: 11px; }
.cel-principal .nome { font-weight: 600; color: var(--ink); }
.cel-principal .sub { font-size: 12.5px; color: var(--muted); }

/* ---------- Formulários ---------- */
.form-grade { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px 18px; }
.campo { display: flex; flex-direction: column; gap: 6px; }
.campo.col-2 { grid-column: 1 / -1; }
.campo label { font-size: 13px; font-weight: 600; color: var(--ink-soft); }
.campo label .req { color: var(--danger); }
.campo input, .campo select, .campo textarea {
  font-family: var(--font-body); font-size: 14px; color: var(--ink);
  padding: 10px 12px; border: 1px solid var(--line-strong); border-radius: var(--r-sm);
  background: var(--surface); transition: border-color .15s, box-shadow .15s; width: 100%;
}
.campo input:focus, .campo select:focus, .campo textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-50); }
.campo textarea { resize: vertical; min-height: 84px; }
.campo .ajuda { font-size: 12px; color: var(--muted); }
.form-acoes { display: flex; gap: 10px; justify-content: flex-end; margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--line); }

/* ---------- Flash ---------- */
.flash { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-radius: var(--r-sm); margin-bottom: 16px; font-size: 14px; font-weight: 500; border: 1px solid transparent; }
.flash i { font-size: 18px; }
.flash-fechar { margin-left: auto; background: none; border: 0; font-size: 20px; line-height: 1; cursor: pointer; opacity: .5; color: inherit; }
.flash-sucesso { background: var(--ok-bg); color: #136e4b; border-color: #bfe6d3; }
.flash-erro { background: var(--danger-bg); color: #9c2f28; border-color: #f3c9c4; }
.flash-aviso { background: var(--warn-bg); color: #8a5e0c; border-color: #f0dca8; }
.flash-info { background: var(--brand-50); color: var(--brand-700); border-color: var(--brand-100); }

/* ---------- Estado vazio ---------- */
.estado-vazio { text-align: center; padding: 48px 20px; color: var(--muted); }
.estado-vazio i { font-size: 44px; color: var(--line-strong); display: block; margin-bottom: 12px; }
.estado-vazio h3 { color: var(--ink-soft); margin-bottom: 6px; }
.estado-vazio p { margin: 0 auto 18px; max-width: 380px; }

/* ---------- Alerta de contraindicação (prontuário) ---------- */
.alerta-clinico { display: flex; gap: 12px; padding: 14px 16px; background: var(--danger-bg); border: 1px solid #f3c9c4; border-radius: var(--r-sm); color: #9c2f28; margin-bottom: 18px; }
.alerta-clinico i { font-size: 20px; flex: none; }
.alerta-clinico strong { display: block; }

/* ---------- Linha do tempo de dose ---------- */
.timeline { position: relative; padding-left: 28px; }
.timeline::before { content: ''; position: absolute; left: 9px; top: 6px; bottom: 6px; width: 2px; background: var(--line-strong); }
.timeline .item { position: relative; padding-bottom: 20px; }
.timeline .item::before { content: ''; position: absolute; left: -23px; top: 4px; width: 14px; height: 14px; border-radius: 50%; background: var(--surface); border: 3px solid var(--line-strong); }
.timeline .item.feito::before { border-color: var(--ok); background: var(--ok); }
.timeline .item.atual::before { border-color: var(--brand); background: var(--brand); box-shadow: 0 0 0 4px var(--brand-50); }
.timeline .dose { font-family: var(--font-display); font-size: 18px; font-weight: 600; }
.timeline .quando { font-size: 13px; color: var(--muted); }

/* ---------- Grid utilitário ---------- */
.linha { display: grid; gap: 18px; }
.linha-2 { grid-template-columns: 2fr 1fr; }
.linha-3 { grid-template-columns: repeat(3, 1fr); }
@media (max-width: 980px) { .linha-2, .linha-3 { grid-template-columns: 1fr; } }

.titulo-pagina { display: flex; align-items: center; gap: 14px; margin-bottom: 20px; }
.titulo-pagina .acoes { margin-left: auto; display: flex; gap: 10px; }
.subtitulo { color: var(--ink-soft); font-size: 14px; margin-top: 2px; }

.texto-muted { color: var(--muted); }
.text-center { text-align: center; }
.mt-0 { margin-top: 0; } .mt-2 { margin-top: 12px; } .mt-3 { margin-top: 18px; }
.lista-dados { list-style: none; padding: 0; margin: 0; }
.lista-dados li { display: flex; justify-content: space-between; gap: 16px; padding: 9px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.lista-dados li:last-child { border-bottom: 0; }
.lista-dados .rotulo { color: var(--muted); }
.lista-dados .valor { font-weight: 600; text-align: right; }

/* ---------- Responsivo ---------- */
.overlay { display: none; position: fixed; inset: 0; background: rgba(8,20,15,.45); z-index: 39; }
@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); transition: transform .25s ease; }
  body.menu-aberto .sidebar { transform: translateX(0); }
  body.menu-aberto .overlay { display: block; }
  .conteudo { margin-left: 0; }
  .topbar .menu-toggle { display: block; }
  .form-grade { grid-template-columns: 1fr; }
  .user-chip .nome, .user-chip .papel { display: none; }
}
