@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Outfit:wght@400;500;600;700&display=swap');

:root {
  /* Premium Color Palette (Toned down white) */
  --bg-body: #e2e8f0; /* Slate 200 - darker background */
  --bg-card: rgba(248, 250, 252, 0.9); /* Slightly off-white for cards */
  --bg-sidebar: rgba(248, 250, 252, 0.95);
  
  --primary: #047857; /* Deep Emerald */
  --primary-hover: #065f46;
  --primary-light: #d1fae5;
  
  --secondary: #b45309; /* Subtle Bronze/Gold */
  --secondary-hover: #92400e;
  
  --text-dark: #0f172a;
  --text-muted: #64748b;
  
  --border-color: rgba(148, 163, 184, 0.2);
  --border-light: rgba(255, 255, 255, 0.5);
  
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
  --shadow-lg: 0 10px 25px -3px rgba(0, 0, 0, 0.05), 0 4px 10px -2px rgba(0, 0, 0, 0.03);
  --shadow-glass: 0 8px 32px 0 rgba(31, 38, 135, 0.07);
  
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;
}

[data-theme="dark"] {
  --bg-body: #0f172a; /* Slate 900 */
  --bg-card: rgba(30, 41, 59, 0.9); /* Slate 800 */
  --bg-sidebar: rgba(15, 23, 42, 0.95);
  
  --primary: #10b981; /* Lighter emerald for contrast */
  --primary-hover: #34d399;
  --primary-light: rgba(16, 185, 129, 0.15);
  
  --secondary: #fbbf24; /* Amber/Gold */
  --secondary-hover: #f59e0b;
  
  --text-dark: #f8fafc;
  --text-muted: #94a3b8;
  
  --border-color: rgba(255, 255, 255, 0.1);
  --border-light: rgba(255, 255, 255, 0.05);
  
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.5);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 10px 25px -3px rgba(0, 0, 0, 0.5);
  --shadow-glass: 0 8px 32px 0 rgba(0, 0, 0, 0.3);
}

body {
  font-family: 'Inter', sans-serif;
  background-color: var(--bg-body);
  background-image: 
    radial-gradient(at 0% 0%, rgba(209, 250, 229, 0.4) 0px, transparent 50%),
    radial-gradient(at 100% 0%, rgba(224, 242, 254, 0.4) 0px, transparent 50%),
    radial-gradient(at 100% 100%, rgba(254, 243, 199, 0.3) 0px, transparent 50%);
  background-attachment: fixed;
  color: var(--text-dark);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* Typography Enhancements */
h1, h2, h3, h4, h5, h6, .brand-title {
  font-family: 'Outfit', sans-serif;
  font-weight: 600;
  color: var(--text-dark);
  letter-spacing: -0.02em;
}

.section-title {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text-dark);
}

.tiny-label {
  font-family: 'Inter', sans-serif;
  text-transform: uppercase;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

/* Layout */
.layout-shell {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  min-height: 100vh;
  min-width: 0;
  overflow-x: hidden;
  transition: grid-template-columns 0.25s ease;
}

.layout-shell.sidebar-collapsed {
  grid-template-columns: 78px minmax(0, 1fr);
}

/* Sidebar Styling */
.side-panel {
  background: var(--bg-sidebar);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-right: 1px solid var(--border-color);
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  z-index: 10;
}

.brand-block {
  display: flex;
  align-items: center;
  position: relative;
  gap: 0.9rem;
  margin-bottom: 2rem;
  padding: 0.75rem 0.85rem;
  border: 1px solid rgba(4, 120, 87, 0.12);
  border-radius: var(--radius-lg);
  background: linear-gradient(135deg, rgba(209, 250, 229, 0.45), rgba(255, 255, 255, 0.2));
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.04);
}

.sidebar-collapse-toggle {
  margin-left: auto;
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-muted);
  transition: all 0.2s ease;
}

.sidebar-collapse-toggle:hover {
  background: var(--primary-light);
  color: var(--primary-hover);
  border-color: rgba(4, 120, 87, 0.25);
}

.brand-mark {
  width: 52px;
  height: 52px;
  min-width: 52px;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-hover) 100%);
  color: white;
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Outfit', sans-serif;
  font-weight: 700;
  font-size: 1.1rem;
  letter-spacing: 0.04em;
  box-shadow: 0 10px 20px rgba(4, 120, 87, 0.25);
}

