/* 🌿 Fundo geral mais suave */
body {
  background-color: #f8f9fa;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

main {
  flex: 1;
}

/* Estilos para tabelas responsivas */
.table-responsive {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* ========== RESPONSIVO: adapta a qualquer tela ========== */

/* Mobile pequeno (< 576px) */
@media (max-width: 575px) {
  .container, .container-fluid {
    padding-left: 0.5rem;
    padding-right: 0.5rem;
  }
  .card-body { padding: 0.75rem; }
  .card-header { padding: 0.5rem 0.75rem; }
  .table th, .table td { padding: 0.4rem 0.35rem; font-size: 0.875rem; }
  .btn { padding: 0.35rem 0.65rem; font-size: 0.875rem; }
  .form-control, .form-select { font-size: 1rem; min-height: 2.5rem; }
  h1, .h1 { font-size: 1.5rem; }
  h2, .h2 { font-size: 1.25rem; }
}

/* Mobile / Tablet (576px - 991px) */
@media (max-width: 991px) {
  .container, .container-fluid {
    padding-left: 0.75rem;
    padding-right: 0.75rem;
  }
  .table th, .table td { padding: 0.5rem; }
  .btn-group .btn { padding: 0.25rem 0.5rem; }
  .card { margin-bottom: 1rem; }
}

@media (max-width: 768px) {
  .container, .container-fluid {
    padding-left: 10px;
    padding-right: 10px;
  }
  .table th, .table td { padding: 0.5rem; }
  .btn-group .btn { padding: 0.25rem 0.5rem; }
  .card { margin-bottom: 20px; }
}

/* Tabelas: scroll horizontal em telas pequenas */
@media (max-width: 991px) {
  .table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin-bottom: 1rem;
  }
  .table { min-width: 500px; }
}

/* Formulários: colunas viram bloco em mobile */
@media (max-width: 767px) {
  .row .col-md-6, .row .col-lg-4, .row .col-lg-6 {
    max-width: 100%;
    flex: 0 0 100%;
  }
}

/* ========== PÁGINAS PADRONIZADAS (mesmo padrão do dashboard) ========== */
.page-modern {
  padding-top: 1.5rem;
  padding-bottom: 1.5rem;
}
/* Cabeçalho da página: mesma linha do dashboard (título + botão de ação) */
.page-header-modern {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 1.5rem;
  padding: 1rem 1.25rem;
  background: #fff;
  border-radius: 10px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
  border: none;
}
.page-header-modern h1,
.page-header-modern h2 {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 700;
  color: #212529;
}
/* Botões de ação (Novo TFD, Filtrar): mesma altura e estilo */
.btn-action-modern,
.page-header-modern .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 18px !important;
  font-weight: 500 !important;
  border-radius: 8px !important;
  min-height: 38px;
  box-sizing: border-box;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
/* Botão do header (Novo TFD) e Filtrar: mesma largura fixa para não ultrapassar */
.page-header-modern .btn,
.btn-filtrar-tfds {
  min-width: 150px;
  width: 150px;
}
.btn-action-modern:hover,
.page-header-modern .btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 2px 10px rgba(91, 163, 246, 0.3);
}
.page-modern .card {
  margin-bottom: 1.5rem;
}
/* Primeiro card da página com barra lateral (igual dashboard) */
.page-modern > .card:first-of-type {
  border-left: 4px solid #2D7FF9;
}
.page-modern .card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem;
}
.page-modern .card-header .btn {
  padding: 0.4rem 0.75rem;
  font-weight: 500;
}

/* ========== PADRONIZAÇÃO GLOBAL (todas as telas) ========== */

/* Cards: mesmo estilo em todo o sistema */
.card {
  background: #fff;
  border: none;
  border-radius: 10px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
  margin-bottom: 1.5rem;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.card:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.08);
}
.card-header {
  background: #f8f9fa;
  border-bottom: 1px solid #eee;
  border-radius: 10px 10px 0 0;
  font-weight: 600;
  padding: 0.75rem 1.25rem;
}
.card-body {
  padding: 1.25rem;
}

