/* ================================================
   SENTINELA - Dark Theme Fix
   Correcoes de contraste para tema escuro
   ================================================ */

/* ================================================
   KPI Cards - Dark Theme
   ================================================ */

[data-theme="dark"] .kpi-card-primary {
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.25) 0%, rgba(37, 99, 235, 0.35) 100%);
  color: #93C5FD;
  border: 1px solid rgba(59, 130, 246, 0.4);
}

[data-theme="dark"] .kpi-card-primary .kpi-value,
[data-theme="dark"] .kpi-card-primary .kpi-label {
  color: #BFDBFE;
}

[data-theme="dark"] .kpi-card-secondary {
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.25) 0%, rgba(5, 150, 105, 0.35) 100%);
  color: #6EE7B7;
  border: 1px solid rgba(16, 185, 129, 0.4);
}

[data-theme="dark"] .kpi-card-secondary .kpi-value,
[data-theme="dark"] .kpi-card-secondary .kpi-label {
  color: #A7F3D0;
}

[data-theme="dark"] .kpi-card-warning {
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.25) 0%, rgba(217, 119, 6, 0.35) 100%);
  color: #FCD34D;
  border: 1px solid rgba(245, 158, 11, 0.4);
}

[data-theme="dark"] .kpi-card-warning .kpi-value,
[data-theme="dark"] .kpi-card-warning .kpi-label {
  color: #FDE68A;
}

[data-theme="dark"] .kpi-card-info {
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.25) 0%, rgba(79, 70, 229, 0.35) 100%);
  color: #A5B4FC;
  border: 1px solid rgba(99, 102, 241, 0.4);
}

[data-theme="dark"] .kpi-card-info .kpi-value,
[data-theme="dark"] .kpi-card-info .kpi-label {
  color: #C7D2FE;
}

/* ================================================
   Timeline - Dark Theme
   ================================================ */

[data-theme="dark"] .timeline-item {
  color: var(--color-surface-foreground);
}

[data-theme="dark"] .timeline-title {
  color: #F3F4F6;
}

[data-theme="dark"] .timeline-time {
  color: #9CA3AF;
}

[data-theme="dark"] .timeline-content {
  color: #E5E7EB;
}

/* ================================================
   Checkboxes e Tasks - Dark Theme
   ================================================ */

[data-theme="dark"] .task-item,
[data-theme="dark"] .checklist-item {
  color: #F3F4F6;
  background: var(--color-surface);
  border-color: var(--color-border);
}

[data-theme="dark"] .task-item label,
[data-theme="dark"] .checklist-item label,
[data-theme="dark"] .task-text,
[data-theme="dark"] .task-label {
  color: #E5E7EB !important;
}

[data-theme="dark"] input[type="checkbox"] + label,
[data-theme="dark"] input[type="checkbox"] ~ span {
  color: #E5E7EB;
}

/* ================================================
   Sidebar - Dark Theme Text Visibility
   ================================================ */

[data-theme="dark"] .sidebar-section-title {
  color: #9CA3AF;
}

[data-theme="dark"] .sidebar-link,
[data-theme="dark"] .nav-link {
  color: #D1D5DB;
}

[data-theme="dark"] .sidebar-link:hover,
[data-theme="dark"] .nav-link:hover {
  color: #F9FAFB;
  background: rgba(255, 255, 255, 0.1);
}

[data-theme="dark"] .sidebar-link.active,
[data-theme="dark"] .nav-link.active {
  color: #F9FAFB;
  background: rgba(59, 130, 246, 0.2);
}

/* ================================================
   Cards & Panels - Dark Theme
   ================================================ */

[data-theme="dark"] .card,
[data-theme="dark"] .panel,
[data-theme="dark"] .glass-card {
  background: var(--color-surface);
  border-color: var(--color-border);
  color: var(--color-surface-foreground);
}

[data-theme="dark"] .card-title,
[data-theme="dark"] .panel-title {
  color: #F9FAFB;
}

[data-theme="dark"] .card-subtitle,
[data-theme="dark"] .panel-subtitle,
[data-theme="dark"] .card-description {
  color: #9CA3AF;
}

/* ================================================
   Charts Container - Dark Theme
   ================================================ */

[data-theme="dark"] .chart-container {
  background: var(--color-surface);
}

