/* Enterprise Dark Mode System: Estándar Verde Petróleo Degradado */
html.dark-mode,
body.dark-mode {
  --slate-50: #041c22;
  --slate-100: #072a33;
  --petrol-subtle: rgba(13, 148, 136, 0.14);
  --slate-200: #0c3844;
  --slate-300: #134e5c;
  --slate-400: #649fa8;
  --slate-500: #93c5cd;
  --slate-600: #c2e5eb;
  --slate-700: #e0f2f5;
  --slate-800: #f0fdfa;
  --slate-900: #ffffff;
  --border-color: #0d3d47;
  --border-subtle: #0d3d47;
  --ink: #f0fdfa;
  --muted: #93c5cd;
  --paper: #021518;
  --surface: #042229;
  --surface-muted: #072a33;
  --card-bg: #042229;
  --line: #0d3d47;
  background-color: #021518;
  color: #f0fdfa;
}

body.dark-mode .sicam-kpi-card,
body.dark-mode .sicam-panel-surface,
body.dark-mode .sicam-modal-box,
body.dark-mode .sicam-confirm-dialog {
  background: #042229;
  border-color: #0d4550;
  color: #f0fdfa;
}
body.dark-mode .sicam-sub-card,
body.dark-mode .sicam-badge-pill {
  background: #072a33;
  border-color: #135260;
  color: #d9f3f5;
}
body.dark-mode .sicam-kpi-label,
body.dark-mode .sicam-kpi-sub,
body.dark-mode .sicam-confirm-message {
  color: #93c5cd;
}
body.dark-mode .sicam-kpi-num,
body.dark-mode .sicam-confirm-title {
  color: #f0fdfa;
}
body.dark-mode #tableView .empty-state-cell {
  background: #042229;
  color: #93c5cd;
}

/* Page Views & Base Layout */
html.dark-mode #homeView,
html.dark-mode #seprecView,
html.dark-mode #adminView,
html.dark-mode #tableView,
html.dark-mode #gacetaView,
html.dark-mode .view,
html.dark-mode .layout,
body.dark-mode #homeView,
body.dark-mode #seprecView,
body.dark-mode #adminView,
body.dark-mode #tableView,
body.dark-mode #gacetaView,
body.dark-mode .view,
body.dark-mode .layout {
  background-color: #021518;
  color: #f0fdfa;
}

html.dark-mode .home-comparison-section,
body.dark-mode .home-comparison-section {
  background: var(--surface);
  border-color: var(--border-color);
}
html.dark-mode .home-compare-card.card-total,
body.dark-mode .home-compare-card.card-total {
  background: rgba(13, 61, 71, 0.4);
  border-color: rgba(20, 184, 166, 0.3);
}
html.dark-mode .home-compare-card.card-aum,
body.dark-mode .home-compare-card.card-aum {
  background: rgba(16, 185, 129, 0.12);
  border-color: rgba(16, 185, 129, 0.35);
}
html.dark-mode .home-compare-card.card-red,
body.dark-mode .home-compare-card.card-red {
  background: rgba(239, 68, 68, 0.12);
  border-color: rgba(239, 68, 68, 0.35);
}
html.dark-mode .home-compare-card.card-man,
body.dark-mode .home-compare-card.card-man {
  background: rgba(14, 116, 144, 0.15);
  border-color: rgba(14, 116, 144, 0.35);
}
html.dark-mode .home-compare-card.card-delta,
body.dark-mode .home-compare-card.card-delta {
  background: rgba(245, 158, 11, 0.12);
  border-color: rgba(245, 158, 11, 0.35);
}

/* Header retains crisp dark petroleum branding */
html.dark-mode header#headerNav,
body.dark-mode header#headerNav {
  background: var(--petrol-grad-header);
  border-bottom: 1px solid rgba(20, 184, 166, 0.28);
  color: #ffffff;
}
html.dark-mode header#headerNav .brand,
body.dark-mode header#headerNav .brand {
  color: #ffffff;
}
html.dark-mode header#headerNav .nav button:not(.active),
body.dark-mode header#headerNav .nav button:not(.active) {
  color: #93c5cd;
  background: transparent;
}
html.dark-mode header#headerNav .nav button:not(.active):hover,
body.dark-mode header#headerNav .nav button:not(.active):hover {
  color: #ffffff;
  background: rgba(20, 184, 166, 0.15);
}

