/* ============================================================
   Prontuário Clínica da Face — estilos
   ============================================================ */
:root {
  --bg: #faf7f1;           /* areia clara */
  --card: #ffffff;
  --ink: #3a3226;          /* marrom-escuro quente */
  --ink-soft: #857661;
  --line: #eae2d2;
  --brand: #a5772b;        /* dourado */
  --brand-escuro: #8a6224;
  --brand-soft: #f5edd9;
  --danger: #b3423f;       /* terracota */
  --warn: #b07d2b;
  --ok: #6b7f3e;           /* oliva */
  --radius: 10px;
  --shadow: 0 1px 3px rgba(90, 70, 30, 0.08), 0 4px 14px rgba(90, 70, 30, 0.07);
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg); color: var(--ink); font-size: 15px;
}
h1, h2, h3 { margin: 0 0 8px; }
button { font: inherit; cursor: pointer; }
input, select, textarea {
  font: inherit; color: var(--ink);
  border: 1px solid var(--line); border-radius: 8px;
  padding: 9px 11px; background: #fff; width: 100%;
}
input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--brand); outline-offset: -1px; border-color: var(--brand);
}
label { display: block; font-size: 13px; color: var(--ink-soft); margin: 10px 0 4px; font-weight: 600; }

/* ---------- topo ---------- */
header.topbar {
  background: linear-gradient(120deg, #c9a24b 0%, #a5772b 50%, #7d5a1e 100%);
  border-bottom: none;
  padding: 12px 22px; display: flex; align-items: center; gap: 18px;
  flex-wrap: wrap;
  position: sticky; top: 0; z-index: 40;
  box-shadow: 0 2px 12px rgba(125, 90, 30, 0.3);
}
.topbar .logo { font-weight: 700; font-size: 17px; color: #fff; letter-spacing: 0.2px; }
.topbar .logo small { display: block; font-weight: 400; font-size: 11px; color: rgba(255,255,255,0.65); }
nav.tabs { display: flex; gap: 6px; flex: 1; min-width: 300px; }
.tab {
  border: none; background: transparent; padding: 9px 18px;
  border-radius: 999px; color: rgba(255,255,255,0.8); font-weight: 600;
}
.tab:hover { background: rgba(255,255,255,0.14); color: #fff; }
.tab.active { background: #fff; color: var(--brand); box-shadow: 0 2px 8px rgba(0,0,0,0.15); }
.user-area { display: flex; align-items: center; gap: 10px; }
#userChip {
  font-size: 12.5px; color: #fff; background: rgba(255,255,255,0.15);
  padding: 6px 14px; border-radius: 999px; border: 1px solid rgba(255,255,255,0.25);
}
#logoutBtn { background: transparent; border-color: rgba(255,255,255,0.4); color: #fff; }
#logoutBtn:hover { background: rgba(255,255,255,0.15); border-color: #fff; color: #fff; }

/* ---------- botões ---------- */
.btn {
  border: 1px solid var(--line); background: #fff; color: var(--ink);
  border-radius: 8px; padding: 8px 14px; font-weight: 600;
}
.btn:hover { border-color: var(--brand); color: var(--brand); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { filter: brightness(1.08); color: #fff; }
.btn.danger { color: var(--danger); }
.btn.small { padding: 5px 10px; font-size: 13px; }
.btn.whatsapp { background: #25d366; border-color: #25d366; color: #fff; }
.btn.whatsapp:hover { filter: brightness(1.05); color: #fff; }

/* ---------- layout ---------- */
main { padding: 20px; max-width: 1400px; margin: 0 auto; }
.panel { display: none; }
.panel.active { display: block; }
.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px;
}
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.toolbar .spacer { flex: 1; }
.toolbar input[type="search"] { max-width: 320px; }
.muted { color: var(--ink-soft); font-size: 13px; }
.empty { text-align: center; color: var(--ink-soft); padding: 40px 0; }

/* ---------- listas (linhas como cartões, sem cara de planilha) ---------- */
table.lista { width: 100%; border-collapse: separate; border-spacing: 0 6px; }
table.lista th {
  text-align: left; font-size: 11px; text-transform: uppercase;
  letter-spacing: 0.6px; color: var(--ink-soft); padding: 2px 12px 6px;
  border: none; font-weight: 700;
}
table.lista td {
  padding: 10px 12px; border: none; background: #fff;
  border-top: 1px solid var(--line); border-bottom: 1px solid var(--line);
}
table.lista td:first-child { border-left: 1px solid var(--line); border-radius: 12px 0 0 12px; }
table.lista td:last-child { border-right: 1px solid var(--line); border-radius: 0 12px 12px 0; }
table.lista tr:hover td { background: #faf5e8; border-color: #dcc998; }
table.lista .acoes { text-align: right; white-space: nowrap; }
table.lista .acoes .btn + .btn { margin-left: 6px; }
.panel > .card:has(table.lista) { background: transparent; border: none; box-shadow: none; padding: 0; }

/* avatar com iniciais */
.avatar {
  display: inline-flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; border-radius: 50%; margin-right: 10px;
  color: #fff; font-weight: 700; font-size: 13px; flex: none;
  vertical-align: middle;
}
.avatar.grande { width: 46px; height: 46px; font-size: 17px; }
.cel-nome { display: flex; align-items: center; }

/* ---------- agenda ---------- */
.agenda-head { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.agenda-head .semana { font-weight: 700; min-width: 210px; text-align: center; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  border: 1px solid var(--line); background: #fff; border-radius: 999px;
  padding: 5px 13px; font-size: 13px; font-weight: 600; color: var(--ink-soft);
}
.chip.active { border-color: var(--chip-cor, var(--brand)); color: var(--chip-cor, var(--brand)); background: #fff; box-shadow: inset 0 0 0 1px var(--chip-cor, var(--brand)); }
.agenda-grid-wrap { overflow-x: auto; }
.agenda-grid {
  display: grid; min-width: 900px;
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); overflow: hidden;
}
.agenda-grid .gcell { border-bottom: 1px solid #f0ead9; border-right: 1px solid #f0ead9; min-height: 34px; position: relative; }
.agenda-grid .ghead {
  background: #faf6ec; font-weight: 700; font-size: 13px; text-align: center;
  padding: 8px 4px; position: sticky; top: 0;
}
.agenda-grid .ghead small { display: block; font-weight: 400; color: var(--ink-soft); }
.agenda-grid .ghora { font-size: 11.5px; color: var(--ink-soft); text-align: right; padding: 2px 6px; background: #faf6ec; }
.agenda-grid .gslot { cursor: pointer; }
.agenda-grid .gslot:hover { background: var(--brand-soft); }
.agenda-grid .hoje { background: #fdfbf3; }
.evento {
  position: absolute; left: 2px; right: 2px; z-index: 5;
  border-radius: 6px; padding: 3px 7px; font-size: 12px; line-height: 1.25;
  color: #fff; overflow: hidden; cursor: pointer;
  border-left: 4px solid rgba(0,0,0,0.25);
}
.evento .ev-nome { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.evento .ev-meta { opacity: 0.9; font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.evento.st-cancelado { opacity: 0.45; text-decoration: line-through; }
.evento.st-faltou { opacity: 0.55; }
.evento .ev-status {
  display: inline-block; font-size: 10px; vertical-align: 1px;
  background: rgba(255,255,255,0.28); border-radius: 4px; padding: 0 5px; margin-left: 4px;
}

.evento.bloqueio {
  background: repeating-linear-gradient(45deg, #d7dde3, #d7dde3 8px, #cbd2d9 8px, #cbd2d9 16px);
  color: #4a5560; border-left-color: #9aa5b0;
}
.visao-toggle { display: flex; gap: 0; }
.visao-toggle .btn { border-radius: 0; }
.visao-toggle .btn:first-child { border-radius: 8px 0 0 8px; }
.visao-toggle .btn:last-child { border-radius: 0 8px 8px 0; margin-left: -1px; }
.visao-toggle .btn.active { background: var(--brand); border-color: var(--brand); color: #fff; }

/* ---------- visão Dia (lista enxuta, estilo Medicina Direta) ---------- */
#agDiaWrap { overflow-x: auto; padding: 10px; background: transparent; border: none; box-shadow: none; }
.dia-lista { min-width: 980px; border-spacing: 0 4px; }
.dia-lista th { padding: 2px 8px 4px; font-size: 10.5px; }
.dia-lista td {
  vertical-align: middle; font-size: 12.5px;
  padding: 5px 8px; line-height: 1.3; white-space: nowrap;
}
.dia-lista td:first-child { width: 48px; }
tr.dia-disponivel td { border: none; background: transparent; border-bottom: 1px dashed #e0d8c4; }
tr.dia-bloqueio td { border: none; }
tr.dia-disponivel:hover td { background: var(--brand-soft); border-radius: 8px; }
tr.dia-bloqueio td { border-radius: 8px; }
.dia-lista .dia-nome { cursor: pointer; }
.dia-lista .dia-nome:hover b { color: var(--brand); text-decoration: underline; }
.dia-lista .dia-nome .muted { font-size: 11px; }
.med-dot {
  display: inline-block; width: 9px; height: 9px; border-radius: 50%;
  margin-right: 5px; vertical-align: 1px;
}
.dia-lista .tel-whats { text-decoration: none; color: var(--ink); white-space: nowrap; }
.dia-lista .tel-whats:hover { color: #1da851; }
tr.dia-disponivel td {
  color: #8a8047; font-weight: 700; font-size: 11.5px; cursor: pointer;
  padding: 2px 8px; letter-spacing: 0.4px;
}
tr.dia-disponivel:hover td { background: var(--brand-soft); }
tr.dia-disponivel td:first-child { color: var(--ink-soft); font-weight: 400; }
.status-select {
  width: auto; padding: 4px 8px; font-size: 12.5px; font-weight: 700; border-radius: 6px;
}
.status-select.st-marcado { color: #6b5f4c; }
.status-select.st-confirmado { color: var(--ok); }
.status-select.st-aguardando { color: var(--warn); background: #fdf3e0; }
.status-select.st-em_atendimento { color: var(--brand-escuro); background: #f2e5c9; }
.status-select.st-atendido { color: var(--ok); background: #ebeeda; }
.status-select.st-faltou { color: var(--danger); }
.status-select.st-cancelado { color: #888; }
tr.dia-st-cancelado td, tr.dia-st-faltou td { opacity: 0.55; }
tr.dia-bloqueio td {
  background: repeating-linear-gradient(45deg, #f0f2f5, #f0f2f5 8px, #e7eaee 8px, #e7eaee 16px);
  color: #5a6570; font-weight: 600;
}

/* ---------- cartão rápido (estilo MEDC) ---------- */
.mr-info { margin: -2px 0 12px; font-size: 13px; }
.mr-status { display: flex; flex-wrap: wrap; gap: 7px; }
.mr-st {
  border: 1px solid var(--line); cursor: pointer; font-size: 13px;
  padding: 7px 13px; border-radius: 8px; background: #fff;
}
.mr-st:hover { filter: brightness(0.96); }
.mr-st.ativo { outline: 2px solid var(--brand); outline-offset: 1px; }

/* ---------- dados vitais no editor ---------- */
.vitais-linha { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
@media (max-width: 800px) { .vitais-linha { grid-template-columns: repeat(2, 1fr); } }

/* ---------- badges de status ---------- */
.badge { display: inline-block; border-radius: 6px; padding: 2px 9px; font-size: 12px; font-weight: 700; }
.badge.marcado { background: #f0ece2; color: #6b5f4c; }
.badge.confirmado { background: #ebeeda; color: var(--ok); }
.badge.aguardando { background: #fdf3e0; color: var(--warn); }
.badge.em_atendimento { background: #f2e5c9; color: var(--brand-escuro); }
.badge.atendido { background: #ebeeda; color: var(--ok); }
.badge.faltou { background: #f7e6e5; color: var(--danger); }
.badge.cancelado { background: #edeae4; color: #969084; }

/* ---------- modal ---------- */
.modal-bg {
  position: fixed; inset: 0; background: rgba(15, 30, 45, 0.45);
  display: none; align-items: flex-start; justify-content: center;
  z-index: 100; padding: 40px 16px; overflow-y: auto;
}
.modal-bg.open { display: flex; }
.modal {
  background: #fff; border-radius: 14px; box-shadow: var(--shadow);
  width: 100%; max-width: 560px; padding: 22px;
}
.modal h3 { color: var(--brand); }
.modal .linha { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.modal .rodape { display: flex; gap: 10px; justify-content: flex-end; margin-top: 18px; }
.modal .rodape .esq { margin-right: auto; }

/* ---------- login ---------- */
.login-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(160deg, #c9a24b 0%, #a5772b 45%, #6f4f1a 100%);
}
.login-card {
  background: #fff; border-radius: 16px; padding: 34px;
  width: 100%; max-width: 400px; box-shadow: 0 20px 60px rgba(0,0,0,0.25);
}
.login-card .logo { text-align: center; margin-bottom: 20px; }
.login-card .logo b { font-size: 22px; color: var(--brand); }
.login-card .logo span { display: block; color: var(--ink-soft); font-size: 13px; margin-top: 4px; }
.login-card .btn { width: 100%; margin-top: 16px; padding: 11px; }
.login-erro { color: var(--danger); font-size: 13px; margin-top: 10px; text-align: center; min-height: 18px; }
.demo-box { margin-top: 22px; border-top: 1px dashed var(--line); padding-top: 16px; text-align: center; }
.demo-box .btn { margin-top: 8px; }

/* ---------- ficha do paciente ---------- */
.ficha-grid { display: grid; grid-template-columns: 340px 1fr; gap: 16px; }
.ficha-grid .dado { margin-bottom: 8px; }
.ficha-grid .dado b { display: block; font-size: 12px; color: var(--ink-soft); text-transform: uppercase; letter-spacing: 0.3px; }
.aviso-construcao {
  background: #fdf6e3; border: 1px solid #ecd9a0; color: #7a6120;
  border-radius: 8px; padding: 12px 16px; font-size: 14px;
}

/* ---------- prontuário ---------- */
.pront-header {
  display: flex; gap: 14px; align-items: center; justify-content: space-between;
  flex-wrap: wrap; margin-bottom: 16px;
  border-left: 5px solid var(--brand);
}
.pront-dados .ph-top { display: flex; align-items: center; gap: 6px; margin-bottom: 6px; }
.pront-dados .ph-nome { font-weight: 700; font-size: 17px; color: var(--brand); }
.pront-dados .ph-linha { display: flex; gap: 14px; flex-wrap: wrap; font-size: 13px; }
.pront-dados .ph-item b { color: var(--ink-soft); font-weight: 600; }
.pront-acoes { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.pront-grid { display: grid; grid-template-columns: 1fr 300px; gap: 16px; align-items: start; }
.tl-card { margin-bottom: 14px; }
.tl-head {
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  flex-wrap: wrap; border-bottom: 1px solid var(--line);
  padding-bottom: 8px; margin-bottom: 10px;
}
.ev-sec { margin: 8px 0; }
.ev-sec > b {
  display: block; font-size: 11.5px; text-transform: uppercase;
  letter-spacing: 0.4px; color: var(--ink-soft); margin-bottom: 2px;
}
.tl-acoes { display: flex; gap: 8px; margin-top: 12px; border-top: 1px dashed var(--line); padding-top: 10px; align-items: center; }
.pront-sidebar .sb-box { margin-bottom: 12px; padding: 14px; }
.sb-box h4 { margin: 0 0 8px; font-size: 14px; }
.sb-lista { list-style: none; margin: 0 0 8px; padding: 0; }
.sb-lista li {
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
  padding: 5px 0; border-bottom: 1px solid var(--line); font-size: 13.5px;
}
.sb-lista li:last-child { border-bottom: none; }
.sb-x {
  border: none; background: transparent; color: var(--ink-soft);
  font-size: 15px; padding: 0 4px; border-radius: 4px;
}
.sb-x:hover { color: var(--danger); background: #f7e6e5; }
.sb-form input { font-size: 13px; padding: 6px 9px; }

@media (max-width: 1000px) {
  .pront-grid { grid-template-columns: 1fr; }
}

@media (max-width: 800px) {
  .ficha-grid { grid-template-columns: 1fr; }
  .modal .linha { grid-template-columns: 1fr; }
  nav.tabs { overflow-x: auto; }
}
