/* TechClinix - Admin Layout */

:root {
  /* Marca — paleta Clinix (tema claro) */
  --color-bg: #F6FAF9;
  --color-surface: #FFFFFF;
  --color-sidebar: #0F2E2A;
  --color-sidebar-hover: #1B4741;
  /* Teal um tom abaixo do #0E9488 da paleta: com o original, texto branco
     rende só 3.7:1 e reprova AA. Neste, 5.2:1 — mantém o branco habitual
     em botões e superfícies primárias. */
  --color-primary: #0B7A70;
  --color-primary-hover: #096B62;
  --color-accent: #E07856;
  --color-text: #12312C;
  --color-text-muted: #52706B;
  --color-text-light: #8AA5A0;
  --color-border: #DDE9E6;
  --color-success: #0E9488;
  --color-error: #D4553A;
  /* Escurecido pelo mesmo motivo do primário: no tom original o branco
     rendia 3.2:1. Aqui, 4.6:1. */
  --color-warning: #A66714;

  /* Feedback — superfícies e texto (badges, alerts, stat icons) */
  --color-success-bg: #DCF2EE;
  --color-success-border: #A7DED6;
  --color-success-text: #0B5E56;
  --color-warning-bg: #FBF0DC;
  --color-warning-border: #F0D9A8;
  --color-warning-text: #8A5A12;
  --color-error-bg: #FBE6E0;
  --color-error-border: #F2C4B7;
  --color-error-text: #963521;
  --color-info-bg: #DFF0EE;
  --color-info-text: #0B5E56;
  --color-neutral-bg: #EEF3F2;

  /* Marca — tokens fixos do logo.
     NÃO são redefinidos no tema escuro: o Selo Cruz carrega o próprio fundo e
     deve ficar idêntico em qualquer superfície (incl. favicon). */
  --color-brand-seal: #0E9488;
  --color-brand-seal-cross: #F6FAF9;
  --color-brand-tech-on-dark: #34C4B2;

  /* Superfícies sutis derivadas da marca */
  --color-surface-danger: #FEFAF9;
  --color-overlay: rgba(15, 46, 42, 0.45);
  --color-on-dark: #FFFFFF;
  /* Texto sobre superfícies na cor primária e de aviso (botões, nav ativo,
     chips). Branco no claro; no escuro as cores clareiam e o token é
     redefinido para um tom escuro (ver [data-theme="dark"]). */
  --color-on-primary: #FFFFFF;
  --color-on-warning: #FFFFFF;
  /* Divisórias internas da sidebar (fundo escuro nos dois temas) */
  --color-sidebar-divider: rgba(255, 255, 255, 0.1);

  --shadow-sm: 0 1px 2px 0 rgb(15 46 42 / 0.05);
  --shadow: 0 1px 3px 0 rgb(15 46 42 / 0.1), 0 1px 2px -1px rgb(15 46 42 / 0.1);
  --radius: 8px;
  /* Altura da faixa superior. Sidebar e topbar compartilham para as bordas
     inferiores se alinharem — sem isto o corte fica torto entre as duas. */
  --topbar-height: 69px;

  /* Tipografia */
  --font-display: 'Sora', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-body: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

/*
 * Tema escuro. Aplicado pelo atributo data-theme no <html>: o script inline do
 * layout o define antes do primeiro paint (preferência salva, ou a do sistema
 * na primeira visita) e o theme_controller alterna depois.
 */
[data-theme="dark"] {
  --color-bg: #0A1614;
  --color-surface: #122421;
  /* Mais clara que o --color-bg de propósito: com os dois no mesmo tom a
     sidebar se dissolvia no conteúdo e perdia a separação. */
  --color-sidebar: #122E29;
  --color-sidebar-hover: #1E453E;
  --color-sidebar-divider: rgba(255, 255, 255, 0.08);
  --color-primary: #34C4B2;
  --color-primary-hover: #5BD5C6;
  --color-accent: #E88D6E;
  --color-text: #E7F2F0;
  --color-text-muted: #9FBAB5;
  --color-text-light: #7A958F;
  --color-border: #1E3733;
  --color-error: #E8785C;
  --color-warning: #E0A83C;
  --color-success: #34C4B2;

  /* Feedback no escuro: superfícies profundas e texto claro. Sem isto os
     badges e alerts manteriam os pastéis do tema claro e destoariam. */
  --color-success-bg: #10302C;
  --color-success-border: #1E4A44;
  --color-success-text: #6FD9C9;
  --color-warning-bg: #322611;
  --color-warning-border: #4C3A1B;
  --color-warning-text: #E8BC63;
  --color-error-bg: #331913;
  --color-error-border: #4D2820;
  --color-error-text: #F0A08A;
  --color-info-bg: #10302C;
  --color-info-text: #6FD9C9;
  --color-neutral-bg: #1A2E2B;

  --color-surface-danger: #1A1310;
  --color-overlay: rgba(6, 14, 13, 0.6);
  /* No escuro o primário e o aviso clareiam: o texto por cima inverte para
     um tom escuro, senão o contraste desaba (branco sobre teal claro = 2.2:1). */
  --color-on-primary: #05201C;
  --color-on-warning: #2E1D03;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.5;
  color: var(--color-text);
  background: var(--color-bg);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

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

/* Sidebar */
.sidebar {
  width: 250px;
  background: var(--color-sidebar);
  color: var(--color-on-dark);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 40;
  transition: transform 0.25s ease, width 0.2s ease;
}

.sidebar-header {
  height: var(--topbar-height);
  padding: 0 24px;
  border-bottom: 1px solid var(--color-sidebar-divider);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

/* Off-canvas controls (hidden on desktop) */
.sidebar-backdrop {
  display: none;
}

.sidebar-close,
.sidebar-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  padding: 6px;
  border: 0;
  background: transparent;
  border-radius: 6px;
  cursor: pointer;
  color: inherit;
  transition: background 0.15s ease;
}

.sidebar-close {
  color: var(--color-text-light);
}

.sidebar-close:hover {
  background: var(--color-sidebar-hover);
  color: var(--color-on-dark);
}

.sidebar-toggle {
  color: var(--color-text-muted);
  margin-right: 4px;
}

.sidebar-toggle:hover {
  background: var(--color-bg);
  color: var(--color-text);
}

/* Revisão em execução (ver config/initializers/app_version.rb) */
.sidebar-version {
  margin-top: auto;
  padding: 10px 16px;
  border-top: 1px solid var(--color-sidebar-divider);
  font-size: 11px;
  font-family: ui-monospace, monospace;
  color: var(--color-text-light);
  text-align: center;
  opacity: 0.7;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* No rail de 72px não cabe — o title do elemento mantém a informação */
.layout.sidebar-collapsed .sidebar-version {
  display: none;
}

/* Collapse button (desktop only) — rodapé da sidebar, largura total */
.sidebar-collapse {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: 10px 6px;
  border: 0;
  border-top: 1px solid var(--color-sidebar-divider);
  background: transparent;
  cursor: pointer;
  color: var(--color-text-light);
  transition: background 0.15s ease, color 0.15s ease;
}

.sidebar-collapse:hover {
  background: var(--color-sidebar-hover);
  color: var(--color-on-dark);
}

.sidebar-collapse .material-symbols-outlined {
  transition: transform 0.2s ease;
}

/* Marca — lockup Selo Cruz + wordmark (ver app/views/shared/_logo.html.erb) */
.logo {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.5px;
}

.logo-mark {
  flex-shrink: 0;
}

.logo-wordmark {
  white-space: nowrap;
}

/* Wordmark sobre fundo claro: "tech" teal + "clinix" deep */
.logo-tech {
  color: var(--color-primary);
}

.logo-clinix {
  color: var(--color-text);
}

/* Na sidebar (fundo deep) o wordmark inverte: teal claro + branco */
.sidebar .logo-tech {
  color: var(--color-brand-tech-on-dark);
}

.sidebar .logo-clinix {
  color: var(--color-on-dark);
}

.sidebar-nav {
  flex: 1;
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  color: var(--color-text-light);
  text-decoration: none;
  border-radius: 6px;
  transition: all 0.15s ease;
  font-size: 14px;
  font-weight: 500;
}

.nav-item:hover {
  background: var(--color-sidebar-hover);
  color: var(--color-on-dark);
}

.nav-item.active {
  background: var(--color-primary);
  color: var(--color-on-primary);
}

.nav-item .material-symbols-outlined {
  font-size: 22px;
}






/* Main Content */
.main-content {
  flex: 1;
  margin-left: 250px;
  display: flex;
  flex-direction: column;
  transition: margin-left 0.2s ease;
}

/* Suspende animações durante o resize da janela (ver sidebar_controller.js) */
.layout.sidebar-no-transition .sidebar,
.layout.sidebar-no-transition .main-content {
  transition: none;
}

.topbar {
  background: var(--color-surface);
  /* Altura fixa: o conteúdo varia por tela (voltar, badge, avatar têm alturas
     diferentes do título) e sem isto a barra mudava de tamanho na navegação. */
  height: var(--topbar-height);
  padding: 0 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--color-border);
  position: sticky;
  top: 0;
  z-index: 10;
}

/* Voltar + título andam juntos à esquerda da topbar */
.topbar-title {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.page-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 600;
}

/* O badge de status acompanha o título sem herdar seu peso/tamanho */
.page-title .badge {
  font-family: var(--font-body);
  font-weight: 500;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 24px;
}

.clinic-selector {
  display: flex;
  align-items: center;
  gap: 8px;
}

.clinic-selector .material-symbols-outlined {
  color: var(--color-text-muted);
  font-size: 20px;
}

.clinic-select {
  padding: 8px 12px;
  font-size: 13px;
  font-weight: 500;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  background: var(--color-surface);
  color: var(--color-text);
  cursor: pointer;
  min-width: 180px;
}

.clinic-select:focus {
  outline: none;
  border-color: var(--color-primary);
}

.current-date {
  color: var(--color-text-muted);
  font-size: 13px;
}

/* Alternador de tema claro/escuro (ver controllers/theme_controller.js) */
.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--color-text-muted);
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.theme-toggle:hover {
  background: var(--color-neutral-bg);
  color: var(--color-text);
}

.theme-toggle .material-symbols-outlined {
  font-size: 20px;
}

/* Menu do usuário (ver controllers/dropdown_controller.js) */
.user-menu {
  position: relative;
  display: inline-flex;
}

.user-menu-panel {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 50;
  min-width: 200px;
  padding: 6px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  background: var(--color-surface);
  box-shadow: var(--shadow);
}

.user-menu-panel[hidden] {
  display: none;
}

.user-menu-header {
  display: flex;
  flex-direction: column;
  padding: 8px 10px 10px;
  border-bottom: 1px solid var(--color-border);
  margin-bottom: 6px;
}

.user-menu-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--color-text);
}