/* Tabelas: mesmo estilo em todo o sistema */
.table {
  width: 100%;
  margin-bottom: 0;
}
.table thead {
  background: #f8f9fa;
  font-weight: 600;
}
.table thead th {
  padding: 14px;
  border-bottom: 2px solid #dee2e6;
  color: #495057;
}
.table tbody td {
  padding: 14px;
  vertical-align: middle;
}
.table tbody tr:hover {
  background: #f5f7fb;
}
.table-hover tbody tr:hover {
  background: #f5f7fb;
}

/* Títulos de página: padrão em todo o sistema */
.container h1, .container h2, .container-fluid h1, .container-fluid h2,
.content-container h1, .content-container h2 {
  color: #212529;
  font-weight: 700;
  margin-bottom: 1.25rem;
}
.content-container .container,
main .container,
main .container-fluid {
  padding-top: 1.5rem;
  padding-bottom: 1.5rem;
}

/* Listas dentro de cards (todo o sistema) */
.card .list-group-item {
  border-color: #eee;
  padding: 0.75rem 1.25rem;
}
.card .list-group-flush .list-group-item:last-child {
  border-bottom: 0;
}

/* Formulários: padrão em todo o sistema */
.form-group {
  margin-bottom: 1rem;
}
.form-label {
  font-weight: 500;
  color: #495057;
}
.form-control, .form-select {
  border-radius: 8px;
  border-color: #dee2e6;
}
.form-control:focus, .form-select:focus {
  border-color: #2D7FF9;
  box-shadow: 0 0 0 3px rgba(45, 127, 249, 0.15);
}
.alert {
  border-radius: 10px;
  border: none;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
  margin-bottom: 1.5rem;
}

/* Estilos para botões de ação */
.btn-group .btn {
  margin-right: 2px;
}

/* Estilos para paginação */
.pagination {
  margin-bottom: 0;
}

/* Rodapé totais — relatório pacientes (evita table-light branco no escuro) */
.relatorio-tfoot-totais td {
  background-color: #f1f3f5 !important;
  border-top: 2px solid #dee2e6 !important;
  vertical-align: middle;
}

/* Linha TOTAL no meio da tabela (período / especialidade) — separador discreto */
.relatorio-tbody-total-row td {
  background-color: #f1f3f5;
  border-top: 1px solid #ced4da;
  vertical-align: middle;
}

/* Área de anexo documentos/exames (visualizar paciente) */
.documentos-upload-area {
  background-color: #f8f9fa;
  border-color: #dee2e6 !important;
}

/* Estilos para mensagens flash */
.alert-dismissible {
  padding-right: 3rem;
}

/* Rodapé: versão e links */
footer {
  margin-top: auto;
  background-color: #f8f9fa;
  border-top: 1px solid #eee;
  padding: 1rem 0;
}
footer .footer-inner .d-flex a { color: #495057; }
footer .footer-inner .d-flex a:hover { text-decoration: underline; }

/* Ícone de alternar tema (portal/login + headers) */
.theme-toggle-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  color: #6c757d;
  background: transparent;
  transition: color 0.2s ease, opacity 0.2s ease;
  padding: 0;
  border: 0;
}
.theme-toggle-icon:hover {
  color: #2D7FF9;
  opacity: 0.85;
  text-decoration: none;
}
.theme-toggle-icon:focus,
.theme-toggle-icon:focus-visible {
  outline: none;
  box-shadow: none;
}

/* Evita que o toggle herde o tamanho fixo dos botões do header */
.page-header-modern .theme-toggle-icon {
  min-width: auto !important;
  width: auto !important;
}

/* Portal: dar respiro entre tema e sino */
.page-header-modern .theme-toggle-icon {
  margin-right: 20px;
}