.brand-title {
  font-size: 1.1rem;
  margin: 0;
  line-height: 1.15;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-dark);
}

.brand-subtitle {
  font-size: 0.72rem;
  color: var(--primary-hover);
  margin: 0.1rem 0 0;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-weight: 600;
}

/* Navigation Links */
.menu-list {
  gap: 0.5rem;
}

.menu-link {
  font-family: 'Inter', sans-serif;
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  padding: 0.75rem 1rem;
  transition: all 0.2s ease;
  border: 1px solid transparent;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.menu-link i {
  font-size: 1.1rem;
  color: var(--text-muted);
  transition: all 0.2s ease;
}

.menu-link:hover {
  background: white;
  color: var(--text-dark);
  border-color: var(--border-color);
  box-shadow: var(--shadow-sm);
}

[data-theme="dark"] .menu-link:hover {
  background: rgba(51, 65, 85, 0.75);
  color: #f8fafc;
  border-color: rgba(148, 163, 184, 0.4);
}

.menu-link:hover i {
  color: var(--primary);
}

.menu-link.active {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
  box-shadow: 0 4px 12px rgba(4, 120, 87, 0.25);
}

.menu-link.active i {
  color: white;
}

/* Submenu Links */
.menu-sublist {
  margin-left: 1rem;
  padding-left: 1rem;
  border-left: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  margin-top: 0;
  margin-bottom: 0;
  max-height: 0;
  overflow: hidden;
  opacity: 0;
  transform: translateY(-4px);
  pointer-events: none;
  transition: max-height 0.28s ease, opacity 0.2s ease, transform 0.2s ease, margin 0.2s ease;
}

.menu-sublist.open {
  max-height: 420px;
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
  margin-top: 0.25rem;
  margin-bottom: 0.5rem;
}

.toggle-icon {
  transition: transform 0.2s ease;
}

.menu-link.open .toggle-icon {
  transform: rotate(-180deg);
}

.menu-sublink {
  font-size: 0.85rem;
  padding: 0.5rem 0.75rem;
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  transition: all 0.2s ease;
}

.menu-sublink:hover {
  background: var(--primary-light);
  color: var(--primary-hover);
}

.menu-list .menu-sublink.active {
  background: linear-gradient(135deg, rgba(4, 120, 87, 0.15), rgba(4, 120, 87, 0.08));
  color: var(--primary-hover);
  border: 1px solid rgba(4, 120, 87, 0.2);
  font-weight: 600;
}

.menu-list .menu-sublink.active:hover {
  background: var(--primary-light);
  color: var(--primary-hover);
}

.menu-link.open:not(.active) {
  background: rgba(255, 255, 255, 0.75);
  color: var(--text-dark);
}

[data-theme="dark"] .menu-link.open:not(.active) {
  background: rgba(51, 65, 85, 0.7);
  color: #f8fafc;
}

.sidebar-collapsed .side-panel {
  padding: 1rem 0.75rem;
}

.sidebar-collapsed .brand-block {
  justify-content: center;
  padding: 0.75rem 0.4rem;
}

.sidebar-collapsed .brand-block > div,
.sidebar-collapsed .menu-link span,
.sidebar-collapsed #sidebarUserInfo,
.sidebar-collapsed .side-panel .btn-outline-danger span {
  display: none;
}

.sidebar-collapsed .sidebar-collapse-toggle {
  position: absolute;
  top: 1rem;
  right: -0.9rem;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--bg-sidebar);
  box-shadow: var(--shadow-sm);
}

.sidebar-collapsed .menu-link {
  justify-content: center;
  padding: 0.75rem 0.5rem;
}

.sidebar-collapsed .menu-link .toggle-icon,
.sidebar-collapsed .menu-sublist {
  display: none;
}

.sidebar-collapsed .side-panel .btn-outline-danger {
  padding: 0.65rem 0.5rem;
}

.sidebar-collapsed .side-panel .btn-outline-danger i {
  margin: 0;
}

/* Main Content Area */
.main-panel {
  padding: 2rem;
  max-width: 1400px;
  margin: 0 auto;
  width: 100%;
  min-width: 0;
}

/* Topbar */
.topbar {
  background: var(--bg-card);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: 0.9rem 1.25rem;
  box-shadow: var(--shadow-glass);
  margin-bottom: 1rem;
  animation: fadeIn 0.28s ease;
}