.user-menu-role {
  font-size: 12px;
  color: var(--color-text-muted);
}

.user-menu-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 6px;
  color: var(--color-text);
  font-size: 13px;
  text-decoration: none;
  transition: background 0.15s ease, color 0.15s ease;
}

.user-menu-item:hover {
  background: var(--color-neutral-bg);
  color: var(--color-error);
  text-decoration: none;
}

.user-menu-item .material-symbols-outlined {
  font-size: 18px;
}

/* Avatar com as iniciais do usuário (ver User#initials) */
.topbar-avatar {
  border: 0;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--color-primary);
  color: var(--color-on-primary);
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.02em;
  flex-shrink: 0;
  user-select: none;
}

.content {
  padding: 32px;
  flex: 1;
}

/* Alerts */
.alert {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  margin: 16px 32px 0;
  border-radius: var(--radius);
  font-size: 14px;
}

.alert-success {
  background: var(--color-success-bg);
  color: var(--color-success-text);
  border: 1px solid var(--color-success-border);
}

.alert-error {
  background: var(--color-error-bg);
  color: var(--color-error-text);
  border: 1px solid var(--color-error-border);
}

.alert .material-symbols-outlined {
  font-size: 20px;
}

/* Diálogo de confirmação (ver shared/_confirm_dialog.html.erb) */
.confirm-dialog {
  width: min(480px, calc(100vw - 32px));
  /* O <dialog> só centraliza sozinho sem largura definida; com ela, o auto
     nas quatro margens é o que o mantém no meio da viewport. */
  margin: auto;
  padding: 28px;
  border: 1px solid var(--color-border);
  border-radius: 12px;
  background: var(--color-surface);
  color: var(--color-text);
  box-shadow: 0 16px 40px rgb(15 46 42 / 0.22);
}

