/* ============================================================
   LUMÊ — Identidade visual (Manual de Marca, jul/2026)
   Primária #A39D96 · Secundária #B8B298 · Contraste #57524A
   Tipografia: Afacad Flux (primária) / Poppins (alternativa)
   ============================================================ */
:root {
  --lume-primary: #A39D96;
  --lume-secondary: #B8B298;
  --lume-dark: #57524A;
  --lume-dark-2: #4A463F;
  --lume-muted: #959CA2;
  --lume-bg: #F6F4F0;
  --lume-text: #3E3A34;

  /* Status (tons terrosos saturados para não brigar com a paleta da marca) */
  --lume-success: #5F6F56;
  --lume-warning: #8A642B;
  --lume-danger: #A05540;

  /* Bootstrap ajustado à marca: ações em taupe escuro (contraste) */
  --bs-primary: var(--lume-dark);
  --bs-primary-rgb: 87, 82, 74;
  --bs-success: var(--lume-success);
  --bs-success-rgb: 95, 111, 86;
  --bs-warning: var(--lume-warning);
  --bs-warning-rgb: 138, 100, 43;
  --bs-danger: var(--lume-danger);
  --bs-danger-rgb: 160, 85, 64;
  --bs-body-color: var(--lume-text);
  --bs-body-bg: var(--lume-bg);
  --bs-link-color: #57524A;
  --bs-link-hover-color: #3E3A34;
  --bs-body-font-family: "Afacad Flux", "Poppins", system-ui, -apple-system,
    "Segoe UI", sans-serif;
  --bs-border-radius: 0.5rem;
  --bs-border-radius-sm: 0.4rem;
  --bs-border-radius-lg: 0.75rem;
}

body {
  min-height: 100vh;
}

/* ---------- Bootstrap 5.3: botões usam variáveis POR COMPONENTE ----------
   O :root acima não muda .btn-*; por isso é preciso sobrescrever as
   variáveis --bs-btn-* de cada variante para aplicar a paleta da marca. */