/* Login View Dark Mode */
html.dark-mode #loginView,
body.dark-mode #loginView {
  background: #021518;
}
html.dark-mode .login-form-wrapper,
body.dark-mode .login-form-wrapper {
  background: #042229;
  border-left: 1px solid rgba(20, 184, 166, 0.25);
}
html.dark-mode .login-card h2,
body.dark-mode .login-card h2 {
  color: #f0fdfa;
}
html.dark-mode .login-card p,
body.dark-mode .login-card p {
  color: #93c5cd;
}

/* Headings & Section Titles */
html.dark-mode .admin-header h2,
html.dark-mode .admin-card h2,
html.dark-mode .admin-card h3,
html.dark-mode .card h2,
html.dark-mode .card h3,
html.dark-mode h1, 
html.dark-mode h2, 
html.dark-mode h3,
body.dark-mode .admin-header h2,
body.dark-mode .admin-card h2,
body.dark-mode .admin-card h3,
body.dark-mode .card h2,
body.dark-mode .card h3,
body.dark-mode h1, 
body.dark-mode h2, 
body.dark-mode h3 {
  color: #f0fdfa;
  border-bottom-color: #0d3d47;
}
html.dark-mode .admin-header span,
html.dark-mode p,
body.dark-mode .admin-header span,
body.dark-mode p {
  color: #93c5cd;
}

/* Cards & Elevated Containers */
html.dark-mode .admin-card,
html.dark-mode .card,
html.dark-mode .panel,
html.dark-mode .metrics,
html.dark-mode .table-wrap,
html.dark-mode .user-grid,
html.dark-mode .gaceta-card,
html.dark-mode .gaceta-table-wrap,
html.dark-mode .gaceta-filter-box,
html.dark-mode #gacetaSubscriptionBox,
html.dark-mode .seprec-slideover-panel,
html.dark-mode .ajam-slideover-panel,
html.dark-mode .seprec-result-card,
html.dark-mode .report-card,
body.dark-mode .admin-card,
body.dark-mode .card,
body.dark-mode .panel,
body.dark-mode .metrics,
body.dark-mode .table-wrap,
body.dark-mode .user-grid,
body.dark-mode .gaceta-card,
body.dark-mode .gaceta-table-wrap,
body.dark-mode .gaceta-filter-box,
body.dark-mode #gacetaSubscriptionBox,
body.dark-mode .seprec-slideover-panel,
body.dark-mode .ajam-slideover-panel,
body.dark-mode .seprec-result-card,
body.dark-mode .report-card {
  background-color: #042229;
  border-color: #0d3d47;
  color: #f0fdfa;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
}

/* SEPREC Slideover Panel & Detail Tables */
html.dark-mode .seprec-detail-table th,
body.dark-mode .seprec-detail-table th {
  background: #072d36;
  color: #93c5cd;
  border-bottom-color: #0d3d47;
}
html.dark-mode .seprec-detail-table td,
body.dark-mode .seprec-detail-table td {
  color: #e0f2f5;
  border-bottom-color: #0d3d47;
}
html.dark-mode .seprec-detail-table tr:nth-child(even),
body.dark-mode .seprec-detail-table tr:nth-child(even) {
  background: rgba(20, 184, 166, 0.04);
}

/* Map Navigation Bar & Search Controls */
html.dark-mode #mapSearchResultNav,
html.dark-mode .map-search-container,
html.dark-mode .map-search-bar,
body.dark-mode #mapSearchResultNav,
body.dark-mode .map-search-container,
body.dark-mode .map-search-bar {
  background: #042229;
  border-color: #0d3d47;
  color: #f0fdfa;
}