#darkModeToggle {
  width: 40px;
  height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-color: var(--border-color);
}

#darkModeToggle:hover {
  background: var(--primary-light);
  color: var(--primary-hover);
}

.tabs-shell {
  margin-bottom: 1rem;
  padding: 0.5rem 1rem 0;
  background: transparent;
  border: none;
  animation: fadeIn 0.32s ease;
}

#mainTabList {
  border-bottom: 1px solid var(--border-color);
  gap: 0.25rem;
}

#mainTabList .nav-link {
  border: 1px solid transparent;
  border-top-left-radius: 10px;
  border-top-right-radius: 10px;
  color: var(--text-muted);
  font-weight: 500;
  padding: 0.55rem 0.9rem;
}

#mainTabList .nav-link:hover {
  color: var(--text-dark);
  border-color: var(--border-color);
  background: rgba(255, 255, 255, 0.45);
}

[data-theme="dark"] #mainTabList .nav-link:hover {
  color: #f8fafc;
  background: rgba(51, 65, 85, 0.65);
}

#mainTabList .nav-link.active {
  color: var(--primary-hover);
  border-color: var(--border-color);
  border-bottom-color: transparent;
  background: var(--bg-card);
}

.tab-content {
  padding-top: 0.75rem !important;
}

.metric-caption {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin: 0;
}

.metric-trend {
  font-size: 0.78rem;
  font-weight: 600;
  margin-top: 0.45rem;
  margin-bottom: 0;
  letter-spacing: 0.01em;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.25rem 0.5rem;
  border-radius: 999px;
  border: 1px solid transparent;
}

.metric-trend.updated {
  animation: trendPopIn 0.36s ease;
}

.metric-trend .trend-icon {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.72rem;
  flex-shrink: 0;
}

.metric-trend.is-up {
  color: #065f46;
  background: rgba(16, 185, 129, 0.18);
  border-color: rgba(5, 150, 105, 0.28);
}

.metric-trend.is-up .trend-icon {
  background: rgba(5, 150, 105, 0.2);
}

.metric-trend.is-down {
  color: #991b1b;
  background: rgba(248, 113, 113, 0.18);
  border-color: rgba(220, 38, 38, 0.24);
}

.metric-trend.is-down .trend-icon {
  background: rgba(220, 38, 38, 0.2);
}

.metric-trend.is-neutral {
  color: #334155;
  background: rgba(148, 163, 184, 0.2);
  border-color: rgba(100, 116, 139, 0.24);
}

.metric-trend.is-neutral .trend-icon {
  background: rgba(100, 116, 139, 0.18);
}

[data-theme="dark"] .metric-trend.is-up {
  color: #34d399;
  background: rgba(16, 185, 129, 0.16);
  border-color: rgba(16, 185, 129, 0.3);
}

[data-theme="dark"] .metric-trend.is-down {
  color: #f87171;
  background: rgba(239, 68, 68, 0.16);
  border-color: rgba(248, 113, 113, 0.28);
}

[data-theme="dark"] .metric-trend.is-neutral {
  color: #cbd5e1;
  background: rgba(71, 85, 105, 0.3);
  border-color: rgba(148, 163, 184, 0.3);
}

.badge.text-bg-light-subtle {
  background-color: var(--primary-light) !important;
  color: var(--primary-hover) !important;
  border: 1px solid rgba(4, 120, 87, 0.2) !important;
  padding: 0.4em 0.8em;
  border-radius: 20px;
  font-weight: 600;
}

/* Cards (Glassmorphism Premium) */
.card-premium {
  background: var(--bg-card);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-glass);
  overflow: hidden;
  transition: transform 0.28s ease, box-shadow 0.28s ease;
}

.card-premium:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.card-body {
  padding: 1.5rem;
}

/* Premium Buttons */
.btn-gold {
  background: linear-gradient(135deg, var(--secondary), var(--secondary-hover));
  color: white;
  border: none;
  font-weight: 500;
  border-radius: var(--radius-sm);
  padding: 0.5rem 1.25rem;
  box-shadow: 0 4px 10px rgba(180, 83, 9, 0.2);
  transition: all 0.3s ease;
}

.btn-gold:hover {
  background: linear-gradient(135deg, var(--secondary-hover), var(--secondary));
  transform: translateY(-2px);
  box-shadow: 0 6px 14px rgba(180, 83, 9, 0.3);
  color: white;
}