[data-theme="dark"] .chart-title {
  color: #F3F4F6;
}

[data-theme="dark"] .chart-legend {
  color: #D1D5DB;
}

/* ================================================
   Tables - Dark Theme
   ================================================ */

[data-theme="dark"] table th {
  color: #F3F4F6;
  background: rgba(55, 65, 81, 0.5);
}

[data-theme="dark"] table td {
  color: #E5E7EB;
  border-color: var(--color-border);
}

[data-theme="dark"] table tr:hover {
  background: rgba(55, 65, 81, 0.3);
}

/* ================================================
   Right Panel / Widget Area - Dark Theme
   ================================================ */

[data-theme="dark"] .widget,
[data-theme="dark"] .right-panel,
[data-theme="dark"] .aside-panel {
  background: var(--color-surface);
  color: var(--color-surface-foreground);
}

[data-theme="dark"] .widget-title,
[data-theme="dark"] .widget-header h3,
[data-theme="dark"] .widget-header h4 {
  color: #F3F4F6;
}

[data-theme="dark"] .widget-content {
  color: #D1D5DB;
}

/* ================================================
   Badges - Dark Theme
   ================================================ */

[data-theme="dark"] .badge {
  color: #F3F4F6;
}

[data-theme="dark"] .badge-outline {
  border-color: var(--color-border);
  color: #D1D5DB;
}

[data-theme="dark"] .badge-success,
[data-theme="dark"] .badge-low {
  background: rgba(5, 150, 105, 0.3);
  color: #6EE7B7;
}

[data-theme="dark"] .badge-warning,
[data-theme="dark"] .badge-medium {
  background: rgba(217, 119, 6, 0.3);
  color: #FCD34D;
}

[data-theme="dark"] .badge-danger,
[data-theme="dark"] .badge-critical {
  background: rgba(220, 38, 38, 0.3);
  color: #FCA5A5;
}

[data-theme="dark"] .badge-info,
[data-theme="dark"] .badge-high {
  background: rgba(234, 88, 12, 0.3);
  color: #FDBA74;
}

/* ================================================
   Map Popup - Dark Theme
   ================================================ */

[data-theme="dark"] .leaflet-popup-content-wrapper {
  background: var(--color-surface);
  color: var(--color-surface-foreground);
}

[data-theme="dark"] .leaflet-popup-content {
  color: #E5E7EB;
}

[data-theme="dark"] .leaflet-popup-content strong {
  color: #F3F4F6;
}

[data-theme="dark"] .leaflet-popup-tip {
  background: var(--color-surface);
}

/* ================================================
   Form Elements - Dark Theme
   ================================================ */

[data-theme="dark"] input,
[data-theme="dark"] select,
[data-theme="dark"] textarea {
  background: var(--color-muted);
  color: #F3F4F6;
  border-color: var(--color-border);
}

[data-theme="dark"] input::placeholder,
[data-theme="dark"] textarea::placeholder {
  color: #6B7280;
}

[data-theme="dark"] input:focus,
[data-theme="dark"] select:focus,
[data-theme="dark"] textarea:focus {
  border-color: var(--color-primary);
  outline-color: var(--color-primary);
}

/* ================================================
   Buttons - Dark Theme
   ================================================ */

[data-theme="dark"] .btn-outline {
  color: #D1D5DB;
  border-color: var(--color-border);
}

[data-theme="dark"] .btn-outline:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #F3F4F6;
}

[data-theme="dark"] .btn-ghost {
  color: #D1D5DB;
}

[data-theme="dark"] .btn-ghost:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #F3F4F6;
}

/* ================================================
   Projecao / Prediction Panel - Dark Theme
   ================================================ */

[data-theme="dark"] .projection-text,
[data-theme="dark"] .prediction-label,
[data-theme="dark"] .forecast-text {
  color: #E5E7EB !important;
}

/* ================================================
   Alert Items - Dark Theme
   ================================================ */

[data-theme="dark"] .alert-item {
  background: var(--color-surface);
  border-color: var(--color-border);
}

[data-theme="dark"] .alert-title {
  color: #F3F4F6;
}

[data-theme="dark"] .alert-message {
  color: #D1D5DB;
}

[data-theme="dark"] .alert-meta {
  color: #9CA3AF;
}