/* MapLibre Controls & Popups */
html.dark-mode .maplibregl-popup-content,
body.dark-mode .maplibregl-popup-content {
  background: #042229 !important;
  color: #f0fdfa !important;
  border: 1px solid #0d3d47 !important;
  box-shadow: 0 12px 32px rgba(0,0,0,0.7) !important;
}
html.dark-mode .maplibregl-popup-anchor-bottom .maplibregl-popup-tip,
body.dark-mode .maplibregl-popup-anchor-bottom .maplibregl-popup-tip { border-top-color: #042229 !important; }
html.dark-mode .maplibregl-popup-anchor-top .maplibregl-popup-tip,
body.dark-mode .maplibregl-popup-anchor-top .maplibregl-popup-tip { border-bottom-color: #042229 !important; }
html.dark-mode .maplibregl-popup-anchor-left .maplibregl-popup-tip,
body.dark-mode .maplibregl-popup-anchor-left .maplibregl-popup-tip { border-right-color: #042229 !important; }
html.dark-mode .maplibregl-popup-anchor-right .maplibregl-popup-tip,
body.dark-mode .maplibregl-popup-anchor-right .maplibregl-popup-tip { border-left-color: #042229 !important; }

/* Earth Popup Dark Mode Theming (Alto contraste y armonía verde petróleo) */
html.dark-mode .earth-popup,
body.dark-mode .earth-popup {
  background: #042229;
  color: #f0fdfa;
}
html.dark-mode .earth-popup-title-bar,
body.dark-mode .earth-popup-title-bar {
  background: #062e38;
  color: #f0fdfa;
  border-bottom: 1px solid #0d3d47;
}
html.dark-mode .earth-popup-header,
body.dark-mode .earth-popup-header {
  background: linear-gradient(135deg, #0d5852, #0a4440);
  color: #5eead4;
  border-bottom: 1px solid #115e59;
}
html.dark-mode .earth-popup tr:nth-child(even),
body.dark-mode .earth-popup tr:nth-child(even) {
  background: #072a33;
}
html.dark-mode .earth-popup tr:nth-child(odd),
body.dark-mode .earth-popup tr:nth-child(odd) {
  background: #042229;
}
html.dark-mode .earth-popup td,
body.dark-mode .earth-popup td {
  color: #f1f5f9;
  border-bottom: 1px solid #0d3d47;
}
html.dark-mode .earth-popup td:first-child,
body.dark-mode .earth-popup td:first-child {
  color: #93c5fd;
  background: rgba(0, 0, 0, 0.25);
  font-weight: 600;
}
html.dark-mode .earth-popup td strong,
html.dark-mode .earth-popup td b,
body.dark-mode .earth-popup td strong,
body.dark-mode .earth-popup td b {
  color: #ffffff;
  font-weight: 700;
}
html.dark-mode .earth-popup-actions,
body.dark-mode .earth-popup-actions {
  background: #062e38;
  border-top: 1px solid #0d3d47;
}
html.dark-mode .maplibregl-popup-close-button,
html.dark-mode .mapboxgl-popup-close-button,
body.dark-mode .maplibregl-popup-close-button,
body.dark-mode .mapboxgl-popup-close-button {
  color: #94a3b8 !important;
}
html.dark-mode .maplibregl-popup-close-button:hover,
html.dark-mode .mapboxgl-popup-close-button:hover,
body.dark-mode .maplibregl-popup-close-button:hover,
body.dark-mode .mapboxgl-popup-close-button:hover {
  background: #0d3d47 !important;
  color: #ffffff !important;
}
html.dark-mode .maplibregl-ctrl-group,
body.dark-mode .maplibregl-ctrl-group {
  background: #042229 !important;
  border: 1px solid #0d3d47 !important;
}
html.dark-mode .maplibregl-ctrl-group button,
body.dark-mode .maplibregl-ctrl-group button {
  background: #042229 !important;
  border-bottom-color: #0d3d47 !important;
}

/* Mobile Bottom Sheet Dark Mode */
html.dark-mode .mobile-bottom-sheet,
body.dark-mode .mobile-bottom-sheet {
  background: #042229;
  color: #f0fdfa;
  border-top-color: #0d3d47;
  box-shadow: 0 -8px 30px rgba(0,0,0,0.8);
}
html.dark-mode .sheet-title,
body.dark-mode .sheet-title {
  color: #ffffff;
}
html.dark-mode .sheet-drag-handle,
body.dark-mode .sheet-drag-handle {
  background: #0d3d47;
}
html.dark-mode .sheet-close-btn,
body.dark-mode .sheet-close-btn {
  background: #062e38;
  color: #94a3b8;
}
html.dark-mode .sheet-meta-card,
body.dark-mode .sheet-meta-card {
  background: #062831;
  border-color: #0d3d47;
}
html.dark-mode .sheet-meta-card-title,
body.dark-mode .sheet-meta-card-title {
  color: #5eead4;
  border-bottom-color: #0d3d47;
}
html.dark-mode .sheet-meta-table td.meta-label,
body.dark-mode .sheet-meta-table td.meta-label {
  color: #94a3b8;
}
html.dark-mode .sheet-meta-table td.meta-val,
body.dark-mode .sheet-meta-table td.meta-val {
  color: #f8fafc;
}

/* Form Inputs, Selects & Labels */
html.dark-mode input,
html.dark-mode select,
html.dark-mode textarea,
body.dark-mode input,
body.dark-mode select,
body.dark-mode textarea {
  background: #072d36;
  color: #f0fdfa;
  border-color: #0e505d;
}
html.dark-mode input:focus,
html.dark-mode select:focus,
html.dark-mode textarea:focus,
body.dark-mode input:focus,
body.dark-mode select:focus,
body.dark-mode textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(45, 212, 191, 0.3);
}
html.dark-mode input::placeholder,
html.dark-mode select::placeholder,
body.dark-mode input::placeholder,
body.dark-mode select::placeholder {
  color: #649fa8;
}
html.dark-mode label,
body.dark-mode label {
  color: #93c5cd;
}

/* Tables & Grids */
body.dark-mode th,
body.dark-mode .user-grid th,
body.dark-mode .gaceta-table th {
  background: #161e2e;
  color: #9ca3af;
  border-bottom: 1px solid #1f293d;
}
body.dark-mode td,
body.dark-mode .user-grid td,
body.dark-mode .gaceta-table td {
  color: #e5e7eb;
  border-bottom: 1px solid #1f293d;
}
body.dark-mode tr:hover,
body.dark-mode .user-grid tr:hover,
body.dark-mode .gaceta-table tr:hover {
  background: #1f293d;
}

/* Metrics & KPIs */
body.dark-mode .metric {
  border-right-color: #1f293d;
}
body.dark-mode .metric b {
  color: #f3f4f6;
}
body.dark-mode .metric span {
  color: #9ca3af;
}

/* Outline Buttons */
body.dark-mode .btn-outline {
  border-color: #374151;
  color: #e5e7eb;
}
body.dark-mode .btn-outline:hover {
  background: #1f293d;
  color: #ffffff;
}

/* Modal Overlay & Cards */
body.dark-mode .modal {
  background: rgba(3, 7, 18, 0.8);
}
body.dark-mode .modal-content,
body.dark-mode .modal-card,
body.dark-mode .admin-modal-content {
  background: #0f172a;
  color: #f8fafc;
  border: 1px solid #1f293d;
}
body.dark-mode footer {
  background: #080d1a;
  color: #9ca3af;
  border-top-color: #1f293d;
}

/* Special UI Components */
body.dark-mode #oidcTokenDisplay {
  background: #0b0f19;
  border: 1px solid #1f293d;
  color: #38bdf8;
}
body.dark-mode code {
  background: #0b0f19;
  color: #fb923c;
  border: 1px solid #1f293d;
  padding: 2px 6px;
  border-radius: 4px;
}
body.dark-mode .badge-inactive {
  background: #3f1212;
  color: #fca5a5;
}
body.dark-mode .badge-active {
  background: #064e3b;
  color: #6ee7b7;
}
body.dark-mode .spatial-valid {
  background: #064e3b;
  color: #6ee7b7;
}
body.dark-mode .spatial-warning {
  background: #451a03;
  color: #fde68a;
}
body.dark-mode .btn-auth-local-on {
  background: rgba(6, 78, 59, 0.45);
  color: #6ee7b7;
  border-color: #047857;
}
body.dark-mode .btn-auth-local-off {
  background: rgba(127, 29, 29, 0.45);
  color: #fca5a5;
  border-color: #991b1b;
}
body.dark-mode .btn-auth-sso-on {
  background: rgba(19, 78, 74, 0.45);
  color: #5eead4;
  border-color: #0f766e;
}
body.dark-mode .btn-auth-sso-off {
  background: rgba(30, 41, 59, 0.5);
  color: #94a3b8;
  border-color: #475569;
}

body.dark-mode .admin-tab-btn {
  color: #94a3b8;
}
body.dark-mode .admin-tab-btn:hover {
  color: #f1f5f9;
  background: rgba(255, 255, 255, 0.06);
}
body.dark-mode .admin-tab-btn.active {
  background: #1e293b;
  color: #2dd4bf;
  border-color: rgba(45, 212, 191, 0.3);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.35);
}
body.dark-mode .cal-card-item {
  background: #1e293b;
  border-color: #334155;
}
body.dark-mode .cal-card-item.is-proxima {
  border-color: #f59e0b;
  background: rgba(245, 158, 11, 0.12);
}
html.dark-mode .basemap-pill-btn {
  background: rgba(15, 23, 42, 0.65);
  color: #94a3b8;
  border-color: rgba(255, 255, 255, 0.12);
}
html.dark-mode .basemap-pill-btn:hover {
  background: rgba(30, 41, 59, 0.85);
  color: #f8fafc;
}
html.dark-mode .basemap-pill-btn.active {
  background: #0284c7;
  color: #ffffff;
  border-color: #38bdf8;
  box-shadow: 0 0 12px rgba(56, 189, 248, 0.4);
}