.btn-outline-primary {
  color: var(--primary);
  border-color: var(--primary);
}

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

.btn-selecionar-associado {
  background-color: var(--primary);
  border: 1px solid var(--primary);
  border-radius: var(--radius-sm);
  color: #ffffff;
  font-weight: 600;
  white-space: nowrap;
}

.btn-selecionar-associado:hover,
.btn-selecionar-associado:focus-visible {
  background-color: var(--primary-hover);
  border-color: var(--primary-hover);
  color: #ffffff;
}

.btn-selecionar-associado:focus-visible {
  box-shadow: 0 0 0 0.25rem rgba(4, 120, 87, 0.3);
}

.btn-corrigir-gaveta {
  background-color: #b45309;
  border: 1px solid #92400e;
  border-radius: var(--radius-sm);
  box-shadow: 0 4px 10px rgba(146, 64, 14, 0.22);
  color: #ffffff;
  font-weight: 600;
  padding: 0.5rem 1.25rem;
}

.btn-corrigir-gaveta:hover,
.btn-corrigir-gaveta:focus-visible {
  background-color: #92400e;
  border-color: #78350f;
  color: #ffffff;
}

.btn-corrigir-gaveta:focus-visible {
  box-shadow: 0 0 0 0.25rem rgba(245, 158, 11, 0.35);
}

/* Views and Animations */
.view {
  display: none;
  opacity: 0;
  animation: fadeIn 0.4s ease forwards;
}

.active-view {
  display: block;
}

.subview-pane {
  display: none;
  opacity: 0;
}

.subview-pane.active-subview {
  display: block;
  animation: slideUpFade 0.4s ease forwards;
}

/* Tables */
.table-responsive {
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
  background: var(--bg-card);
  overflow: auto;
}

#sepultadosTableContainer {
  display: block;
  width: 100%;
  min-width: 0;
  max-height: min(68vh, 680px);
  overflow-x: scroll;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
}

#sepultadosTableContainer .table-premium {
  width: max-content;
  min-width: 1280px;
}

#sepultadosTableContainer::-webkit-scrollbar {
  height: 14px;
  width: 14px;
}

#sepultadosTableContainer::-webkit-scrollbar-track {
  background: rgba(148, 163, 184, 0.22);
}

#sepultadosTableContainer::-webkit-scrollbar-thumb {
  background: rgba(71, 85, 105, 0.6);
  border-radius: 999px;
}

#cadSepultamentoPane,
#cadSepultamentoPane .module-shell,
#cadSepultamentoPane .module-content,
#cadSepultamentoPane .card,
#cadSepultamentoPane .card-body {
  min-width: 0;
  max-width: 100%;
}

#cadSepultamentoPane .filtro-data-lista {
  font-size: 0.9rem;
}

.table-premium {
  margin-bottom: 0;
  width: 100%;
}

.table-premium thead th {
  background: #f8fafc;
  color: var(--text-muted);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 2;
}

.table-premium tr td {
  border-bottom: 1px solid var(--border-color);
  color: var(--text-dark);
}

.table-premium tbody tr:nth-child(even) td {
  background: rgba(148, 163, 184, 0.06);
}

[data-theme="dark"] .table-premium th {
  color: var(--text-muted);
  background: rgba(30, 41, 59, 0.98);
}

[data-theme="dark"] .table-premium td {
  color: #e2e8f0;
}

.table-premium tr:hover td {
  background-color: rgba(0, 0, 0, 0.02);
}

[data-theme="dark"] .table-premium tr:hover td {
  background-color: rgba(255, 255, 255, 0.02);
}

[data-theme="dark"] .table-premium tbody tr:nth-child(even) td {
  background: rgba(15, 23, 42, 0.45);
}

/* Row Action Buttons Hover Effect */
.table-premium .row-action {
  opacity: 0;
  transform: translateY(2px);
  transition: all 0.2s ease;
}

.table-premium tr:hover .row-action {
  opacity: 1;
  transform: translateY(0);
}

/* Action Buttons in Table */
.row-action {
  font-size: 0.8rem;
  padding: 0.3rem 0.6rem;
  border-radius: 6px;
  font-weight: 500;
  margin-right: 0.25rem;
}

.table-premium tbody tr {
  transition: background-color 0.2s ease;
}

.table-auditoria {
  min-width: 760px;
}