/* ========== NAVBAR MODERNO (proporcional aos cards) ========== */
.navbar-modern {
  background: #fff !important;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
  border-bottom: 1px solid #eee;
  min-height: 60px;
  margin-bottom: 0;
}
.navbar-brand-modern {
  color: #2D7FF9 !important;
  font-weight: 700;
  font-size: 1.15rem;
}
.navbar-brand-modern:hover { color: #1A5EDB !important; }
.nav-link-modern {
  color: #495057 !important;
  font-weight: 500;
  font-size: 0.9rem;
  padding: 0.5rem 0.75rem !important;
  border-radius: 8px;
  transition: background 0.2s, color 0.2s;
}
.nav-link-modern:hover {
  background: #f5f7fb;
  color: #2D7FF9 !important;
}
.nav-link-modern.active {
  background: #e8f0fe;
  color: #2D7FF9 !important;
  text-decoration: none !important;
}
.nav-link-user {
  color: #212529 !important;
  font-weight: 600;
}
.navbar-toggler-modern {
  border-color: #dee2e6;
  padding: 0.35rem 0.5rem;
}
.navbar-toggler-modern:focus {
  box-shadow: 0 0 0 2px rgba(45, 127, 249, 0.25);
}
.dropdown-menu-modern {
  border: none;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.08);
  border-radius: 10px;
  padding: 0.5rem;
  margin-top: 0.5rem;
}
.dropdown-menu-modern .dropdown-item {
  border-radius: 8px;
  padding: 0.5rem 0.75rem;
  font-weight: 500;
}
.dropdown-menu-modern .dropdown-item:hover {
  background: #f5f7fb;
}
.dropdown-menu-modern .dropdown-item.text-danger:hover {
  background: #fff5f5;
}

/* Navbar legado (fallback) */
.navbar {
  margin-bottom: 20px;
}
.navbar:not(.navbar-modern) .container-fluid { padding-top: 0.5rem; padding-bottom: 0.5rem; }
.navbar:not(.navbar-modern) .navbar-brand,
.navbar:not(.navbar-modern) .nav-link { padding-top: 0.5rem; padding-bottom: 0.5rem; }

/* Estilos para detalhes de visualização */
.detail-row {
  margin-bottom: 0.5rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid #eee;
}

.detail-label {
  font-weight: bold;
}

/* Badges: padrão em todo o sistema (status e contadores) */
.badge {
  border-radius: 20px;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 500;
}

/* ========== DASHBOARD (estilo SaaS / corporativo) ========== */

.dashboard-page .mb-4 { margin-bottom: 30px !important; }
.dashboard-page .card { padding: 20px; margin-bottom: 24px; }

/* Botões de ação do dashboard */
.btn-dashboard-action {
  padding: 10px 18px !important;
  font-weight: 600 !important;
}

/* Cards de indicadores: fundo branco + barra lateral colorida (estilo AdminLTE/CoreUI) */
.card-dashboard-link { display: block; color: inherit; }
.card-dashboard-link:hover { color: inherit; text-decoration: none; }
.card-dashboard {
  background: #fff;
  border: none;
  border-radius: 10px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  overflow: hidden;
}
.card-dashboard-link:hover .card-dashboard {
  transform: translateY(-3px);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.08);
}
.card-dashboard .card-body {
  padding: 20px;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  min-height: 132px;
}
/* Faixa inferior igual nos 4 cards (evita card Pendentes mais alto) */
.dashboard-card-sub {
  margin-top: 0.35rem;
  min-height: 1.35rem;
  line-height: 1.35;
}
.dashboard-card-sub-placeholder {
  visibility: hidden;
  pointer-events: none;
  user-select: none;
}
.dashboard-icon-concluidos {
  color: #0aa2c0 !important;
  font-size: 1.6rem !important;
}
.dashboard-title {
  font-size: 14px;
  color: #666;
  font-weight: 600;
}
.dashboard-icon {
  font-size: 1.5rem;
  line-height: 1;
}
.dashboard-number {
  font-size: 36px;
  font-weight: 700;
  margin-top: 10px;
  color: #212529;
  line-height: 1.1;
}
.dashboard-trend { font-size: 12px; }