.confirm-dialog::backdrop {
  background: var(--color-overlay);
}

.confirm-dialog-header {
  display: flex;
  align-items: flex-start;
  gap: 16px;
}

.confirm-dialog-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  flex-shrink: 0;
  border-radius: 50%;
  background: var(--color-info-bg);
  color: var(--color-info-text);
  font-size: 24px;
}

/* Ações destrutivas ganham o tom de erro no ícone e no botão de aceite */
.confirm-dialog[data-variant="danger"] .confirm-dialog-icon {
  background: var(--color-error-bg);
  color: var(--color-error-text);
}

.confirm-dialog[data-variant="danger"] [data-confirm-accept] {
  background: var(--color-error);
  color: var(--color-on-primary);
}

.confirm-dialog[data-variant="warning"] .confirm-dialog-icon {
  background: var(--color-warning-bg);
  color: var(--color-warning-text);
}

.confirm-dialog-heading {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.confirm-dialog-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 700;
  line-height: 1.3;
}

.confirm-dialog-message {
  margin: 0;
  font-size: 14px;
  line-height: 1.6;
  color: var(--color-text-muted);
}

.confirm-dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 28px;
}

/* Toasts — notificações flash sobrepostas (ver shared/_toasts.html.erb) */
.toasts {
  position: fixed;
  bottom: 16px;
  right: 16px;
  z-index: 80;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: min(400px, calc(100vw - 32px));
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  border-radius: var(--radius);
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  box-shadow: var(--shadow);
  font-size: 14px;
  pointer-events: auto;
  opacity: 0;
  transform: translateX(16px);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.toast.toast-visible {
  opacity: 1;
  transform: translateX(0);
}

@media (prefers-reduced-motion: reduce) {
  .toast {
    transition: none;
    transform: none;
  }
}

.toast-success {
  border-color: var(--color-success-border);
  background: var(--color-success-bg);
  color: var(--color-success-text);
}

.toast-error {
  border-color: var(--color-error-border);
  background: var(--color-error-bg);
  color: var(--color-error-text);
}

.toast-message {
  flex: 1;
  min-width: 0;
  line-height: 1.5;
}

.toast .material-symbols-outlined {
  font-size: 20px;
  flex-shrink: 0;
}

.toast-close {
  display: inline-flex;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  cursor: pointer;
  opacity: 0.7;
  transition: opacity 0.15s ease;
}

.toast-close:hover {
  opacity: 1;
}

.toast-close .material-symbols-outlined {
  font-size: 18px;
}

/* Cards */
.card {
  background: var(--color-surface);
  border-radius: var(--radius);
  border: 1px solid var(--color-border);
  padding: 24px;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.card-title {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 600;
}

.card-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Stats Grid */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 24px;
  margin-bottom: 32px;
}

.stat-card {
  background: var(--color-surface);
  border-radius: var(--radius);
  border: 1px solid var(--color-border);
  padding: 24px;
  display: flex;
  align-items: flex-start;
  gap: 16px;
}

.stat-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.stat-icon .material-symbols-outlined {
  font-size: 24px;
}

.stat-icon.blue {
  background: var(--color-info-bg);
  color: var(--color-primary);
}

.stat-icon.green {
  background: var(--color-success-bg);
  color: var(--color-success);
}

.stat-icon.yellow {
  background: var(--color-warning-bg);
  color: var(--color-warning);
}

.stat-icon.red {
  background: var(--color-error-bg);
  color: var(--color-error);
}

.stat-content {
  display: flex;
  flex-direction: column;
}

.stat-value {
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 700;
  line-height: 1;
}

.stat-label {
  font-size: 13px;
  color: var(--color-text-muted);
  margin-top: 4px;
}

/* Tables */
.table-wrapper {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th, td {
  padding: 12px 16px;
  text-align: left;
  border-bottom: 1px solid var(--color-border);
}

th {
  font-size: 12px;
  font-weight: 600;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

td {
  font-size: 14px;
}

tbody tr:hover {
  background: var(--color-bg);
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 9999px;
  font-size: 12px;
  font-weight: 500;
}

.badge-success {
  background: var(--color-success-bg);
  color: var(--color-success-text);
}

.badge-warning {
  background: var(--color-warning-bg);
  color: var(--color-warning-text);
}

.badge-error {
  background: var(--color-error-bg);
  color: var(--color-error-text);
}

.badge-info {
  background: var(--color-info-bg);
  color: var(--color-info-text);
}

.badge-secondary {
  background: var(--color-neutral-bg);
  color: var(--color-text-muted);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  font-size: 14px;
  font-weight: 500;
  border-radius: 6px;
  border: none;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.15s ease;
}

.btn-primary {
  background: var(--color-primary);
  color: var(--color-on-primary);
}

.btn-primary:hover {
  background: var(--color-primary-hover);
}

.btn-secondary {
  background: var(--color-surface);
  color: var(--color-text);
  border: 1px solid var(--color-border);
}

.btn-secondary:hover {
  background: var(--color-bg);
}

.btn-warning {
  background: var(--color-warning);
  color: var(--color-on-warning);
}

.btn-warning:hover {
  filter: brightness(0.92);
}

.btn:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

/* Forms */
.form-group {
  margin-bottom: 20px;
}

.form-label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--color-text);
  margin-bottom: 6px;
}

.form-input {
  width: 100%;
  padding: 10px 14px;
  font-family: inherit;
  font-size: 14px;
  /* Sem isto o campo herda o preto padrão do navegador e fica ilegível no
     tema escuro (contraste 1.3:1). */
  color: var(--color-text);
  border: 1px solid var(--color-border);
  border-radius: 6px;
  background: var(--color-surface);
  transition: all 0.15s ease;
}

.form-input:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgb(14 148 136 / 0.15);
}