.table-auditoria th:first-child,
.table-auditoria td:first-child {
  width: 172px;
}

.table-auditoria th:nth-child(2),
.table-auditoria td:nth-child(2) {
  width: 140px;
}

.table-auditoria th:nth-child(3),
.table-auditoria td:nth-child(3) {
  width: 110px;
}

.table-auditoria td:last-child {
  min-width: 280px;
}

/* Status Pills */
.status-pill {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.3em 0.8em;
  border-radius: 20px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.status-ativo {
  background-color: var(--primary-light);
  color: var(--primary-hover);
  border: 1px solid rgba(4, 120, 87, 0.2);
}

.status-exumado {
  background-color: #fef3c7;
  color: #92400e;
  border: 1px solid rgba(180, 83, 9, 0.2);
}

/* Formulários */
.form-label {
  font-weight: 500;
  font-size: 0.9rem;
  color: var(--text-dark);
}

.form-control, .form-select {
  background-color: rgba(255, 255, 255, 0.6);
  border: 1px solid var(--border-color);
  color: var(--text-dark);
}

[data-theme="dark"] .form-control, 
[data-theme="dark"] .form-select {
  background-color: rgba(0, 0, 0, 0.2);
  color: var(--text-dark);
}

[data-theme="dark"] .form-control::placeholder {
  color: var(--text-muted);
}

.form-control::placeholder {
  color: #64748b;
}

.form-control:focus, .form-select:focus {
  background-color: #fff;
  border-color: var(--primary);
  box-shadow: 0 0 0 4px var(--primary-light);
  color: var(--text-dark);
}

[data-theme="dark"] .form-control:focus, 
[data-theme="dark"] .form-select:focus {
  background-color: rgba(0, 0, 0, 0.4);
}

.form-label {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-dark);
  margin-bottom: 0.4rem;
}

.nivel-acesso-permissoes-acoes {
  display: flex;
  gap: 0.5rem;
}

.nivel-acesso-permissoes {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0.65rem;
  padding: 0.85rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background: rgba(248, 250, 252, 0.65);
}

.nivel-acesso-permissao {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.65rem;
  min-height: 46px;
  padding: 0.65rem 0.75rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  color: var(--text-dark);
  cursor: pointer;
  transition: border-color 0.2s ease, background-color 0.2s ease, box-shadow 0.2s ease;
}

.nivel-acesso-permissao:hover {
  border-color: rgba(4, 120, 87, 0.45);
  background: var(--primary-light);
}

.nivel-acesso-permissao input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.nivel-acesso-permissao-marca {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  flex: 0 0 20px;
  border: 2px solid var(--text-muted);
  border-radius: 5px;
  color: white;
  transition: all 0.2s ease;
}

.nivel-acesso-permissao-marca i {
  font-size: 0.85rem;
  opacity: 0;
}

.nivel-acesso-permissao input:checked + .nivel-acesso-permissao-marca {
  border-color: var(--primary);
  background: var(--primary);
}

.nivel-acesso-permissao input:checked + .nivel-acesso-permissao-marca i {
  opacity: 1;
}

.nivel-acesso-permissao input:focus-visible + .nivel-acesso-permissao-marca {
  outline: 3px solid var(--primary-light);
  outline-offset: 2px;
}

.nivel-acesso-permissao:has(input:checked) {
  border-color: rgba(4, 120, 87, 0.45);
  box-shadow: 0 2px 8px rgba(4, 120, 87, 0.08);
}

[data-theme="dark"] .nivel-acesso-permissoes {
  background: rgba(15, 23, 42, 0.35);
}

/* Select2 */
.select2-container {
  width: 100% !important;
}

.select2-container .select2-selection--single,
.select2-container .select2-selection--multiple {
  min-height: 38px;
  background-color: rgba(255, 255, 255, 0.6);
  border: 1px solid var(--border-color);
  color: var(--text-dark);
  border-radius: 0.375rem;
  transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out, background-color 0.15s ease-in-out;
}

.select2-container .select2-selection--single .select2-selection__rendered {
  line-height: 36px;
  color: var(--text-dark);
  padding-left: 0.75rem;
  padding-right: 2rem;
}

.select2-container .select2-selection--single .select2-selection__placeholder {
  color: #64748b;
}

.select2-container .select2-selection--single .select2-selection__arrow {
  height: 36px;
  right: 0.5rem;
}

