/* =========================================================
   Reabilitare — Sistema de gestão da clínica
   Identidade herdada da página da Dra. Débora (Espaço Interativo Reabilitare):
   paleta creme/petróleo/pêssego · Fredoka (marca) · Quicksand (corpo) · Caveat (manuscrito)
   Layout de PAINEL: sidebar + topbar + conteúdo. Front sem build.
   ========================================================= */

:root {
  /* paleta da marca */
  --cream:      #FBF7EC;
  --cream-card: #FFFDF7;
  --cream-2:    #F5EEDC;
  --petrol:     #1E6E7D;
  --petrol-d:   #155863;
  --petrol-ink: #17505A;
  --peach:      #EE9A5F;
  --peach-d:    #DE7F3C;
  --yellow:     #F4D66A;
  --sage:       #C3D9B8;
  --sky:        #A7D8E6;
  --ink:        #26383D;
  --muted:      #6C7D82;
  --line:       #EAE2CF;
  --wa:         #25D366;

  /* cores de status de agendamento */
  --st-confirmado: var(--sage);
  --st-aguardando: var(--yellow);
  --st-chegou:     var(--sky);
  --st-falta:      #E7B7A6;

  --shadow-sm: 0 6px 16px -6px rgba(21, 88, 99, 0.18);
  --shadow-md: 0 14px 30px -10px rgba(21, 88, 99, 0.22);
  --shadow-lg: 0 22px 44px -14px rgba(21, 88, 99, 0.28);

  --radius: 18px;
  --radius-lg: 26px;
  --radius-sm: 12px;

  --font-brand: 'Fredoka', sans-serif;
  --font-hand:  'Caveat', cursive;
  --font-body:  'Quicksand', sans-serif;

  --sidebar-w: 248px;
  --topbar-h: 72px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: var(--font-body);
  color: var(--ink);
  line-height: 1.5;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  background: var(--cream);
}
img { max-width: 100%; display: block; }
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }

/* fundo global com wallpaper + véu creme (igual à página da Débora) */
.bg {
  position: fixed; inset: 0; z-index: -2;
  background:
    linear-gradient(180deg, rgba(251,247,236,0.82) 0%, rgba(245,238,220,0.9) 100%),
    url("wallpaper.jpeg") center center / cover no-repeat;
}

/* ============ LAYOUT ============ */
.app { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100vh; }