.form-input::placeholder {
  color: var(--color-text-light);
}

/* Auth Layout */
.auth-layout {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: var(--color-bg);
}

.auth-card {
  width: 100%;
  max-width: 400px;
  background: var(--color-surface);
  border-radius: var(--radius);
  border: 1px solid var(--color-border);
  padding: 40px;
  box-shadow: var(--shadow);
}

.auth-header {
  text-align: center;
  margin-bottom: 32px;
}

.auth-logo {
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 700;
  color: var(--color-text);
  margin-bottom: 8px;
}

.auth-subtitle {
  font-size: 14px;
  color: var(--color-text-muted);
}

.auth-form .form-group:last-of-type {
  margin-bottom: 24px;
}

.auth-form .btn {
  width: 100%;
}

.auth-links {
  margin-top: 24px;
  text-align: center;
  font-size: 13px;
  color: var(--color-text-muted);
}

.auth-links a {
  color: var(--color-primary);
  text-decoration: none;
}

.auth-links a:hover {
  text-decoration: underline;
}

/* Error messages */
.field_with_errors {
  display: contents;
}

.field_with_errors input {
  border-color: var(--color-error);
}

#error_explanation {
  background: var(--color-error-bg);
  border: 1px solid var(--color-error-border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 20px;
}

#error_explanation h2 {
  font-size: 14px;
  font-weight: 600;
  color: var(--color-error-text);
  margin-bottom: 8px;
}

#error_explanation ul {
  margin: 0;
  padding-left: 20px;
  font-size: 13px;
  color: var(--color-error-text);
}

/* Checkbox / Remember me */
.form-checkbox {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--color-text-muted);
}

.form-checkbox input {
  width: 16px;
  height: 16px;
}

/* Empty State */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--color-text-muted);
}

.empty-state .material-symbols-outlined {
  font-size: 48px;
  margin-bottom: 16px;
  opacity: 0.5;
}

.empty-state p {
  font-size: 14px;
}

.empty-state .text-muted {
  font-size: 13px;
  margin-top: 4px;
}

/* Inline code */
code {
  background: var(--color-bg);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 13px;
  font-family: ui-monospace, monospace;
}

/* Page Header */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}