.select2-container--default .select2-selection--single .select2-selection__arrow b {
  border-color: var(--text-muted) transparent transparent transparent;
}

.select2-container .select2-selection--multiple {
  padding: 2px 0.5rem;
}

.select2-container .select2-selection--multiple .select2-selection__rendered {
  padding: 0;
}

.select2-container .select2-selection--multiple .select2-selection__choice {
  background-color: var(--primary-light);
  border: 1px solid rgba(4, 120, 87, 0.2);
  color: var(--primary-hover);
  border-radius: 999px;
  padding: 0.1rem 0.5rem;
}

.select2-container--default.select2-container--focus .select2-selection--single,
.select2-container--default.select2-container--focus .select2-selection--multiple,
.select2-container--default.select2-container--open .select2-selection--single,
.select2-container--default.select2-container--open .select2-selection--multiple {
  background-color: #fff;
  border-color: var(--primary);
  box-shadow: 0 0 0 4px var(--primary-light);
}

.select2-dropdown {
  border: 1px solid var(--border-color);
  border-radius: 0.5rem;
  overflow: hidden;
  box-shadow: var(--shadow-md);
  background: #fff;
}

.select2-search--dropdown {
  padding: 0.5rem;
  background: #fff;
}

.select2-search--dropdown .select2-search__field {
  border: 1px solid var(--border-color);
  border-radius: 0.375rem;
  padding: 0.375rem 0.5rem;
  background: #fff;
  color: var(--text-dark);
}

.select2-results__option {
  padding: 0.5rem 0.75rem;
}

.select2-container--default .select2-results__option--highlighted.select2-results__option--selectable {
  background: var(--primary);
  color: #fff;
}

[data-theme="dark"] .select2-container .select2-selection--single,
[data-theme="dark"] .select2-container .select2-selection--multiple {
  background-color: rgba(0, 0, 0, 0.2);
  color: var(--text-dark);
}

[data-theme="dark"] .select2-container .select2-selection--single .select2-selection__rendered,
[data-theme="dark"] .select2-container .select2-selection--multiple .select2-selection__rendered {
  color: var(--text-dark);
}

[data-theme="dark"] .select2-container .select2-selection--single .select2-selection__placeholder {
  color: var(--text-muted);
}

[data-theme="dark"] .select2-container--default.select2-container--focus .select2-selection--single,
[data-theme="dark"] .select2-container--default.select2-container--focus .select2-selection--multiple,
[data-theme="dark"] .select2-container--default.select2-container--open .select2-selection--single,
[data-theme="dark"] .select2-container--default.select2-container--open .select2-selection--multiple {
  background-color: rgba(0, 0, 0, 0.4);
}

[data-theme="dark"] .select2-dropdown,
[data-theme="dark"] .select2-search--dropdown {
  background: rgba(15, 23, 42, 0.98);
  border-color: var(--border-color);
}

[data-theme="dark"] .select2-search--dropdown .select2-search__field {
  background: rgba(0, 0, 0, 0.25);
  border-color: var(--border-color);
  color: var(--text-dark);
}

[data-theme="dark"] .select2-results__option {
  color: var(--text-dark);
}

/* Modals */
.modal-premium {
  border: none;
  border-radius: var(--radius-xl);
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
  overflow: hidden;
}

.modal-header {
  background: #f8fafc;
  border-bottom: 1px solid var(--border-color);
  padding: 1.5rem;
}

.modal-title {
  font-family: 'Outfit', sans-serif;
  font-weight: 600;
  color: var(--text-dark);
}

.modal-body {
  padding: 1.5rem;
}

.modal-footer {
  background: #f8fafc;
  border-top: 1px solid var(--border-color);
  padding: 1.25rem 1.5rem;
}

#novaQuadraModal .modal-dialog {
  max-width: 980px;
}

#novaQuadraModal .modal-body {
  padding: 1.25rem 1.5rem;
}

#novaQuadraModal #quadraModalTabs {
  flex-wrap: nowrap;
}

#novaQuadraModal #quadraLotesPane .table-responsive {
  max-height: 320px;
}

#novaQuadraModal #btnAdicionarQuadraLote {
  width: 100%;
  white-space: nowrap;
}

[data-theme="dark"] .modal-header,
[data-theme="dark"] .modal-footer {
  background: rgba(15, 23, 42, 0.9);
}

#mainTabContent > .tab-pane.active {
  animation: slideUpFade 0.26s ease;
}

