/* ============================================================
   Casa G&T — Estilos compartilhados
   ============================================================ */

:root {
  --cgt-bg: #f4f6fb;
  --cgt-sidebar: #1b2138;
  --cgt-sidebar-hover: #2a3253;
  --cgt-accent: #4f6bed;
  --cgt-radius: 14px;
}

/* Anti-flash: antes do JS injetar o layout, o body mostra o fundo escuro da sidebar
   (mesma cor) em vez de branco — elimina o piscar ao navegar entre páginas */
body {
  background: #1b2138;
  font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  color: #1f2533;
}
/* Após o shell ser injetado, o cgt-main cobre tudo com o fundo claro */
.cgt-main { background: var(--cgt-bg); }

/* ---------- Layout com sidebar ---------- */
.cgt-layout { display: flex; min-height: 100vh; }

.cgt-sidebar {
  width: 250px;
  background: var(--cgt-sidebar);
  color: #cfd6ee;
  flex-shrink: 0;
  position: fixed;
  top: 0; bottom: 0; left: 0;
  overflow-y: auto;
  transition: transform .25s ease;
  z-index: 1040;
}
.cgt-sidebar .brand {
  padding: 1.25rem 1.25rem;
  font-weight: 700;
  font-size: 1.15rem;
  color: #fff;
  letter-spacing: .3px;
  border-bottom: 1px solid rgba(255,255,255,.07);
}
.cgt-sidebar .brand small { font-weight: 400; color: #8b95c4; display: block; font-size: .72rem; }
.cgt-nav { padding: .75rem .6rem 2rem; }
.cgt-nav .group-label {
  font-size: .68rem; text-transform: uppercase; letter-spacing: .8px;
  color: #6f7aa8; padding: .9rem .8rem .35rem;
}
.cgt-nav a {
  display: flex; align-items: center; gap: .65rem;
  padding: .6rem .8rem; margin-bottom: 2px;
  border-radius: 9px; color: #cfd6ee; text-decoration: none;
  font-size: .9rem; transition: background .15s, color .15s;
}
.cgt-nav a:hover { background: var(--cgt-sidebar-hover); color: #fff; }
.cgt-nav a.active { background: var(--cgt-accent); color: #fff; font-weight: 600; }
.cgt-nav a .ico { width: 18px; text-align: center; opacity: .9; }

.cgt-main { flex: 1; margin-left: 250px; min-width: 0; }
.cgt-topbar {
  background: #fff; border-bottom: 1px solid #e6e9f2;
  padding: .7rem 1.25rem; display: flex; align-items: center; gap: 1rem;
  position: sticky; top: 0; z-index: 1030;
}
.cgt-topbar h1 { font-size: 1.1rem; font-weight: 600; margin: 0; }
.cgt-content { padding: 1.5rem 1.25rem 3rem; }

.cgt-burger { display: none; background: none; border: 0; font-size: 1.4rem; color: #1b2138; }

/* ---------- Cards / KPIs ---------- */
.card { border: 1px solid #e9ecf5; border-radius: var(--cgt-radius); }
.kpi {
  background: #fff; border: 1px solid #e9ecf5; border-radius: var(--cgt-radius);
  padding: 1.1rem 1.2rem; height: 100%;
}
.kpi .label { font-size: .78rem; color: #7a849e; text-transform: uppercase; letter-spacing: .5px; }
.kpi .value { font-size: 1.55rem; font-weight: 700; margin-top: .25rem; }
.kpi .sub { font-size: .8rem; color: #98a1b8; margin-top: .15rem; }
.kpi.accent { border-left: 4px solid var(--cgt-accent); }
.kpi.green  { border-left: 4px solid #1aa179; }
.kpi.red    { border-left: 4px solid #e5484d; }
.kpi.amber  { border-left: 4px solid #e9a23b; }

/* ---------- Tabelas ---------- */
.table-card { background: #fff; border: 1px solid #e9ecf5; border-radius: var(--cgt-radius); overflow: hidden; }
.table-card .table { margin: 0; }
.table-card thead th { background: #f7f8fc; font-size: .78rem; text-transform: uppercase; letter-spacing: .4px; color: #7a849e; border-bottom: 1px solid #e9ecf5; }
.table-card td { vertical-align: middle; font-size: .9rem; }

.status-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 6px; }
.dot-prev { background: #e9a23b; }
.dot-rec  { background: #1aa179; }
.dot-late { background: #e5484d; }

/* ---------- Responsivo ---------- */
@media (max-width: 992px) {
  .cgt-sidebar { transform: translateX(-100%); }
  .cgt-sidebar.open { transform: translateX(0); }
  .cgt-main { margin-left: 0; }
  .cgt-burger { display: inline-block; }
}

.cgt-overlay {
  display: none; position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 1035;
}
.cgt-overlay.show { display: block; }

/* login */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg,#1b2138,#3a456f); }
.login-card { width: 100%; max-width: 410px; }

/* ============================================================
   Contexto G/T/Casal + Sidebar accordion (v2)
   ============================================================ */
.cgt-ctx { padding: .85rem 1rem .4rem; border-bottom: 1px solid rgba(255,255,255,.07); }
.cgt-ctx-label { font-size: .68rem; text-transform: uppercase; letter-spacing: .6px; color: #6f7aa8; margin-bottom: .4rem; }
.cgt-ctx-switch { display: flex; gap: 4px; background: #11162b; padding: 4px; border-radius: 10px; }
.cgt-ctx-btn {
  flex: 1; border: 0; background: transparent; color: #9aa3c8;
  font-size: .74rem; font-weight: 600; padding: .4rem .2rem; border-radius: 7px; cursor: pointer;
  transition: all .15s;
}
.cgt-ctx-btn:hover { color: #fff; }
.cgt-ctx-btn.active.g { background: #4f6bed; color: #fff; }
.cgt-ctx-btn.active.t { background: #e5484d; color: #fff; }
.cgt-ctx-btn.active.c { background: #6b7280; color: #fff; }

/* accordion */
.cgt-group { margin-bottom: 2px; }
.cgt-group-head {
  width: 100%; display: flex; align-items: center; gap: .65rem;
  padding: .6rem .8rem; border: 0; background: transparent; color: #cfd6ee;
  border-radius: 9px; font-size: .9rem; cursor: pointer; transition: background .15s;
}
.cgt-group-head:hover { background: var(--cgt-sidebar-hover); color: #fff; }
.cgt-group-head .chev { transition: transform .2s; font-size: .7rem; opacity: .7; }
.cgt-group.open .cgt-group-head .chev { transform: rotate(90deg); }
.cgt-group.open .cgt-group-head { color: #fff; }
.cgt-group-body { max-height: 0; overflow: hidden; transition: max-height .25s ease; }
.cgt-group.open .cgt-group-body { max-height: 420px; }
.cgt-sublink {
  display: block; padding: .5rem .8rem .5rem 2.3rem; color: #aab2d5; text-decoration: none;
  font-size: .85rem; border-radius: 8px; margin: 1px .2rem;
}
.cgt-sublink:hover { background: var(--cgt-sidebar-hover); color: #fff; }
.cgt-sublink.active { background: var(--cgt-accent); color: #fff; font-weight: 600; }

.cgt-link { /* item solo (visão geral) */
  display: flex; align-items: center; gap: .65rem; padding: .6rem .8rem; margin-bottom: 4px;
  border-radius: 9px; color: #cfd6ee; text-decoration: none; font-size: .9rem;
}
.cgt-link:hover { background: var(--cgt-sidebar-hover); color: #fff; }
.cgt-link.active { background: var(--cgt-accent); color: #fff; font-weight: 600; }

/* pill de contexto no topbar */
.cgt-ctx-pill { font-size: .72rem; font-weight: 700; padding: .2rem .6rem; border-radius: 20px; color: #fff; }
.cgt-ctx-pill.ctx-g { background: #4f6bed; }
.cgt-ctx-pill.ctx-t { background: #e5484d; }
.cgt-ctx-pill.ctx-c { background: #6b7280; }

/* ============================================================
   Notificações (sino + painel) — v3
   ============================================================ */
.cgt-bell { position: relative; background: none; border: 0; font-size: 1.25rem; cursor: pointer; line-height: 1; padding: .3rem; }
.cgt-bell-badge {
  position: absolute; top: -2px; right: -2px; background: #e5484d; color: #fff;
  font-size: .6rem; font-weight: 700; min-width: 16px; height: 16px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center; padding: 0 4px;
}
.cgt-notif-panel {
  position: fixed; top: 0; right: 0; height: 100vh; width: 360px; max-width: 90vw;
  background: #fff; box-shadow: -8px 0 30px rgba(0,0,0,.18); z-index: 1060;
  transform: translateX(105%); transition: transform .25s ease; display: flex; flex-direction: column;
}
.cgt-notif-panel.show { transform: translateX(0); }
.cgt-notif-head { display: flex; align-items: center; justify-content: space-between; padding: 1rem 1.1rem; border-bottom: 1px solid #eef0f5; }
.cgt-notif-body { overflow-y: auto; flex: 1; padding: .5rem; }
.cgt-notif-item { padding: .7rem .8rem; border-radius: 10px; cursor: pointer; transition: background .12s; }
.cgt-notif-item:hover { background: #f5f7fb; }
.cgt-notif-item.nao-lida { background: #eef3ff; }
.cgt-notif-item.nao-lida:hover { background: #e4ecff; }

/* ============================================================
   MOBILE UX — reforço v3
   ============================================================ */
.cgt-topbar { position: sticky; top: 0; z-index: 1020; }

@media (max-width: 992px) {
  .cgt-content { padding: 1rem .85rem 4rem; }
  .cgt-topbar h1 { font-size: 1.05rem; }
  /* KPIs empilham bem e ficam tocáveis */
  .kpi { padding: .85rem .9rem; }
  .kpi .value { font-size: 1.15rem; }
  /* tabelas rolam horizontalmente com inércia */
  .table-responsive { -webkit-overflow-scrolling: touch; }
  table { font-size: .86rem; }
  /* botões e selects com área de toque maior */
  .btn-sm { padding: .4rem .7rem; }
  .form-select-sm, .form-control { min-height: 40px; }
  /* modais quase full-screen no celular */
  .modal-dialog { margin: .5rem; }
  .modal-content { border-radius: 14px; }
  /* nav pills roláveis sem quebrar */
  .nav-pills { flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch; padding-bottom: 4px; }
  .nav-pills .nav-link { white-space: nowrap; }
}

@media (max-width: 576px) {
  .cgt-content { padding: .8rem .7rem 4rem; }
  .kpi .value { font-size: 1.05rem; }
  .kpi .label { font-size: .68rem; }
  /* cards de clínica e afins com espaçamento confortável */
  .card-body { padding: 1rem; }
  /* esconde colunas marcadas como opcionais no mobile */
  .hide-sm { display: none !important; }
}

/* faz os KPIs sempre legíveis */
.kpi .value { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* botão flutuante de ação (mobile) */
.fab {
  position: fixed; bottom: 18px; right: 18px; z-index: 1030;
  width: 56px; height: 56px; border-radius: 50%; border: 0;
  background: var(--cgt-accent); color: #fff; font-size: 1.6rem; line-height: 1;
  box-shadow: 0 6px 18px rgba(79,107,237,.45); display: none;
}
@media (max-width: 768px) { .fab { display: flex; align-items: center; justify-content: center; } }
/* Prevent a raw page from flashing before the authenticated layout moves it into #page-host. Embedded historical sheets have their own bootstrap. */
html:not(.historic-embedded) body > #app ~ #page-content{visibility:hidden!important}