/* Sem título (já está na topbar): as ações encostam à direita */
.page-header-actions-only {
  justify-content: flex-end;
}

.page-header h2 {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 600;
}

.page-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.back-link {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  color: var(--color-text-muted);
  transition: all 0.15s ease;
}

.back-link:hover {
  background: var(--color-border);
  color: var(--color-text);
}

/* Clínicas inativas: seção recolhível abaixo das ativas */
.clinics-inactive {
  margin-top: 32px;
}

.clinics-inactive-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 6px;
  color: var(--color-text-muted);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  list-style: none;
  user-select: none;
  transition: background 0.15s ease, color 0.15s ease;
}

.clinics-inactive-toggle::-webkit-details-marker {
  display: none;
}

.clinics-inactive-toggle:hover {
  background: var(--color-neutral-bg);
  color: var(--color-text);
}

.clinics-inactive-toggle .material-symbols-outlined {
  font-size: 20px;
  transition: transform 0.2s ease;
}

.clinics-inactive[open] .clinics-inactive-toggle .material-symbols-outlined {
  transform: rotate(180deg);
}

.clinics-inactive-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 9999px;
  background: var(--color-neutral-bg);
  font-size: 12px;
  font-weight: 600;
}

.clinics-inactive .clinics-grid {
  margin-top: 16px;
}

/* Clinics Grid */
.clinics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 24px;
}

.clinic-card-link {
  text-decoration: none;
  color: inherit;
  display: block;
}

.clinic-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: all 0.15s ease;
  cursor: pointer;
}

.clinic-card:hover {
  box-shadow: var(--shadow);
  border-color: var(--color-primary);
  transform: translateY(-2px);
}

.clinic-card:hover .clinic-card-action {
  color: var(--color-primary);
}

.clinic-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px;
  background: var(--color-bg);
  border-bottom: 1px solid var(--color-border);
}

.clinic-icon {
  width: 48px;
  height: 48px;
  background: var(--color-primary);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-on-primary);
}

.clinic-icon .material-symbols-outlined {
  font-size: 24px;
}

.clinic-card-body {
  padding: 20px;
}

.clinic-name {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 4px;
}

.clinic-slug {
  font-size: 13px;
  color: var(--color-text-muted);
  margin-bottom: 16px;
}

.clinic-stats {
  display: flex;
  gap: 24px;
  margin-bottom: 16px;
}

.clinic-stat {
  display: flex;
  flex-direction: column;
}

.clinic-stat .stat-number {
  font-size: 20px;
  font-weight: 700;
  color: var(--color-text);
}

.clinic-stat .stat-text {
  font-size: 12px;
  color: var(--color-text-muted);
}

.clinic-integrations {
  display: flex;
  gap: 8px;
}

.integration-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 9999px;
  font-size: 12px;
  font-weight: 500;
}

.integration-badge .material-symbols-outlined {
  font-size: 14px;
}

.integration-badge.configured {
  background: var(--color-success-bg);
  color: var(--color-success-text);
}

.integration-badge.pending {
  background: var(--color-warning-bg);
  color: var(--color-warning-text);
}

.clinic-card-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding: 16px 20px;
  border-top: 1px solid var(--color-border);
  background: var(--color-bg);
}

.clinic-card-action {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 500;
  color: var(--color-text-muted);
  transition: color 0.15s ease;
}

.clinic-card-action .material-symbols-outlined {
  font-size: 18px;
}

.btn-sm {
  padding: 6px 12px;
  font-size: 13px;
}

.btn-sm .material-symbols-outlined {
  font-size: 16px;
}

/* Form Styles */
.form-section {
  margin-bottom: 32px;
  padding-bottom: 32px;
  border-bottom: 1px solid var(--color-border);
}

.form-section:last-of-type {
  border-bottom: none;
  margin-bottom: 0;
  padding-bottom: 0;
}

.form-section-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 20px;
}

.form-section-title {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 8px;
}

.form-section-description {
  font-size: 13px;
  color: var(--color-text-muted);
}

.form-row {
  display: flex;
  gap: 16px;
  align-items: flex-start;
}

.form-row .form-group {
  flex: 1;
}

.form-hint {
  font-size: 12px;
  color: var(--color-text-muted);
  margin-top: 4px;
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 32px;
  padding-top: 24px;
  border-top: 1px solid var(--color-border);
}

.clinic-form {
  padding: 24px;
}

/*
 * "Testar Conexão" vive fora do form da clínica: button_to gera um <form>, e
 * form aninhado faz o parser fechar o form externo, deixando o submit "Salvar
 * Alterações" órfão (ver app/views/dashboard/v1/clinics/_form.html.erb).
 * Fica no fluxo, alinhado à direita junto das ações do form.
 */
/* Form auxiliar do "Testar Conexão": só transporta a requisição, o botão
   visível fica no cabeçalho da seção e se liga a ele por form=. */
.clinic-test-connection-form {
  display: none;
}

/* Última seção antes das ações: sem borda própria — o .form-actions já traz a
   dele, e as duas juntas viravam uma barra dupla vazia. */
.form-section-last {
  border-bottom: none;
  margin-bottom: 0;
  padding-bottom: 0;
}