/* Modules Sidebar (e.g. in Cemiterio view) */
.module-shell {
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 1.5rem;
}

.module-sidebar {
  background: var(--bg-sidebar);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
  padding: 1rem;
  height: fit-content;
  box-shadow: var(--shadow-sm);
}

.subview-link {
  font-family: 'Inter', sans-serif;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  padding: 0.6rem 1rem;
  margin-bottom: 0.25rem;
  transition: all 0.2s ease;
  border: none;
  width: 100%;
  text-align: left;
  background: transparent;
}

.subview-link:hover {
  background-color: #f1f5f9;
  color: var(--text-dark);
}

.subview-link.active {
  background-color: var(--primary-light);
  color: var(--primary-hover);
  font-weight: 600;
}

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

@keyframes slideUpFade {
  from { 
    opacity: 0;
    transform: translateY(15px);
  }
  to { 
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes trendPopIn {
  0% {
    opacity: 0;
    transform: translateY(4px) scale(0.985);
  }
  65% {
    opacity: 1;
    transform: translateY(0) scale(1.012);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@media (prefers-reduced-motion: reduce) {
  .metric-trend.updated {
    animation: none;
  }
}

/* Responsive */
@media (max-width: 991.98px) {
  .layout-shell {
    grid-template-columns: 1fr;
    transition: none;
  }

  .layout-shell.sidebar-collapsed {
    grid-template-columns: 1fr;
  }
  
  .main-panel {
    padding: 1rem;
  }
  
  .module-shell {
    grid-template-columns: 1fr;
  }

  .tabs-shell {
    padding-left: 0;
    padding-right: 0;
  }

  .table-premium .row-action {
    opacity: 1;
    transform: none;
  }

  .map-card {
    width: 132px;
  }

  .map-card.map-card-compact {
    width: 96px;
  }

  #novaQuadraModal .modal-dialog {
    max-width: calc(100% - 1rem);
    margin: 0.5rem auto;
  }

  #novaQuadraModal .modal-body,
  #novaQuadraModal .modal-footer,
  #novaQuadraModal .modal-header {
    padding-left: 1rem;
    padding-right: 1rem;
  }
}
.btn-outline-danger {
  color: #dc2626;
  border-color: #fca5a5;
}
.btn-outline-danger:hover {
  background-color: #fee2e2;
  color: #b91c1c;
  border-color: #fca5a5;
}

.module-shell.module-shell-full {
  grid-template-columns: 1fr;
}

/* Refinos visuais do painel de relatorios */
#relatorioPainelPane .card-body {
  padding: 1.25rem 1.4rem;
}

#relatorioPainelPane .module-content,
#relatorioPainelPane .card-body,
#relatorioOutput {
  min-width: 0;
  max-width: 100%;
}

#filtrosRelatorioSepultado,
#filtrosRelatorioAssociado,
#filtrosRelatorioExumacao,
#filtrosRelatorioQlg,
#filtrosRelatorioQlgFuneraria {
  background: rgba(148, 163, 184, 0.06);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.7rem;
}

#filtrosRelatorioSepultado .form-control,
#filtrosRelatorioSepultado .form-select,
#filtrosRelatorioAssociado .form-control,
#filtrosRelatorioAssociado .form-select,
#filtrosRelatorioExumacao .form-control,
#filtrosRelatorioExumacao .form-select,
#filtrosRelatorioQlg .form-control,
#filtrosRelatorioQlg .form-select,
#filtrosRelatorioQlgFuneraria .form-control,
#filtrosRelatorioQlgFuneraria .form-select {
  min-height: 38px;
}

/* Select2 em campos compactos (sm) */
.form-select-sm + .select2-container .select2-selection--single {
  min-height: 38px;
}

.form-select-sm + .select2-container .select2-selection--single .select2-selection__rendered {
  line-height: 36px;
  font-size: 0.95rem;
}

.form-select-sm + .select2-container .select2-selection--single .select2-selection__arrow {
  height: 36px;
}

.select2-container .select2-selection--single {
  position: relative;
}

.select2-container--default .select2-selection--single .select2-selection__clear {
  position: absolute;
  right: 1.6rem;
  top: 50%;
  transform: translateY(-50%);
  margin: 0;
  color: var(--text-muted);
  font-weight: 700;
}

#relatorioOutput table th {
  white-space: nowrap;
}