/* ================================================
   Misc Text Elements - Dark Theme
   ================================================ */

[data-theme="dark"] .text-muted,
[data-theme="dark"] .text-secondary {
  color: #9CA3AF !important;
}

[data-theme="dark"] h1, [data-theme="dark"] h2,
[data-theme="dark"] h3, [data-theme="dark"] h4,
[data-theme="dark"] h5, [data-theme="dark"] h6 {
  color: var(--color-surface-foreground);
}

[data-theme="dark"] p {
  color: #D1D5DB;
}

[data-theme="dark"] label {
  color: #E5E7EB;
}

/* ================================================
   Scrollbar - Dark Theme
   ================================================ */

[data-theme="dark"] ::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

[data-theme="dark"] ::-webkit-scrollbar-track {
  background: var(--color-muted);
}

[data-theme="dark"] ::-webkit-scrollbar-thumb {
  background: #4B5563;
  border-radius: 4px;
}

[data-theme="dark"] ::-webkit-scrollbar-thumb:hover {
  background: #6B7280;
}

/* ================================================
   Pagination - Dark Theme
   ================================================ */

[data-theme="dark"] .pagination {
  color: #D1D5DB;
}

[data-theme="dark"] .pagination-btn {
  background: var(--color-muted);
  color: #E5E7EB;
  border-color: var(--color-border);
}

[data-theme="dark"] .pagination-btn:hover:not(:disabled) {
  background: rgba(59, 130, 246, 0.2);
  color: #F3F4F6;
}

[data-theme="dark"] .pagination-btn:disabled {
  color: #6B7280;
  opacity: 0.5;
}

[data-theme="dark"] .pagination-info {
  color: #9CA3AF;
}

/* ================================================
   CRITICAL TEXT FIXES - Dark Theme
   ================================================ */

/* KPI Card Text */
[data-theme="dark"] .kpi-card {
  background: #1F2937 !important;
  border-color: #374151 !important;
}

[data-theme="dark"] .kpi-card .kpi-value,
[data-theme="dark"] .kpi-value {
  color: #F9FAFB !important;
}

[data-theme="dark"] .kpi-card .kpi-label,
[data-theme="dark"] .kpi-card .kpi-title,
[data-theme="dark"] .kpi-label,
[data-theme="dark"] .kpi-title {
  color: #D1D5DB !important;
}

[data-theme="dark"] .kpi-card .kpi-subtitle,
[data-theme="dark"] .kpi-subtitle {
  color: #9CA3AF !important;
}

[data-theme="dark"] .kpi-card .kpi-trend,
[data-theme="dark"] .kpi-trend {
  color: #D1D5DB !important;
}

[data-theme="dark"] .kpi-card .kpi-footer,
[data-theme="dark"] .kpi-footer {
  color: #9CA3AF !important;
  border-color: #374151 !important;
}

/* Page Title & Header */
[data-theme="dark"] .page-title {
  color: #F9FAFB !important;
}

[data-theme="dark"] .page-subtitle {
  color: #9CA3AF !important;
}

/* Navigation Menu Items */
[data-theme="dark"] .nav-item {
  color: #D1D5DB !important;
}

[data-theme="dark"] .nav-item:hover {
  color: #F9FAFB !important;
}

[data-theme="dark"] .nav-item.active {
  color: #FFFFFF !important;
}

[data-theme="dark"] .nav-item span {
  color: inherit !important;
}

[data-theme="dark"] .nav-section-title {
  color: #6B7280 !important;
}

/* User Info */
[data-theme="dark"] .user-name {
  color: #F3F4F6 !important;
}

[data-theme="dark"] .user-role {
  color: #9CA3AF !important;
}

/* Quick Action Buttons */
[data-theme="dark"] .quick-action-btn {
  background: #1F2937 !important;
  color: #D1D5DB !important;
  border-color: #374151 !important;
}

[data-theme="dark"] .quick-action-btn:hover {
  background: #374151 !important;
  color: #F9FAFB !important;
}

/* Card Titles */
[data-theme="dark"] .card-header,
[data-theme="dark"] .card-title {
  color: #F3F4F6 !important;
}

[data-theme="dark"] .card-body {
  color: #D1D5DB !important;
}