/* Tabs */
/* Abas + ações na mesma faixa (ver clinics/show.html.erb) */
.tabs-bar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--color-border);
  margin-bottom: 24px;
}

.tabs {
  display: flex;
  gap: 2px;
  flex-wrap: wrap;
}

.tab {
  white-space: nowrap;
}

.tabs-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-bottom: 8px;
  flex-shrink: 0;
}

/* O horário da última sync é o primeiro a sair quando o espaço aperta — o
   botão de sincronizar permanece, e o dado segue no title do botão. */
@media (max-width: 1400px) {
  .tabs-actions .sync-timestamp {
    display: none;
  }
}

.tab {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 14px;
  font-size: 14px;
  font-weight: 500;
  color: var(--color-text-muted);
  text-decoration: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: all 0.15s ease;
}

.tab:hover {
  color: var(--color-text);
  background: var(--color-bg);
}

.tab.active {
  color: var(--color-primary);
  border-bottom-color: var(--color-primary);
}

.tab .material-symbols-outlined {
  font-size: 18px;
}

.tab-content {
  animation: fadeIn 0.2s ease;
}

/* Appointments */
.appointment-toolbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.date-nav {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.appointment-filter-form {
  display: flex;
  align-items: flex-end;
  gap: 8px;
}

.appointment-filter-form .form-label {
  margin-bottom: 10px;
}

.appointment-filter-select {
  min-width: 180px;
}

.actions-dropdown {
  position: relative;
  display: inline-flex;
}

.actions-dropdown summary {
  list-style: none;
}

.actions-dropdown summary::-webkit-details-marker {
  display: none;
}

.actions-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  z-index: 20;
  min-width: 260px;
  padding: 6px;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  background: var(--color-surface);
  box-shadow: var(--shadow);
}

.dropdown-action {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--color-text);
  font: inherit;
  font-size: 13px;
  text-align: left;
  cursor: pointer;
}

.dropdown-action:hover {
  background: var(--color-bg);
}

.dropdown-action:disabled {
  color: var(--color-text-muted);
  cursor: not-allowed;
}

.dropdown-action .material-symbols-outlined {
  font-size: 18px;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* Messages List */
.message-template-input {
  min-height: 140px;
  resize: vertical;
}

.messages-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px;
}

.message-item {
  padding: 16px;
  border-radius: var(--radius);
  background: var(--color-bg);
}

.message-item.outbound {
  border-left: 3px solid var(--color-primary);
}

.message-item.inbound {
  border-left: 3px solid var(--color-success);
}

.message-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.message-patient {
  font-weight: 600;
  font-size: 14px;
}

.message-appointment-time {
  margin-left: 8px;
  font-size: 12px;
  color: var(--color-text-muted);
}

.message-time {
  font-size: 12px;
  color: var(--color-text-muted);
}

.message-content {
  font-size: 14px;
  line-height: 1.6;
  color: var(--color-text);
}

.message-content p {
  margin: 0;
}

.message-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--color-border);
}

.message-direction {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  color: var(--color-text-muted);
}

.message-sid {
  font-size: 12px;
  color: var(--color-text-muted);
}

.message-direction .material-symbols-outlined {
  font-size: 14px;
}

/* Text utilities */
.text-muted {
  color: var(--color-text-muted);
}

.text-small {
  font-size: 12px;
}

/* Material Symbols config */
.material-symbols-outlined {
  font-variation-settings:
    'FILL' 0,
    'wght' 400,
    'GRAD' 0,
    'opsz' 24;
}

/* Collapsed sidebar (icon rail) — desktop */
.layout.sidebar-collapsed .sidebar {
  width: 76px;
}

.layout.sidebar-collapsed .main-content {
  margin-left: 76px;
}

/* No rail de 72px some só o wordmark — o Selo Cruz continua visível */
.layout.sidebar-collapsed .logo-wordmark,
.layout.sidebar-collapsed .nav-item span:not(.material-symbols-outlined) {
  display: none;
}

.layout.sidebar-collapsed .sidebar-header {
  justify-content: center;
  padding: 0;
}

.layout.sidebar-collapsed .sidebar-collapse .material-symbols-outlined {
  transform: rotate(180deg);
}

.layout.sidebar-collapsed .nav-item {
  justify-content: center;
  padding: 12px;
}

/* Responsive: off-canvas sidebar */
@media (max-width: 1024px) {
  .sidebar-toggle {
    display: inline-flex;
  }

  /* No off-canvas o colapso não se aplica */
  .sidebar-collapse {
    display: none;
  }

  .layout.sidebar-collapsed .sidebar {
    width: 250px;
  }

  .layout.sidebar-collapsed .main-content {
    margin-left: 0;
  }

  .layout.sidebar-collapsed .logo-wordmark,
  .layout.sidebar-collapsed .nav-item span:not(.material-symbols-outlined) {
    display: inline;
  }

  .layout.sidebar-collapsed .sidebar-header {
    justify-content: space-between;
    padding: 20px 24px;
  }

  .layout.sidebar-collapsed .nav-item {
    justify-content: flex-start;
    padding: 12px 16px;
  }

  .sidebar {
    transform: translateX(-100%);
    box-shadow: 0 0 24px rgb(15 46 42 / 0.25);
  }

  .sidebar-close {
    display: inline-flex;
  }

  .main-content {
    margin-left: 0;
  }

  .layout.sidebar-open .sidebar {
    transform: translateX(0);
  }

  .layout.sidebar-open .sidebar-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 30;
    background: var(--color-overlay);
  }
}