#relatorioOutput {
  max-width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  overscroll-behavior-x: contain;
}

#relatorioOutput[data-report-type="sepultado"] table,
#relatorioOutput[data-report-type="exumacao"] table {
  width: max-content;
  min-width: 1400px;
}

#relatorioOutput[data-report-type="sepultado"],
#relatorioOutput[data-report-type="exumacao"] {
  display: block;
  width: 100%;
  overflow-x: scroll;
}

#relatorioOutput[data-report-type="sepultado"]::-webkit-scrollbar,
#relatorioOutput[data-report-type="exumacao"]::-webkit-scrollbar {
  height: 14px;
}

#relatorioOutput[data-report-type="sepultado"]::-webkit-scrollbar-track,
#relatorioOutput[data-report-type="exumacao"]::-webkit-scrollbar-track {
  background: rgba(148, 163, 184, 0.22);
  border-radius: 999px;
}

#relatorioOutput[data-report-type="sepultado"]::-webkit-scrollbar-thumb,
#relatorioOutput[data-report-type="exumacao"]::-webkit-scrollbar-thumb {
  background: var(--primary);
  border: 3px solid rgba(148, 163, 184, 0.22);
  border-radius: 999px;
}

#relatorioOutput[data-report-type="sepultado"]::-webkit-scrollbar-thumb:hover,
#relatorioOutput[data-report-type="exumacao"]::-webkit-scrollbar-thumb:hover {
  background: var(--primary-hover);
}

#relatorioOutput table td,
#relatorioOutput table th {
  vertical-align: middle;
}

@media (max-width: 991.98px) {
  #filtrosRelatorioSepultado .col-md-1,
  #filtrosRelatorioSepultado .col-md-2 {
    min-width: 0;
  }

  #relatorioOutput table th {
    white-space: normal;
  }
}

.map-legend {
  background: rgba(248, 250, 252, 0.75);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.5rem 0.75rem;
}

.map-legend-item {
  font-size: 0.82rem;
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.map-dot {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  display: inline-block;
}

.map-dot-livre {
  background: #16a34a;
}

.map-dot-ocupado {
  background: #dc2626;
}

.map-dot-critico {
  background: #f59e0b;
}

.map-summary {
  font-size: 0.85rem;
  color: var(--text-muted);
  background: rgba(248, 250, 252, 0.65);
  border: 1px dashed var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.55rem 0.75rem;
}

.map-card {
  width: 160px;
  cursor: pointer;
  border: 0;
  border-radius: 12px;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.map-card:hover {
  transform: translateY(-2px);
}

.map-card.map-card-compact {
  width: 112px;
}

.map-status-tag {
  font-size: 0.62rem;
  padding: 0.1rem 0.35rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.2);
  line-height: 1.2;
}

.map-card-action {
  margin-top: 0.4rem;
  font-size: 0.68rem;
  padding: 0.1rem 0.45rem;
  border-radius: 999px;
  font-weight: 600;
  align-self: flex-start;
}

.map-section {
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.map-section-critical {
  border-color: rgba(245, 158, 11, 0.45) !important;
  box-shadow: inset 0 0 0 1px rgba(245, 158, 11, 0.2);
}

#mapaQuickFilters .btn.active {
  box-shadow: none;
}

[data-theme="dark"] .map-legend,
[data-theme="dark"] .map-summary {
  background: rgba(30, 41, 59, 0.75);
}

[data-theme="dark"] .map-legend-item {
  color: #cbd5e1;
}

[data-theme="dark"] .map-section {
  background: rgba(30, 41, 59, 0.35) !important;
}

[data-theme="dark"] .map-card-action {
  background: rgba(248, 250, 252, 0.92);
}

.bg-orb {
  position: fixed;
  border-radius: 50%;
  filter: blur(40px);
  z-index: 0;
  pointer-events: none;
}
.bg-orb-a {
  width: 300px;
  height: 300px;
  background: rgba(4, 120, 87, 0.15);
  top: -100px;
  right: -50px;
}
.bg-orb-b {
  width: 400px;
  height: 400px;
  background: rgba(180, 83, 9, 0.1);
  bottom: -150px;
  left: -100px;
}

/* Garantia extra: painéis inativos sempre ocultos */
#mainTabContent > .tab-pane:not(.active) {
  display: none !important;
}
#mainTabContent > .tab-pane.active {
  display: block !important;
}