.btn-primary {
  --bs-btn-color: #fff;
  --bs-btn-bg: var(--lume-dark);
  --bs-btn-border-color: var(--lume-dark);
  --bs-btn-hover-color: #fff;
  --bs-btn-hover-bg: var(--lume-dark-2);
  --bs-btn-hover-border-color: var(--lume-dark-2);
  --bs-btn-active-color: #fff;
  --bs-btn-active-bg: var(--lume-dark-2);
  --bs-btn-active-border-color: var(--lume-dark-2);
  --bs-btn-disabled-color: #fff;
  --bs-btn-disabled-bg: #908a81;
  --bs-btn-disabled-border-color: #908a81;
}
.btn-outline-primary {
  --bs-btn-color: var(--lume-dark);
  --bs-btn-border-color: var(--lume-secondary);
  --bs-btn-hover-color: #fff;
  --bs-btn-hover-bg: var(--lume-dark);
  --bs-btn-hover-border-color: var(--lume-dark);
  --bs-btn-active-color: #fff;
  --bs-btn-active-bg: var(--lume-dark);
  --bs-btn-active-border-color: var(--lume-dark);
}
.btn-success {
  --bs-btn-color: #fff;
  --bs-btn-bg: var(--lume-success);
  --bs-btn-border-color: var(--lume-success);
  --bs-btn-hover-color: #fff;
  --bs-btn-hover-bg: #6b775f;
  --bs-btn-hover-border-color: #6b775f;
  --bs-btn-active-bg: #6b775f;
  --bs-btn-active-border-color: #6b775f;
  --bs-btn-disabled-bg: #a7b09c;
  --bs-btn-disabled-border-color: #a7b09c;
}
.btn-outline-success {
  --bs-btn-color: var(--lume-success);
  --bs-btn-border-color: var(--lume-success);
  --bs-btn-hover-color: #fff;
  --bs-btn-hover-bg: var(--lume-success);
  --bs-btn-hover-border-color: var(--lume-success);
  --bs-btn-active-color: #fff;
  --bs-btn-active-bg: var(--lume-success);
  --bs-btn-active-border-color: var(--lume-success);
}
/* Foco com a cor da marca */
.form-control:focus, .form-select:focus, .btn:focus-visible {
  box-shadow: 0 0 0 0.2rem rgba(163, 157, 150, 0.35);
}
/* Badges de status: tons terrosos */
.badge.text-bg-success { background: var(--lume-success); color: #fff; }
.badge.text-bg-warning { background: var(--lume-warning); color: #fff; }
.badge.text-bg-danger { background: var(--lume-danger); color: #fff; }
.text-bg-primary { background: var(--lume-dark) !important; color: #fff !important; }
.text-bg-success { background: var(--lume-success) !important; color: #fff !important; }
/* Links e paginação na cor da marca */
.pagination .page-link { color: var(--lume-dark); }
.pagination .page-item.active .page-link { background: var(--lume-dark); border-color: var(--lume-dark); }
.dropdown-item.active, .dropdown-item:active { background: var(--lume-dark); }
.nav-pills .nav-link.active { background: var(--lume-dark); }

/* ---------- Navbar ---------- */
.navbar {
  box-shadow: 0 1px 0 rgba(87, 82, 74, 0.08);
}
.navbar-light .navbar-nav .nav-link {
  color: var(--lume-dark);
  font-weight: 500;
}
.navbar-light .navbar-nav .nav-link:hover {
  color: var(--lume-primary);
}
.navbar-light .navbar-nav .nav-link.active {
  color: var(--lume-dark);
  border-bottom: 2px solid var(--lume-primary);
}
.navbar-text {
  color: var(--lume-text);
}

/* ---------- Botões e badges ---------- */
.lume-badge {
  background: var(--lume-secondary);
  color: var(--lume-dark);
  font-weight: 600;
}
.lume-btn {
  --bs-btn-color: #fff;
  --bs-btn-bg: var(--lume-dark);
  --bs-btn-border-color: var(--lume-dark);
  --bs-btn-hover-color: #fff;
  --bs-btn-hover-bg: var(--lume-dark-2);
  --bs-btn-hover-border-color: var(--lume-dark-2);
  --bs-btn-active-color: #fff;
  --bs-btn-active-bg: var(--lume-dark-2);
  --bs-btn-active-border-color: var(--lume-dark-2);
  --bs-btn-disabled-color: #fff;
  --bs-btn-disabled-bg: #908a81;
  --bs-btn-disabled-border-color: #908a81;
  font-weight: 600;
}
.lume-btn-outline {
  color: var(--lume-dark);
  border: 1px solid var(--lume-secondary);
}
.lume-btn-outline:hover {
  background: var(--lume-secondary);
  color: var(--lume-dark);
}

/* ---------- Cards ---------- */
.card {
  border-color: rgba(87, 82, 74, 0.08);
  box-shadow: 0 1px 3px rgba(87, 82, 74, 0.06);
}
.card-header {
  background: #FBFAF7;
  color: var(--lume-dark);
}

/* ---------- Formulários ---------- */
.form-control,
.form-select {
  border-color: #D8D3CB;
}
.form-control:focus,
.form-select:focus {
  border-color: var(--lume-primary);
  box-shadow: 0 0 0 0.2rem rgba(163, 157, 150, 0.25);
}

/* ---------- Tabelas ---------- */
.table > :not(caption) > * > * {
  vertical-align: middle;
}
.table thead th {
  color: var(--lume-dark);
  font-weight: 600;
}

/* ---------- Login ---------- */
.lume-login-card {
  border: 0;
  border-top: 4px solid var(--lume-primary);
}

/* ---------- Impressão da anamnese ---------- */
@media print {
  .d-print-none,
  .navbar {
    display: none !important;
  }
  body {
    background: #fff;
  }
  .container {
    max-width: 100% !important;
  }
}

/* ---------- Agenda (estilo Google Calendar) ---------- */
.agenda-week {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 1px;
  background: #e7e3dd;
  border: 1px solid #e7e3dd;
  border-radius: 0.5rem;
  overflow: hidden;
}
.agenda-day {
  background: #fff;
  min-height: 320px;
  display: flex;
  flex-direction: column;
}
.agenda-today {
  background: #fbfaf7;
}
.agenda-day-head {
  padding: 0.5rem;
  text-align: center;
  border-bottom: 1px solid #eee9e2;
  background: #f6f4f0;
}
.agenda-today .agenda-day-head {
  background: #ece9e2;
}
.agenda-day-name {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--lume-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.agenda-day-num {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--lume-text);
}
.agenda-day-body {
  padding: 0.4rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  flex: 1;
  overflow-y: auto;
}
.agenda-slot {
  border: 0;
  border-radius: 0.4rem;
  background: var(--lume-bg);
  border-left: 3px solid var(--lume-primary);
  padding: 0.3rem 0.5rem;
  text-align: left;
  width: 100%;
  transition: background 0.15s ease, transform 0.1s ease;
}
.agenda-slot:hover {
  background: #ece9e2;
  transform: translateY(-1px);
}
.agenda-slot-time {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--lume-dark);
}
.agenda-slot-doctor {
  font-size: 0.72rem;
  color: var(--lume-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.agenda-slot-patient {
  background: #eef3f7;
  border-left-color: #7fa8c9;
  cursor: pointer;
}
.agenda-slot-patient:hover {
  background: #e2ecf3;
}
.agenda-empty {
  font-size: 0.8rem;
  text-align: center;
  color: #cfc9c0;
  padding-top: 1rem;
}
/* ---------- Agenda: grade em timeline continua ---------- */
#agendaGrid {
  overflow-x: auto;
}
.tl {
  display: flex;
  min-width: 720px;
  background: #fff;
}
.tl-axis {
  flex: 0 0 52px;
  width: 52px;
  background: #faf9f6;
  border-right: 1px solid #e7e3dd;
  position: relative;
}
.tl-axis-inner {
  position: relative;
}
.tl-axis-label {
  position: absolute;
  right: 6px;
  transform: translateY(-50%);
  font-size: 0.68rem;
  font-variant-numeric: tabular-nums;
  color: #a39d94;
}
.tl-cols {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
}
.tl-day {
  display: flex;
  flex-direction: column;
  min-width: 0;
  border-right: 1px solid #eee9e2;
}
.tl-day:last-child { border-right: 0; }
.tl-day-head {
  padding: 0.3rem 0.35rem;
  overflow: hidden;
  text-align: center;
  background: #f6f4f0;
  border-bottom: 1px solid #eee9e2;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 1px;
}
.tl-today .tl-day-head { background: #ece9e2; }
.tl-day-name {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--lume-muted);
}
.tl-day-num {
  font-size: 1rem;
  font-weight: 700;
  color: var(--lume-text);
  line-height: 1.1;
}
.tl-today .tl-day-num { color: var(--lume-primary); }
.tl-day-free {
  font-size: 0.62rem;
  font-weight: 600;
  color: #4F6247;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tl-day-free.is-full { color: #a8a29a; }
.tl-day-free.is-holiday { color: #8A642B; }
.tl-day-free.is-blocked { color: #A05540; font-weight: 700; }
.tl-day-free.is-empty { color: #cfc9c0; font-weight: 400; }
.tl-day-body {
  position: relative;
  display: flex;
  gap: 2px;
  background-image: linear-gradient(to bottom, #efebe5 1px, transparent 1px);
  background-size: 100% var(--tl-hour, 69px);
  background-repeat: repeat-y;
}
.tl-lane {
  position: relative;
  flex: 1;
  min-width: 0;
}
.tl-day-lanes {
  display: flex;
  gap: 2px;
  margin-top: 1px;
}
.tl-day-lane {
  flex: 1;
  min-width: 0;
  font-size: 0.58rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tl-now {
  position: absolute;
  left: 0;
  right: 0;
  height: 2px;
  background: #c0563f;
  z-index: 6;
}
.tl-now::before {
  content: "";
  position: absolute;
  left: -3px;
  top: -3px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #c0563f;
}
.tl-appt {
  position: absolute;
  left: 2px;
  right: 2px;
  border-radius: 0.35rem;
  border-left: 3px solid var(--lane-color, #5b8cb8);
  background: #e7f0f7;
  padding: 0.12rem 0.3rem;
  overflow: hidden;
  font-size: 0.72rem;
  z-index: 3;
}
/* Cor do bloco por status (a legenda acima da grade explica cada cor) */
.tl-appt[data-status="agendado"] { background: #E6E2DC; border-left-color: #6E6862; }
.tl-appt[data-status="agendado"] .tl-appt-time { color: #4A4640; }
.tl-appt[data-status="confirmado"] { background: #DCE8D6; border-left-color: #4F6247; }
.tl-appt[data-status="confirmado"] .tl-appt-time { color: #3A4A34; }
.tl-appt[data-status="em_andamento"] { background: #F7E6C8; border-left-color: #8A642B; }
.tl-appt[data-status="em_andamento"] .tl-appt-time { color: #6B4B1E; }
.tl-appt[data-status="realizado"] { background: #D8E5F0; border-left-color: #3F6C8F; }
.tl-appt[data-status="realizado"] .tl-appt-time { color: #2F5169; }
/* Faturada: verde mais fechado com hachura leve (distingue de "confirmado") */
.tl-appt[data-status="faturado"] {
  background: #C9DFC1;
  background-image: repeating-linear-gradient(
    45deg, rgba(62, 107, 58, 0.10) 0 5px, transparent 5px 10px
  );
  border-left-color: #3E6B3A;
}
.tl-appt[data-status="faturado"] .tl-appt-time { color: #2F5229; }
.tl-appt-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.15rem;
}
.tl-appt-time {
  font-size: 0.66rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: #4a4a4a;
  white-space: nowrap;
}
.tl-appt-name {
  font-weight: 600;
  color: var(--lume-dark);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.2;
}
.tl-appt-meta {
  font-size: 0.62rem;
  color: #6b665f;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tl-appt.is-compact { padding-top: 0; padding-bottom: 0; }
.tl-appt.is-compact .tl-appt-meta { display: none; }
.tl-appt.is-compact .tl-appt-name { font-size: 0.66rem; }
.tl-appt-actions {
  display: inline-flex;
  gap: 0.05rem;
  opacity: 0;
  transition: opacity 0.12s ease;
}
.tl-appt:hover .tl-appt-actions,
.tl-appt:focus-within .tl-appt-actions { opacity: 1; }
.tl-appt-btn {
  border: 0;
  background: rgba(255, 255, 255, 0.7);
  color: #4a4a4a;
  font-size: 0.66rem;
  line-height: 1;
  padding: 0.12rem 0.2rem;
  border-radius: 0.2rem;
  text-decoration: none;
}
.tl-appt-btn:hover { background: #fff; color: #000; }
.tl-free {
  position: absolute;
  left: 2px;
  right: 2px;
  border: 1px dashed #d5cfc6;
  background: #fcfbf8;
  border-radius: 0.35rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0;
  padding: 0 0.2rem;
  color: #8d877e;
  font-size: 0.66rem;
  font-weight: 600;
  cursor: pointer;
  overflow: hidden;
  z-index: 2;
  transition: background 0.12s ease, border-color 0.12s ease, color 0.12s ease;
}
.tl-free:hover {
  background: #f1efe9;
  border-color: var(--lume-primary);
  color: var(--lume-dark);
}
.tl-free-range {
  font-size: 0.6rem;
  font-weight: 400;
  color: #a8a29a;
  font-variant-numeric: tabular-nums;
}
.tl-free.is-short .tl-free-range { display: none; }
.tl-free { pointer-events: none; }
/* Camada de células da grade: clique agenda, arraste define a duração */
.tl-cells {
  position: absolute;
  left: 2px;
  right: 2px;
  z-index: 2;
  display: flex;
  flex-direction: column;
}
.tl-cell {
  position: absolute;
  left: 0;
  right: 0;
  border: 0;
  background: transparent;
  border-radius: 0.2rem;
  padding: 0;
  cursor: pointer;
  touch-action: manipulation;
}
.tl-cell::after {
  content: "+";
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--lume-primary);
  opacity: 0;
  transition: opacity 0.1s ease;
}
.tl-cell:hover { background: rgba(110, 104, 98, 0.08); }
.tl-cell:hover::after { opacity: 0.55; }
.tl-cell.is-selected {
  background: rgba(79, 98, 71, 0.18);
  box-shadow: inset 0 0 0 1px rgba(79, 98, 71, 0.55);
}
.tl-cell.is-selected::after { opacity: 0; }
/* Alça para esticar a consulta */
.tl-appt-resize {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 7px;
  cursor: ns-resize;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.56rem;
  font-weight: 700;
  color: #4a4a4a;
  opacity: 0;
  touch-action: none;
}
.tl-appt-resize::after {
  content: "";
  width: 26px;
  height: 3px;
  border-radius: 2px;
  background: rgba(74, 74, 74, 0.35);
}
.tl-appt:hover .tl-appt-resize { opacity: 1; }
.tl-appt.is-resizing { z-index: 8; box-shadow: 0 4px 14px rgba(0, 0, 0, 0.18); }
.tl-appt.is-resizing .tl-appt-resize {
  opacity: 1;
  background: rgba(255, 255, 255, 0.85);
  height: 14px;
  justify-content: flex-start;
  padding-left: 3px;
}
.tl-appt.is-resizing .tl-appt-resize::after { display: none; }
.tl-appt.is-clamped { outline: 2px solid #c0563f; }
/* Arrastar o bloco para outro dia/horário */
.tl-appt.is-moving {
  opacity: 0.35;
  pointer-events: none;
  cursor: grabbing;
}
.tl-appt { cursor: grab; }
.tl-appt.is-moving { cursor: grabbing; }
.tl-ghost {
  position: absolute;
  left: 2px;
  right: 2px;
  z-index: 7;
  border: 2px dashed #4F6247;
  border-radius: 0.35rem;
  background: rgba(79, 98, 71, 0.12);
  color: #3d4d37;
  font-size: 0.64rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  overflow: hidden;
  white-space: nowrap;
}
#bkDurHint:empty { display: none; }
.tl-free.is-tiny { cursor: default; border-style: dotted; }
.tl-free.is-tiny:hover { background: #fcfbf8; border-color: #d5cfc6; color: #8d877e; }
.tl-empty {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #cfc9c0;
  font-size: 0.8rem;
}

/* ---------- Ajustes (hub de configurações) ---------- */
.lume-setting {
  color: inherit;
  border: 1px solid #e7e3dd;
  transition: border-color 0.12s ease, transform 0.12s ease;
}
.lume-setting:hover {
  border-color: var(--lume-primary);
  transform: translateY(-1px);
}
.lume-setting-icon {
  flex: 0 0 38px;
  width: 38px;
  height: 38px;
  border-radius: 0.5rem;
  background: var(--lume-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--lume-dark);
  font-size: 1.05rem;
}
.min-w-0 { min-width: 0; }

/* ---------- Início (painel do dia) ---------- */
.lume-kpi {
  color: inherit;
  border: 1px solid #e7e3dd;
  transition: border-color 0.12s ease, transform 0.12s ease;
}
.lume-kpi:hover {
  border-color: var(--lume-primary);
  transform: translateY(-1px);
}
.lume-kpi-label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--lume-muted);
  font-weight: 600;
}
.lume-kpi-value {
  font-size: 1.65rem;
  font-weight: 700;
  line-height: 1.15;
  color: var(--lume-dark);
  font-variant-numeric: tabular-nums;
}
.lume-kpi-money { font-size: 1.25rem; }

/* Telas intermediárias (~1024–1200): tabelas mais compactas para caber
   sem esconder a coluna de ações atrás do scroll horizontal. */
@media (max-width: 1199.98px) {
  .table { font-size: 0.86rem; }
  .table > :not(caption) > * > * { padding: 0.32rem 0.4rem; }
  .table .btn-sm { padding: 0.12rem 0.34rem; font-size: 0.75rem; }
  .table .badge { font-size: 0.68rem; }
}

/* ---------- Responsividade (mobile + desktop) ---------- */
@media (max-width: 767.98px) {
  .container, .container-fluid {
    padding-left: 0.75rem;
    padding-right: 0.75rem;
  }
  main.container { padding-top: 1rem; padding-bottom: 1rem; }
  /* Botões de ação empilháveis em telas estreitas */
  .d-flex.gap-2.flex-wrap, .d-flex.gap-3.flex-wrap { gap: 0.4rem !important; }
  /* Campos maiores para toque */
  .btn { min-height: 0; }
  .form-control, .form-select { font-size: 1rem; }
  /* Cards com respiro menor */
  .card-body { padding: 1rem; }
  /* Tabelas: rolagem horizontal (garantia mesmo sem .table-responsive) */
  .table-responsive, .table { display: block; overflow-x: auto; white-space: nowrap; }
  .table-responsive .table { display: table; }
}

/* Tabela dentro de .table-responsive mantém largura da célula */
.table-responsive > .table { white-space: nowrap; }

/* Editor de texto rico (ToastUI) em telas pequenas */
@media (max-width: 767.98px) {
  .toastui-editor-defaultUI {
    min-width: 0;
    max-width: 100%;
  }
  .toastui-editor-toolbar {
    white-space: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  .toastui-editor-toolbar-group {
    flex-wrap: nowrap;
  }
  .tui-editor-contents { font-size: 1rem; }
}

/* Grupos de botões de ações (Ver/Editar/PDF) quebram linha no mobile */
.btn-group-sm, .d-flex.gap-2 { flex-wrap: wrap; }

/* Evita overflow horizontal de elementos amplos */
img, video, iframe { max-width: 100%; }

/* Badges de status (tabela e outras telas) */
.badge-status { color: #fff; font-weight: 600; }
.badge-status-agendado { background: #6E6862; }
.badge-status-confirmado { background: #4F6247; }
.badge-status-em_andamento { background: #8A642B; }
.badge-status-realizado { background: #3F6C8F; }
.badge-status-faturado { background: #3E6B3A; }
.badge-status-cancelado { background: #A05540; }

/* Legenda de cores */
.agenda-legenda {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 1rem;
  font-size: 0.78rem;
  color: var(--lume-text);
}
.agenda-legenda .item {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}
.agenda-legenda .chip {
  width: 0.85rem;
  height: 0.85rem;
  border-radius: 0.2rem;
  display: inline-block;
}