@media (max-width: 640px) {
  .topbar {
    padding: 12px 16px;
  }

  .content {
    padding: 16px;
  }

  .alert {
    margin: 12px 16px 0;
  }

  .topbar-actions {
    gap: 12px;
  }

  .current-date {
    display: none;
  }
}

/* Sidesheet (right drawer) */
body.sidesheet-locked {
  overflow: hidden;
}

.sidesheet-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: var(--color-overlay);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s ease, visibility 0.2s ease;
}

.sidesheet-overlay.open {
  opacity: 1;
  visibility: visible;
}

.sidesheet {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 440px;
  max-width: 92vw;
  background: var(--color-surface);
  border-left: 1px solid var(--color-border);
  box-shadow: -8px 0 24px rgb(15 46 42 / 0.12);
  z-index: 60;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.25s ease;
}

.sidesheet.open {
  transform: translateX(0);
}

.sidesheet-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 20px 24px;
  border-bottom: 1px solid var(--color-border);
}

.sidesheet-title {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 600;
}

.sidesheet-subtitle {
  font-size: 13px;
  color: var(--color-text-muted);
  margin-top: 2px;
}

.sidesheet-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 6px;
  border: 0;
  background: transparent;
  border-radius: 6px;
  cursor: pointer;
  color: var(--color-text-muted);
  transition: background 0.15s ease;
}

.sidesheet-close:hover {
  background: var(--color-bg);
  color: var(--color-text);
}

.sidesheet-body {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
}

.sidesheet-section {
  padding-bottom: 20px;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--color-border);
}

.sidesheet-section:last-of-type {
  border-bottom: 0;
}

.sidesheet-section-title {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--color-text-muted);
  margin-bottom: 12px;
}

.sidesheet-section .form-group {
  margin-bottom: 12px;
}

.sidesheet-section .form-group:last-child {
  margin-bottom: 0;
}

.sidesheet-scopes {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 12px;
}

.sidesheet-footer {
  position: sticky;
  bottom: 0;
  display: flex;
  justify-content: flex-end;
  padding-top: 16px;
  background: var(--color-surface);
}

.sidesheet-footer .btn {
  width: 100%;
}

.sidesheet-test-btn {
  width: 100%;
  margin-top: 12px;
  justify-content: center;
}

/* Appointments realtime updates */
.appointments-refresh-bar {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 12px;
}

.refresh-indicator {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--color-text-muted);
}

.refresh-indicator .refresh-icon {
  font-size: 16px;
}

/* Última sincronização da agenda (ao lado do botão Sincronizar) */
.sync-timestamp {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  color: var(--color-text-muted);
}

.sync-timestamp .material-symbols-outlined {
  font-size: 16px;
}

/* Provider feature flags */
.provider-flags-card {
  margin-bottom: 24px;
}

.provider-flags-card .card-title {
  display: flex;
  align-items: center;
  gap: 8px;
}

.provider-flags-card .card-title .material-symbols-outlined {
  font-size: 20px;
  color: var(--color-primary);
}

.provider-flags-card.provider-flags-off {
  border-color: var(--color-error-border);
  background: var(--color-surface-danger);
}

.provider-flags-hint {
  font-size: 13px;
  margin-bottom: 16px;
}

.provider-toggle {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.provider-toggle:hover {
  border-color: var(--color-primary);
}

.provider-toggle input {
  margin-top: 2px;
  width: 16px;
  height: 16px;
  accent-color: var(--color-primary);
}

.provider-toggle-body {
  display: flex;
  flex-direction: column;
}

.provider-toggle-title {
  font-size: 14px;
  font-weight: 600;
}

.provider-toggle-desc {
  font-size: 12px;
  color: var(--color-text-muted);
}

.provider-toggle-kill {
  border-color: var(--color-error-border);
  background: var(--color-error-bg);
}

.provider-toggle-kill input {
  accent-color: var(--color-error);
}

.provider-toggle-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* Alert warning (config incompleta) */
.alert-warning {
  background: var(--color-warning-bg);
  color: var(--color-warning-text);
  border: 1px solid var(--color-warning-border);
}

/* Clinic config tab */
.config-warning {
  align-items: flex-start;
  margin: 24px 0 20px;
}

.config-warning-list {
  margin: 6px 0 0;
  padding-left: 18px;
}

.config-warning-list li {
  margin-top: 2px;
}

.config-form .form-group {
  margin-bottom: 20px;
}

.config-timing-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 20px;
  margin-bottom: 20px;
}

.config-timing {
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 16px;
}

.config-timing legend {
  font-size: 13px;
  font-weight: 600;
  padding: 0 6px;
  color: var(--color-text);
}

.config-duration {
  display: flex;
  gap: 12px;
}

.config-duration label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--color-text-muted);
}

.config-duration .form-input {
  width: 72px;
}

.config-actions {
  display: flex;
  justify-content: flex-end;
  padding-top: 16px;
  border-top: 1px solid var(--color-border);
}