/* Barra lateral colorida (accent) */
.card-dashboard-accent-primary { border-left: 4px solid #2D7FF9; }
.card-dashboard-accent-success { border-left: 4px solid #28a745; }
.card-dashboard-accent-info { border-left: 4px solid #17a2b8; }
.card-dashboard-accent-warning { border-left: 4px solid #FFC107; }

/* Tabela dashboard: hover, cabeçalho forte, padding maior */
.table-dashboard thead {
  background: #f8f9fa;
  font-weight: 600;
}
.table-dashboard thead th {
  padding: 14px;
  border-bottom: 2px solid #dee2e6;
}
.table-dashboard tbody td {
  padding: 14px;
}
.table-dashboard tbody tr:hover {
  background: #f5f7fb;
}

/* Badges de status — padrão dashboard: cores suaves (fundo pastel, texto escuro) */
.badge-status-modern {
  border-radius: 20px;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 500;
  border: 1px solid transparent;
  box-shadow: none;
}
.badge-status-modern.badge-warning,
.badge-status-warning {
  background: #fff3cd;
  color: #856404;
  border-color: #ffeeba;
}
.badge-status-modern.badge-primary,
.badge-status-primary {
  background: #cce5ff;
  color: #004085;
  border-color: #b8daff;
}
.badge-status-modern.badge-success,
.badge-status-success {
  background: #d4edda;
  color: #155724;
  border-color: #c3e6cb;
}
.badge-status-modern.badge-danger,
.badge-status-danger {
  background: #f8d7da;
  color: #721c24;
  border-color: #f5c6cb;
}
.badge-status-modern.badge-info {
  background: #d1ecf1;
  color: #0c5460;
  border-color: #bee5eb;
}
.badge-status-modern.badge-secondary {
  background: #e2e3e5;
  color: #383d41;
  border-color: #d6d8db;
}

/* Contagens em relatórios — mesma paleta suave da dash (Pendentes / Aceitas / Canceladas) */
.badge-metric {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2.25rem;
  padding: 0.4rem 0.75rem;
  font-size: 0.875rem;
  font-weight: 600;
  border-radius: 999px;
  line-height: 1.2;
  box-shadow: none;
  border: 1px solid transparent;
}
.badge-metric-total {
  background: #e9ecef;
  color: #495057;
  border-color: #dee2e6;
}
.badge-metric-pendente {
  background: #fff3cd;
  color: #856404;
  border-color: #ffeeba;
}
.badge-metric-aceito {
  background: #d4edda;
  color: #155724;
  border-color: #c3e6cb;
}
.badge-metric-cancelado {
  background: #f8d7da;
  color: #721c24;
  border-color: #f5c6cb;
}
.badge-metric-muted {
  background: #f8f9fa;
  color: #6c757d;
  font-weight: 500;
  border-color: #dee2e6;
  min-width: 2.25rem;
}

/* Card TFDs por Status: donut centralizado, mesmo estilo dos cards */
.card-dashboard-chart {
  background: #fff;
  border-radius: 10px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
  border: none;
}
.card-dashboard-chart .card-body {
  padding: 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.dashboard-donut-wrapper {
  position: relative;
  width: 220px;
  height: 220px;
  margin-left: auto;
  margin-right: auto;
}
.dashboard-donut-center {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 1.75rem;
  font-weight: 700;
  color: #333;
  z-index: 2;
}
.status-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 6px;
  vertical-align: middle;
}
.status-dot-warning { background: #ffc107; }
.status-dot-primary { background: #0d6efd; }
.status-dot-success { background: #198754; }
.status-dot-danger { background: #dc3545; }

/* Rodapé dos cards do dashboard (sem faixa branca no escuro) */
.dashboard-card-footer {
  background: transparent !important;
  border-top: 1px solid rgba(0, 0, 0, 0.06);
  padding-top: 0.75rem;
}

/* Estilos para cards do dashboard (legado) */
.dashboard-card {
  transition: transform 0.3s;
}
.dashboard-card:hover {
  transform: translateY(-5px);
}

/* Estilos para links */
a {
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

/* Estilos para botões de ação */
.action-buttons .btn {
  margin-right: 5px;
}

/* Estilos para tabelas (complementar ao bloco global acima) */
.table-borderless tbody td { border: 0; }

/* Estilos para formulários de busca */
.search-form {
  margin-bottom: 1rem;
}

/* Estilos para títulos de página */
.page-title {
  margin-bottom: 1.5rem;
  color: #343a40;
}

/* Mensagens de alerta (complementar ao bloco global .alert) */
.alert-dismissible .btn-close { margin-left: 0.5rem; }

/* Estilos para campos obrigatórios */
.required:after {
  content: " *";
  color: red;
}

/* Estilos para visualização de detalhes */
.view-details .row {
  margin-bottom: 0.5rem;
}

/* Estilos para botões de voltar */
.btn-back {
  margin-bottom: 1rem;
}

/* Estilos para cabeçalhos de seção */
.section-header {
  margin-top: 2rem;
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid #dee2e6;
}

/* Estilos para tabelas responsivas */
@media (max-width: 576px) {
  .table-responsive {
    display: block;
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .table-responsive > .table {
    margin-bottom: 0;
  }
}

/* ========== BOTÕES MODERNOS (proporcionais ao layout) ========== */
.btn {
  border-radius: 8px;
  font-weight: 500;
  padding: 0.5rem 1rem;
  transition: transform 0.15s, box-shadow 0.15s;
}
.btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}
/* Botões primários: azul mais suave, menos pesado */
.btn-primary {
  background: #5BA3F6;
  border-color: #5BA3F6;
  box-shadow: none;
}
.btn-primary:hover {
  background: #4A90E8;
  border-color: #4A90E8;
  box-shadow: 0 2px 10px rgba(91, 163, 246, 0.35);
}
.btn-success {
  background: #34C38F;
  border-color: #34C38F;
  box-shadow: none;
}
.btn-success:hover {
  background: #2BB37D;
  border-color: #2BB37D;
  box-shadow: 0 2px 10px rgba(52, 195, 143, 0.3);
}
.btn-sm {
  padding: 0.35rem 0.65rem;
  font-size: 0.875rem;
  border-radius: 6px;
}
.btn-dashboard-action {
  padding: 10px 18px !important;
  font-weight: 500 !important;
  border-radius: 8px !important;
  box-shadow: none !important;
}
.btn-dashboard-action:hover {
  box-shadow: 0 2px 10px rgba(91, 163, 246, 0.3) !important;
}
.btn-outline-primary,
.btn-outline-secondary,
.btn-outline-danger,
.btn-outline-warning,
.btn-outline-success {
  border-radius: 8px;
}
.btn-outline-primary:hover {
  box-shadow: 0 2px 10px rgba(45, 127, 249, 0.25);
}

/* Estilos adicionais para o Sistema TFD */

/* Botões de ação na tabela */
.table .btn-sm {
    display: inline-block !important;
    width: auto !important;
    min-width: initial !important;
    max-width: none !important;
    padding: 0.25rem 0.5rem !important;
    margin: 0 2px !important;
}

/* Contentor dos botões de ação */
.table .d-flex.justify-content-center {
    gap: 3px;
    flex-wrap: nowrap;
}

/* Remover regras conflitantes */
.table td .btn {
    display: inline-block;
    width: auto;
}