/* ---- Sidebar ---- */
.sidebar {
  background: linear-gradient(180deg, var(--petrol) 0%, var(--petrol-d) 100%);
  color: #EAF6F5;
  display: flex; flex-direction: column;
  padding: 22px 16px;
  position: sticky; top: 0; height: 100vh;
}
.sidebar .logo {
  background: #fff; border-radius: var(--radius);
  padding: 10px 14px; margin-bottom: 26px;
  box-shadow: var(--shadow-sm);
}
.sidebar .logo img { width: 100%; max-width: 150px; margin: 0 auto; }
.nav { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.nav a {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 14px; border-radius: var(--radius-sm);
  color: #CFEAE8; font-weight: 500; font-size: .98rem;
  transition: background .15s, color .15s;
}
.nav a svg { width: 20px; height: 20px; flex: none; }
.nav a:hover { background: rgba(255,255,255,0.08); color: #fff; }
.nav a.active { background: var(--cream-card); color: var(--petrol-ink); box-shadow: var(--shadow-sm); }
.nav a.active svg { color: var(--peach-d); }
/* grupo "Configurações" com submenus */
.nav-group { display: flex; flex-direction: column; gap: 4px; }
.nav-grouplabel {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 14px; color: #CFEAE8; font-weight: 500; font-size: .98rem;
}
.nav-grouplabel svg { width: 20px; height: 20px; flex: none; }
.nav a.nav-sub { padding-left: 46px; font-size: .92rem; }
.sidebar .me {
  display: flex; align-items: center; gap: 10px;
  padding: 10px; border-radius: var(--radius-sm);
  background: rgba(255,255,255,0.08); margin-top: 12px;
}
.sidebar .me img { width: 38px; height: 38px; border-radius: 50%; object-fit: cover; border: 2px solid rgba(255,255,255,.4); }
.sidebar .me b { font-size: .9rem; display: block; color: #fff; }
.sidebar .me span { font-size: .78rem; color: #AFD6D3; }

/* ---- Área principal ---- */
.main { display: flex; flex-direction: column; min-width: 0; }

/* ---- Topbar ---- */
.topbar {
  height: var(--topbar-h); flex: none;
  display: flex; align-items: center; gap: 16px;
  padding: 0 28px;
  background: rgba(255,253,247,0.86);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 10;
}
.topbar h1 { font-family: var(--font-brand); font-weight: 600; font-size: 1.4rem; color: var(--petrol-ink); }
.topbar .sub { font-family: var(--font-hand); font-size: 1.25rem; color: var(--peach-d); margin-left: -6px; }
.topbar .spacer { flex: 1; }
.search {
  display: flex; align-items: center; gap: 8px;
  background: #fff; border: 1px solid var(--line);
  border-radius: 999px; padding: 8px 16px; min-width: 220px;
  color: var(--muted);
}
.search input { border: none; outline: none; font-family: inherit; font-size: .92rem; width: 100%; color: var(--ink); background: transparent; }

.content { padding: 24px 28px 40px; overflow: auto; }

/* ============ COMPONENTES ============ */
.card {
  background: var(--cream-card);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 20px;
}
.card h2 { font-family: var(--font-brand); font-weight: 600; font-size: 1.1rem; color: var(--petrol-ink); margin-bottom: 4px; }

.btn {
  display: inline-flex; align-items: center; gap: 8px;
  border: none; border-radius: 999px;
  padding: 10px 20px; font-weight: 600; font-size: .95rem;
  background: var(--petrol); color: #fff;
  box-shadow: var(--shadow-sm); transition: transform .12s, background .15s;
}
.btn:hover { background: var(--petrol-d); transform: translateY(-1px); }
.btn svg { width: 18px; height: 18px; }
.btn.peach { background: var(--peach); } .btn.peach:hover { background: var(--peach-d); }
.btn.ghost { background: #fff; color: var(--petrol-ink); border: 1px solid var(--line); box-shadow: none; }
.btn.ghost:hover { background: var(--cream-2); }

.chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 12px; border-radius: 999px; font-size: .82rem; font-weight: 600; }
.chip.confirmado { background: var(--st-confirmado); color: #2d5a36; }
.chip.aguardando { background: var(--st-aguardando); color: #7a5c15; }
.chip.chegou     { background: var(--st-chegou); color: #1b5566; }
.chip.falta      { background: var(--st-falta); color: #8a3a28; }

/* segmented control (dia/semana/mês) */
.seg { display: inline-flex; background: #fff; border: 1px solid var(--line); border-radius: 999px; padding: 4px; gap: 2px; }
.seg button { border: none; background: transparent; padding: 7px 16px; border-radius: 999px; font-weight: 600; font-size: .88rem; color: var(--muted); }
.seg button.on { background: var(--petrol); color: #fff; }

/* selo do dentista */
.dentista-pick { display: flex; gap: 8px; }
.dentista-pick button {
  display: flex; align-items: center; gap: 8px;
  background: #fff; border: 1px solid var(--line); border-radius: 999px;
  padding: 5px 14px 5px 6px; font-weight: 600; font-size: .9rem; color: var(--ink);
}
.dentista-pick button .dot { width: 22px; height: 22px; border-radius: 50%; }
.dentista-pick button.on { border-color: var(--petrol); box-shadow: var(--shadow-sm); }

/* ============ AGENDA (calendário semanal) ============ */
.agenda-head { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-bottom: 18px; }
.agenda-head .spacer { flex: 1; }
.weeknav { display: flex; align-items: center; gap: 10px; font-family: var(--font-brand); font-weight: 600; color: var(--petrol-ink); }
.weeknav button { width: 34px; height: 34px; border-radius: 50%; border: 1px solid var(--line); background: #fff; color: var(--petrol); font-size: 1.1rem; }

.calendar {
  background: var(--cream-card); border: 1px solid var(--line);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.cal-grid { display: grid; grid-template-columns: 64px repeat(5, 1fr); }
.cal-corner, .cal-dayhead { border-bottom: 1px solid var(--line); }
.cal-dayhead { padding: 12px 8px; text-align: center; border-left: 1px solid var(--line); }
.cal-dayhead .dow { font-weight: 600; color: var(--petrol-ink); font-size: .9rem; text-transform: capitalize; }
.cal-dayhead .dnum { font-family: var(--font-brand); font-size: 1.35rem; color: var(--ink); }
.cal-dayhead.hoje .dnum { color: var(--peach-d); }
.cal-dayhead.hoje { background: #fff; }

.cal-time { border-right: 1px solid var(--line); border-bottom: 1px dashed var(--line); height: 56px; font-size: .74rem; color: var(--muted); text-align: right; padding: 2px 8px 0 0; }
.cal-cell { border-left: 1px solid var(--line); border-bottom: 1px dashed var(--line); height: 56px; position: relative; }
.cal-cell.almoco { background: repeating-linear-gradient(45deg, #F5EEDC, #F5EEDC 8px, #F0E6CE 8px, #F0E6CE 16px); }

.appt {
  position: absolute; left: 4px; right: 4px; top: 3px;
  border-radius: 12px; padding: 7px 10px; font-size: .8rem;
  box-shadow: var(--shadow-sm); overflow: hidden; cursor: pointer;
  border-left: 4px solid rgba(0,0,0,.12);
}
.appt b { display: block; font-size: .86rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.appt small { color: rgba(0,0,0,.55); }
.appt.confirmado { background: #DCEBD2; border-color: #7Fae6a; }
.appt.aguardando { background: #FBEEBE; border-color: #E6C64f; }
.appt.chegou     { background: #CFEAF2; border-color: #74c0d6; }
.appt.falta      { background: #F6DACE; border-color: #D79478; }

/* grid de DIA (uma coluna) */
.cal-grid.dia { grid-template-columns: 64px 1fr; }

/* grid de MÊS */
.month { background: var(--cream-card); border: 1px solid var(--line); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); overflow: hidden; }
.month-head, .month-body { display: grid; grid-template-columns: repeat(7, 1fr); }
.month-head div { padding: 10px; text-align: center; font-weight: 600; font-size: .82rem; color: var(--petrol-ink); border-bottom: 1px solid var(--line); text-transform: capitalize; }
.month-cell { min-height: 92px; border-left: 1px solid var(--line); border-bottom: 1px solid var(--line); padding: 6px 8px; cursor: pointer; transition: background .12s; }
.month-cell:hover { background: var(--cream-2); }
.month-cell.fora { background: #FAF6EA; color: var(--muted); }
.month-cell.hoje .mdnum { background: var(--peach); color: #fff; border-radius: 50%; width: 26px; height: 26px; display: grid; place-items: center; }
.mdnum { font-family: var(--font-brand); font-size: 1rem; }
.month-cell .pill { display: block; font-size: .72rem; margin-top: 4px; padding: 2px 6px; border-radius: 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.month-cell .mais { font-size: .72rem; color: var(--muted); margin-top: 2px; }

/* legenda */
.legenda { display: flex; gap: 16px; flex-wrap: wrap; margin-top: 14px; font-size: .84rem; color: var(--muted); }
.legenda span { display: inline-flex; align-items: center; gap: 6px; }
.legenda i { width: 14px; height: 14px; border-radius: 4px; display: inline-block; }

/* ============ KPIs ============ */
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 22px; }
.kpi { background: var(--cream-card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow-sm); }
.kpi .v { font-family: var(--font-brand); font-size: 1.9rem; color: var(--petrol-ink); line-height: 1; }
.kpi .l { font-size: .82rem; color: var(--muted); margin-top: 4px; }
.kpi .v small { font-size: .9rem; color: var(--peach-d); }

/* ============ TABELA (pacientes) ============ */
.tbl { width: 100%; border-collapse: collapse; }
.tbl th { text-align: left; font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); padding: 10px 12px; border-bottom: 1px solid var(--line); }
.tbl td { padding: 12px; border-bottom: 1px solid var(--line); font-size: .92rem; }
.tbl tr:hover td { background: var(--cream-2); }
.pac { display: flex; align-items: center; gap: 10px; }
.pac .ini { width: 36px; height: 36px; border-radius: 50%; background: var(--sage); color: #2d5a36; display: grid; place-items: center; font-weight: 700; font-size: .85rem; }

/* ============ CONVERSAS ============ */
.chat { display: grid; grid-template-columns: 320px 1fr; height: calc(100vh - var(--topbar-h) - 64px); border-radius: var(--radius-lg); overflow: hidden; border: 1px solid var(--line); box-shadow: var(--shadow-sm); background: var(--cream-card); }
.chat-side { display: flex; flex-direction: column; border-right: 1px solid var(--line); min-height: 0; overflow: hidden; }
.chat-filter { display: flex; gap: 8px; padding: 12px; border-bottom: 1px solid var(--line); background: var(--cream-card); }
.chip-tgl { border: 1px solid var(--line); background: #fff; color: var(--muted); border-radius: 999px; padding: 6px 12px; font-family: inherit; font-size: .82rem; font-weight: 600; cursor: pointer; }
.chip-tgl.on { background: var(--petrol); color: #fff; border-color: var(--petrol); }
.chat-list { overflow: auto; flex: 1; min-height: 0; }
.chat-item { display: flex; gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--line); cursor: pointer; }
.chat-item:hover, .chat-item.on { background: var(--cream-2); }
.chat-item img { width: 44px; height: 44px; border-radius: 50%; object-fit: cover; }
.chat-item .nm { font-weight: 600; font-size: .92rem; }
.chat-item .pv { font-size: .82rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 190px; }
.chat-item .badge { margin-left: auto; background: var(--wa); color: #fff; font-size: .72rem; font-weight: 700; border-radius: 999px; padding: 2px 7px; height: fit-content; }
.chat-pane { display: flex; flex-direction: column; background: var(--cream); }
.chat-pane-head { padding: 14px 18px; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 12px; background: var(--cream-card); }
.chat-msgs { flex: 1; overflow: auto; padding: 20px; display: flex; flex-direction: column; gap: 10px; }
.msg { max-width: 72%; padding: 9px 13px; border-radius: 14px; font-size: .9rem; box-shadow: var(--shadow-sm); }
.msg.in { background: #fff; align-self: flex-start; border-bottom-left-radius: 4px; }
.msg.out { background: #DCF8C6; align-self: flex-end; border-bottom-right-radius: 4px; }
.msg .t { display: block; font-size: .68rem; color: var(--muted); text-align: right; margin-top: 2px; }
.chat-compose { display: flex; gap: 10px; padding: 14px; border-top: 1px solid var(--line); background: var(--cream-card); }
.chat-compose input { flex: 1; border: 1px solid var(--line); border-radius: 999px; padding: 11px 16px; outline: none; font-family: inherit; }

/* ============ CONEXÃO (QR) ============ */
.conexao { max-width: 520px; margin: 10px auto; text-align: center; }
.qr-box { width: 240px; height: 240px; margin: 20px auto; border-radius: var(--radius); background: #fff; border: 1px solid var(--line); display: grid; place-items: center; box-shadow: var(--shadow-sm); }
.qr-box .ph { color: var(--muted); font-size: .85rem; padding: 20px; }
.status-pill { display: inline-flex; align-items: center; gap: 8px; padding: 7px 16px; border-radius: 999px; font-weight: 600; font-size: .9rem; }
.status-pill.off { background: #F6DACE; color: #8a3a28; }
.status-pill.on  { background: var(--sage); color: #2d5a36; }
.status-pill.warn { background: #FBEEBE; color: #8a6d1a; }
.status-pill .d { width: 10px; height: 10px; border-radius: 50%; background: currentColor; }
.qr-box img { width: 100%; height: 100%; object-fit: contain; padding: 10px; }

/* ============ FORM (config agenda) ============ */
.form-row { display: grid; grid-template-columns: 180px 1fr; align-items: center; gap: 14px; padding: 12px 0; border-bottom: 1px dashed var(--line); }
.form-row label { font-weight: 600; color: var(--petrol-ink); font-size: .92rem; }
.form-row input, .form-row select { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 9px 12px; font-family: inherit; outline: none; }
.dias { display: flex; gap: 8px; flex-wrap: wrap; }
/* cards de profissional: form-row compacto (label estreito, inputs que quebram) */
.prof-card .form-row { grid-template-columns: 58px 1fr; gap: 10px; padding: 10px 0; }
.prof-card .form-row > div { flex-wrap: wrap; }
.prof-card .form-row input[type="time"] { width: 84px; padding: 8px 8px; }
.prof-card .dias button { padding: 6px 11px; }
.dias button { border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 7px 14px; font-weight: 600; font-size: .85rem; color: var(--muted); }
.dias button.on { background: var(--petrol); color: #fff; border-color: var(--petrol); }

.view { display: none; }
.view.active { display: block; animation: fade .2s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.section-title { font-family: var(--font-brand); font-weight: 600; color: var(--petrol-ink); font-size: 1.05rem; margin: 2px 0 14px; }

/* ============ RESPONSIVO ============ */
@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; top: 0; width: 220px; transform: translateX(-100%); transition: transform .25s; z-index: 50; }
  .sidebar.open { transform: none; }
  .kpis { grid-template-columns: repeat(2, 1fr); }
  .chat { grid-template-columns: 1fr; }
  .cal-grid { grid-template-columns: 52px repeat(5, 1fr); font-size: .8rem; }
}
.menu-btn { display: none; background: #fff; border: 1px solid var(--line); border-radius: 10px; width: 40px; height: 40px; }
@media (max-width: 900px) { .menu-btn { display: grid; place-items: center; } }