/* Confirmation audit (Mensagens tab) */
.audit-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 4px 0 16px;
  border-bottom: 1px solid var(--color-border);
  margin-bottom: 16px;
}

.audit-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border: 1px solid var(--color-border);
  border-radius: 9999px;
  font-size: 13px;
  font-weight: 500;
  color: var(--color-text-muted);
  text-decoration: none;
  transition: all 0.15s ease;
}

.audit-chip:hover {
  border-color: var(--color-primary);
  color: var(--color-text);
}

.audit-chip.active {
  background: var(--color-primary);
  border-color: var(--color-primary);
  color: var(--color-on-primary);
}

.audit-chip-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  padding: 0 6px;
  height: 18px;
  border-radius: 9999px;
  background: rgba(0, 0, 0, 0.08);
  font-size: 11px;
  font-weight: 600;
}

.audit-chip.active .audit-chip-count {
  background: rgba(255, 255, 255, 0.25);
}

.audit-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.audit-row {
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 12px 14px;
}

.audit-row-main {
  display: grid;
  grid-template-columns: 160px 1fr auto;
  gap: 12px;
  align-items: center;
}

.audit-row-status {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.audit-row-patient {
  display: flex;
  flex-direction: column;
}

.audit-patient-name {
  font-weight: 600;
  font-size: 14px;
}

.audit-patient-phone {
  font-size: 12px;
  color: var(--color-text-muted);
}

.audit-row-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  font-size: 12px;
  color: var(--color-text-muted);
}

.audit-row-meta span {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.audit-row-meta .material-symbols-outlined {
  font-size: 15px;
}

.audit-row-history {
  margin-top: 10px;
  border-top: 1px dashed var(--color-border);
  padding-top: 8px;
}

.audit-row-history summary {
  cursor: pointer;
  font-size: 12px;
  color: var(--color-primary);
}

.audit-messages {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 10px;
}

.audit-message {
  border-left: 3px solid var(--color-border);
  padding: 6px 10px;
  background: var(--color-bg);
  border-radius: 0 6px 6px 0;
}

.audit-message.outbound {
  border-left-color: var(--color-primary);
}

.audit-message.inbound {
  border-left-color: var(--color-success);
}

.audit-message-head {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12px;
  color: var(--color-text-muted);
}

.audit-message-head .material-symbols-outlined {
  font-size: 14px;
}

.audit-message-content {
  font-size: 13px;
  margin-top: 4px;
}

.audit-footer {
  display: flex;
  justify-content: center;
  margin-top: 16px;
}

@media (max-width: 640px) {
  .audit-row-main {
    grid-template-columns: 1fr;
  }
}

.audit-hint-icon {
  font-size: 18px;
  color: var(--color-text-muted);
}

.audit-tooltip:hover .audit-hint-icon {
  color: var(--color-primary);
}

/* Tooltip estilizado e instantâneo (sem delay do title nativo) */
.audit-tooltip {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.audit-tooltip::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 50;
  width: max-content;
  max-width: 260px;
  padding: 8px 10px;
  border-radius: 6px;
  background: var(--color-sidebar);
  color: var(--color-on-dark);
  font-size: 12px;
  font-weight: 400;
  line-height: 1.4;
  text-align: left;
  white-space: normal;
  box-shadow: var(--shadow);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.08s ease;
}

.audit-tooltip::before {
  content: "";
  position: absolute;
  bottom: calc(100% + 3px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 50;
  border: 5px solid transparent;
  border-top-color: var(--color-sidebar);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.08s ease;
}

.audit-tooltip:hover::after,
.audit-tooltip:hover::before {
  opacity: 1;
  visibility: visible;
}

.provider-toggle-disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* Modo de operação (toggle LIVE / TEST) */
.mode-switch {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  margin-bottom: 12px;
  user-select: none;
}

.mode-switch input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.mode-switch-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--color-text-muted);
}

.mode-switch-track {
  position: relative;
  width: 44px;
  height: 24px;
  border-radius: 999px;
  background: var(--color-border);
  transition: background 0.15s ease;
  flex-shrink: 0;
}

.mode-switch-thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--color-on-dark);
  transition: transform 0.15s ease;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

.mode-switch input:checked + .mode-switch-track {
  background: var(--color-error);
}

.mode-switch input:checked + .mode-switch-track .mode-switch-thumb {
  transform: translateX(20px);
}

.mode-switch.mode-switch-live .mode-switch-label:last-child {
  color: var(--color-error);
}

/* Tooltip de ajuda "i" */
.info-tip {
  position: relative;
  display: inline-flex;
  align-items: center;
  cursor: help;
}

.info-tip .material-symbols-outlined {
  font-size: 16px;
  color: var(--color-text-muted);
}

.info-tip-text {
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  width: 220px;
  padding: 8px 10px;
  border-radius: var(--radius);
  background: var(--color-sidebar);
  color: var(--color-on-dark);
  font-size: 12px;
  font-weight: 400;
  line-height: 1.4;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.15s ease;
  z-index: 10;
}

.info-tip:hover .info-tip-text,
.info-tip:focus .info-tip-text {
  opacity: 1;
  visibility: visible;
}