/* Section Titles */
[data-theme="dark"] .section-title,
[data-theme="dark"] .section-header {
  color: #F3F4F6 !important;
}

/* Ranking Items */
[data-theme="dark"] .ranking-item {
  background: #1F2937 !important;
  border-color: #374151 !important;
}

[data-theme="dark"] .ranking-info h4,
[data-theme="dark"] .ranking-name {
  color: #F3F4F6 !important;
}

[data-theme="dark"] .ranking-info span,
[data-theme="dark"] .ranking-subtitle {
  color: #9CA3AF !important;
}

[data-theme="dark"] .ranking-value {
  color: #F9FAFB !important;
}

/* Timeline */
[data-theme="dark"] .timeline-item,
[data-theme="dark"] .alert-timeline-item {
  background: #1F2937 !important;
  border-color: #374151 !important;
}

[data-theme="dark"] .timeline-item h4,
[data-theme="dark"] .timeline-title {
  color: #F3F4F6 !important;
}

[data-theme="dark"] .timeline-item p,
[data-theme="dark"] .timeline-description {
  color: #D1D5DB !important;
}

[data-theme="dark"] .timeline-time,
[data-theme="dark"] .timeline-meta {
  color: #6B7280 !important;
}

/* Main Content Background */
[data-theme="dark"] .main-content,
[data-theme="dark"] .page-container {
  background: #111827 !important;
}

/* Header */
[data-theme="dark"] .header {
  background: #1F2937 !important;
  border-color: #374151 !important;
}

/* Search Box */
[data-theme="dark"] .search-box input,
[data-theme="dark"] .search-input {
  background: #374151 !important;
  color: #F3F4F6 !important;
  border-color: #4B5563 !important;
}

[data-theme="dark"] .search-box input::placeholder,
[data-theme="dark"] .search-input::placeholder {
  color: #6B7280 !important;
}

/* Filter Buttons */
[data-theme="dark"] .filter-btn,
[data-theme="dark"] .filter-select {
  background: #1F2937 !important;
  color: #D1D5DB !important;
  border-color: #374151 !important;
}

[data-theme="dark"] .filter-btn:hover,
[data-theme="dark"] .filter-btn.active {
  background: #374151 !important;
  color: #F9FAFB !important;
}

/* Stats/Metrics */
[data-theme="dark"] .stat-value,
[data-theme="dark"] .metric-value {
  color: #F9FAFB !important;
}

[data-theme="dark"] .stat-label,
[data-theme="dark"] .metric-label {
  color: #9CA3AF !important;
}

/* Links */
[data-theme="dark"] a:not(.btn):not(.nav-item) {
  color: #60A5FA;
}

[data-theme="dark"] a:not(.btn):not(.nav-item):hover {
  color: #93C5FD;
}

/* Tooltips */
[data-theme="dark"] [title],
[data-theme="dark"] .tooltip {
  color: #F3F4F6 !important;
}

/* Modal/Dialog */
[data-theme="dark"] .modal,
[data-theme="dark"] .dialog {
  background: #1F2937 !important;
  color: #F3F4F6 !important;
  border-color: #374151 !important;
}

[data-theme="dark"] .modal-header,
[data-theme="dark"] .dialog-header {
  color: #F9FAFB !important;
  border-color: #374151 !important;
}

[data-theme="dark"] .modal-body,
[data-theme="dark"] .dialog-body {
  color: #D1D5DB !important;
}

/* Empty States */
[data-theme="dark"] .empty-state,
[data-theme="dark"] .no-data {
  color: #6B7280 !important;
}

/* Dropdown Menus */
[data-theme="dark"] .dropdown-menu,
[data-theme="dark"] .select-menu {
  background: #1F2937 !important;
  border-color: #374151 !important;
}

[data-theme="dark"] .dropdown-item {
  color: #D1D5DB !important;
}

[data-theme="dark"] .dropdown-item:hover {
  background: #374151 !important;
  color: #F9FAFB !important;
}

/* Generic Text Fix - Force visible colors */
[data-theme="dark"] span:not([class*="badge"]):not([class*="icon"]),
[data-theme="dark"] div:not([class*="card"]):not([class*="panel"]):not([class*="sidebar"]):not([class*="header"]):not([class*="container"]) {
  color: inherit;
}
