/*
 * Dark-mode (html[data-theme="dark"]) overrides for the application shell and
 * dashboard/chat components. Extracted 2026-08-29 from an inline <style> block in
 * application.html.erb. Kept last in the import order (see application.css) since
 * these rules rely on !important and were originally the last styles loaded.
 */
      /* Dropdown Fixes */
      html[data-theme="dark"],
      html[data-theme="dark"] body {
        background: var(--kv-bg-dark) !important;
        color: #e2e8f0 !important;
      }

      html[data-theme="dark"] .main-content {
        background: var(--kv-bg-dark-elevated) !important;
        color: #e2e8f0 !important;
      }

      html[data-theme="dark"] .top-header,
      html[data-theme="dark"] .content-area,
      html[data-theme="dark"] .card,
      html[data-theme="dark"] .content-panel,
      html[data-theme="dark"] .hero-panel,
      html[data-theme="dark"] .insight-panel,
      html[data-theme="dark"] .filter-panel,
      html[data-theme="dark"] .dashboard-card,
      html[data-theme="dark"] .widget-card,
      html[data-theme="dark"] .widget-group-card,
      html[data-theme="dark"] .modal-content,
      html[data-theme="dark"] .dropdown-menu {
        background: var(--kv-surface-dark) !important;
        color: var(--kv-text-dark) !important;
        border-color: var(--kv-border-dark) !important;
      }

      html[data-theme="dark"] h1,
      html[data-theme="dark"] h2,
      html[data-theme="dark"] h3,
      html[data-theme="dark"] h4,
      html[data-theme="dark"] h5,
      html[data-theme="dark"] h6,
      html[data-theme="dark"] .hero-title,
      html[data-theme="dark"] .section-title,
      html[data-theme="dark"] .panel-title,
      html[data-theme="dark"] .dashboard-name,
      html[data-theme="dark"] .widget-card-name {
        color: var(--kv-text-dark-strong) !important;
      }

      html[data-theme="dark"] .text-muted,
      html[data-theme="dark"] .hero-copy,
      html[data-theme="dark"] .hero-stat-meta,
      html[data-theme="dark"] .dashboard-meta,
      html[data-theme="dark"] .widget-library-note,
      html[data-theme="dark"] .empty-copy {
        color: var(--kv-text-dark-muted) !important;
      }

      html[data-theme="dark"] .form-control,
      html[data-theme="dark"] .form-select,
      html[data-theme="dark"] input,
      html[data-theme="dark"] textarea,
      html[data-theme="dark"] select {
        background: var(--kv-bg-dark-elevated) !important;
        color: var(--kv-text-dark) !important;
        border-color: #4b5563 !important;
      }

      html[data-theme="dark"] .table,
      html[data-theme="dark"] table {
        color: var(--kv-text-dark) !important;
      }

      html[data-theme="dark"] .dropdown-item {
        color: var(--kv-text-dark) !important;
      }

      html[data-theme="dark"] .dropdown-item:hover {
        background-color: var(--kv-border-dark) !important;
      }

      html[data-theme="dark"] .btn-outline-secondary {
        color: #e2e8f0 !important;
        border-color: #64748b !important;
      }

      html[data-theme="dark"] .dashboards-page {
        background: linear-gradient(180deg, rgba(20, 184, 166, 0.10), rgba(15, 23, 42, 0) 340px), var(--kv-bg-dark) !important;
        color: var(--kv-text-dark) !important;
      }

      html[data-theme="dark"] .dashboard-hero,
      html[data-theme="dark"] .hero-panel,
      html[data-theme="dark"] .insight-panel,
      html[data-theme="dark"] .filter-panel,
      html[data-theme="dark"] .content-panel,
      html[data-theme="dark"] .dashboard-card,
      html[data-theme="dark"] .widget-group-card,
      html[data-theme="dark"] .widget-card,
      html[data-theme="dark"] .hero-stat-card,
      html[data-theme="dark"] .empty-state,
      html[data-theme="dark"] .widget-library-note,
      html[data-theme="dark"] .insight-item {
        background: var(--kv-surface-dark-alt) !important;
        border-color: var(--kv-border-dark-alt) !important;
        color: var(--kv-text-dark) !important;
        box-shadow: 0 18px 42px rgba(0, 0, 0, 0.28) !important;
      }

      html[data-theme="dark"] .hero-panel {
        background: linear-gradient(135deg, rgba(20, 184, 166, 0.18), rgba(59, 130, 246, 0.10)), var(--kv-surface-dark-alt) !important;
      }

      html[data-theme="dark"] .hero-stat-value,
      html[data-theme="dark"] .insight-value,
      html[data-theme="dark"] .dashboard-facts,
      html[data-theme="dark"] .widget-group-title,
      html[data-theme="dark"] .empty-title,
      html[data-theme="dark"] .widget-card-name,
      html[data-theme="dark"] .dashboard-name {
        color: var(--kv-text-dark-strong) !important;
      }

      html[data-theme="dark"] .hero-stat-label,
      html[data-theme="dark"] .section-kicker,
      html[data-theme="dark"] .hero-kicker,
      html[data-theme="dark"] .panel-kicker,
      html[data-theme="dark"] .filter-label {
        color: var(--kv-accent-dark-soft) !important;
      }

      html[data-theme="dark"] .hero-stat-meta,
      html[data-theme="dark"] .insight-label,
      html[data-theme="dark"] .dashboard-meta,
      html[data-theme="dark"] .widget-group-subtitle,
      html[data-theme="dark"] .widget-card-key,
      html[data-theme="dark"] .empty-copy,
      html[data-theme="dark"] .hero-copy {
        color: #cbd5e1 !important;
      }

      html[data-theme="dark"] .type-pill,
      html[data-theme="dark"] .widget-type-chip,
      html[data-theme="dark"] .widget-category-pill,
      html[data-theme="dark"] .section-badge,
      html[data-theme="dark"] .status-pill {
        background: #243244 !important;
        border-color: #475569 !important;
        color: #e2e8f0 !important;
      }

      html[data-theme="dark"] .type-pill.active,
      html[data-theme="dark"] .widget-type-chip.active {
        background: #134e4a !important;
        border-color: var(--kv-accent-dark) !important;
        color: #ccfbf1 !important;
      }

      html[data-theme="dark"] .status-pill.success {
        background: #14532d !important;
        color: #bbf7d0 !important;
      }

      html[data-theme="dark"] .status-pill.info {
        background: #1e3a8a !important;
        color: #bfdbfe !important;
      }

      html[data-theme="dark"] .status-pill.muted {
        background: var(--kv-border-dark-alt) !important;
        color: #e2e8f0 !important;
      }

      html[data-theme="dark"] .action-btn-light,
      html[data-theme="dark"] .btn-outline-primary,
      html[data-theme="dark"] .btn-outline-secondary {
        background: var(--kv-bg-dark-elevated) !important;
        border-color: #475569 !important;
        color: var(--kv-text-dark) !important;
      }

      html[data-theme="dark"] .action-btn-danger {
        background: #450a0a !important;
        border-color: #991b1b !important;
        color: #fecaca !important;
      }

      html[data-theme="dark"] .chat-window,
      html[data-theme="dark"] .chat-footer,
      html[data-theme="dark"] .chat-message-assistant .message-bubble,
      html[data-theme="dark"] .quick-actions,
      html[data-theme="dark"] .soc-result-card,
      html[data-theme="dark"] .soc-result-meta {
        background: var(--kv-surface-dark-alt) !important;
        border-color: var(--kv-border-dark-alt) !important;
        color: var(--kv-text-dark) !important;
      }

      html[data-theme="dark"] .chat-body {
        background: var(--kv-bg-dark) !important;
      }

      html[data-theme="dark"] .soc-result-label,
      html[data-theme="dark"] .quick-actions small,
      html[data-theme="dark"] .chat-footer-text small {
        color: #cbd5e1 !important;
      }

      html[data-theme="dark"] .soc-result-value,
      html[data-theme="dark"] .soc-result-card-header {
        color: var(--kv-text-dark-strong) !important;
      }

      html[data-theme="dark"] {
        color-scheme: dark;
      }

      html[data-theme="dark"] .top-header {
        background: rgba(15, 23, 42, 0.96) !important;
        border-bottom: 1px solid #263244 !important;
        box-shadow: 0 10px 28px rgba(0, 0, 0, 0.22) !important;
      }

      html[data-theme="dark"] .top-header h1,
      html[data-theme="dark"] .top-header h2,
      html[data-theme="dark"] .top-header h3,
      html[data-theme="dark"] .top-header h4,
      html[data-theme="dark"] .top-header h5,
      html[data-theme="dark"] .top-header h6,
      html[data-theme="dark"] .top-header label,
      html[data-theme="dark"] .top-header .btn-link,
      html[data-theme="dark"] .top-header .dropdown-toggle {
        color: var(--kv-text-dark-strong) !important;
      }

      html[data-theme="dark"] #theme-switcher {
        background: #1e293b !important;
        border-color: #475569 !important;
        color: #facc15 !important;
        box-shadow: inset 0 0 0 1px rgba(250, 204, 21, 0.14), 0 8px 18px rgba(0, 0, 0, 0.18) !important;
      }

      html[data-theme="dark"] #theme-switcher:hover {
        background: #263449 !important;
        color: #fde68a !important;
      }

      html[data-theme="dark"] .dashboards-page .dashboard-hero,
      html[data-theme="dark"] .dashboards-page .hero-panel,
      html[data-theme="dark"] .dashboards-page .insight-panel,
      html[data-theme="dark"] .dashboards-page .filter-panel,
      html[data-theme="dark"] .dashboards-page .content-panel,
      html[data-theme="dark"] .dashboards-page .dashboard-card,
      html[data-theme="dark"] .dashboards-page .widget-group-card,
      html[data-theme="dark"] .dashboards-page .widget-card,
      html[data-theme="dark"] .dashboards-page .hero-stat-card,
      html[data-theme="dark"] .dashboards-page .empty-state,
      html[data-theme="dark"] .dashboards-page .widget-library-note,
      html[data-theme="dark"] .dashboards-page .insight-item {
        background: #151f32 !important;
        border-color: var(--kv-border-dark-alt) !important;
        color: var(--kv-text-dark) !important;
      }

      html[data-theme="dark"] .dashboards-page .hero-panel {
        background: linear-gradient(135deg, rgba(20, 184, 166, 0.18), rgba(56, 189, 248, 0.10)), #151f32 !important;
      }

      html[data-theme="dark"] .dashboards-page .hero-title,
      html[data-theme="dark"] .dashboards-page .hero-stat-value,
      html[data-theme="dark"] .dashboards-page .panel-title,
      html[data-theme="dark"] .dashboards-page .section-title,
      html[data-theme="dark"] .dashboards-page .dashboard-name,
      html[data-theme="dark"] .dashboards-page .dashboard-facts,
      html[data-theme="dark"] .dashboards-page .dashboard-facts strong,
      html[data-theme="dark"] .dashboards-page .insight-value,
      html[data-theme="dark"] .dashboards-page .widget-group-title,
      html[data-theme="dark"] .dashboards-page .widget-card-name,
      html[data-theme="dark"] .dashboards-page .empty-title {
        color: var(--kv-text-dark-strong) !important;
      }

      html[data-theme="dark"] .dashboards-page .hero-copy,
      html[data-theme="dark"] .dashboards-page .hero-stat-meta,
      html[data-theme="dark"] .dashboards-page .dashboard-meta,
      html[data-theme="dark"] .dashboards-page .insight-label,
      html[data-theme="dark"] .dashboards-page .widget-library-note,
      html[data-theme="dark"] .dashboards-page .widget-group-subtitle,
      html[data-theme="dark"] .dashboards-page .widget-card-key,
      html[data-theme="dark"] .dashboards-page .empty-copy {
        color: #cbd5e1 !important;
      }

      html[data-theme="dark"] .dashboards-page .section-header {
        border-bottom-color: var(--kv-border-dark-alt) !important;
      }

      html[data-theme="dark"] .dashboards-page .dashboard-icon-wrap,
      html[data-theme="dark"] .dashboards-page .empty-icon {
        background: #1e3a5f !important;
        color: #93c5fd !important;
      }

      html[data-theme="dark"] .dashboards-page .type-pill,
      html[data-theme="dark"] .dashboards-page .widget-type-chip,
      html[data-theme="dark"] .dashboards-page .widget-category-pill,
      html[data-theme="dark"] .dashboards-page .section-badge,
      html[data-theme="dark"] .dashboards-page .status-pill {
        background: #202c3f !important;
        border-color: #475569 !important;
        color: #e2e8f0 !important;
      }

      html[data-theme="dark"] .dashboards-page .type-pill.active,
      html[data-theme="dark"] .dashboards-page .widget-type-chip.active {
        background: #115e59 !important;
        border-color: var(--kv-accent-dark) !important;
        color: #ecfeff !important;
      }

      html[data-theme="dark"] .dashboards-page .section-badge.accent,
      html[data-theme="dark"] .dashboards-page .widget-category-pill {
        background: #312e81 !important;
        border-color: #4f46e5 !important;
        color: #ddd6fe !important;
      }

      html[data-theme="dark"] .dashboards-page .status-pill.success {
        background: #14532d !important;
        color: #bbf7d0 !important;
      }

      html[data-theme="dark"] .dashboards-page .status-pill.info {
        background: #1e3a8a !important;
        color: #bfdbfe !important;
      }

      html[data-theme="dark"] .dashboards-page .status-pill.muted {
        background: var(--kv-border-dark-alt) !important;
        color: #e2e8f0 !important;
      }

      html[data-theme="dark"] .table-striped > tbody > tr:nth-of-type(odd) > *,
      html[data-theme="dark"] .list-group-item {
        background-color: var(--kv-surface-dark-alt) !important;
        color: var(--kv-text-dark) !important;
        border-color: var(--kv-border-dark-alt) !important;
      }

      html[data-theme="dark"] body > .floating-chat-widget .chat-window,
      html[data-theme="dark"] body > .floating-chat-widget .chat-footer,
      html[data-theme="dark"] body > .floating-chat-widget .chat-message-assistant .message-bubble,
      html[data-theme="dark"] body > .floating-chat-widget .quick-actions,
      html[data-theme="dark"] body > .floating-chat-widget .soc-result-card,
      html[data-theme="dark"] body > .floating-chat-widget .soc-result-meta {
        background: #151f32 !important;
        border-color: var(--kv-border-dark-alt) !important;
        color: var(--kv-text-dark) !important;
      }

      html[data-theme="dark"] body > .floating-chat-widget .chat-body {
        background: var(--kv-bg-dark) !important;
      }

      html[data-theme="dark"] body > .floating-chat-widget .chat-input {
        background: var(--kv-bg-dark) !important;
        border-color: #475569 !important;
        color: var(--kv-text-dark-strong) !important;
      }

      html[data-theme="dark"] body > .floating-chat-widget .chat-input::placeholder {
        color: var(--kv-text-dark-muted) !important;
      }

      html[data-theme="dark"] body > .floating-chat-widget .quick-action-btn,
      html[data-theme="dark"] body > .floating-chat-widget .soc-show-more-btn {
        background: #1e293b !important;
        border-color: #475569 !important;
        color: #dbeafe !important;
      }

      html[data-theme="dark"] body > .floating-chat-widget .quick-action-btn:hover,
      html[data-theme="dark"] body > .floating-chat-widget .soc-show-more-btn:hover {
        background: #263449 !important;
        border-color: #60a5fa !important;
        color: #ffffff !important;
      }

      html[data-theme="dark"] body > .floating-chat-widget .soc-result-label,
      html[data-theme="dark"] body > .floating-chat-widget .quick-actions small,
      html[data-theme="dark"] body > .floating-chat-widget .message-time,
      html[data-theme="dark"] body > .floating-chat-widget .chat-footer-text small {
        color: #cbd5e1 !important;
      }

      html[data-theme="dark"] body > .floating-chat-widget .soc-result-value,
      html[data-theme="dark"] body > .floating-chat-widget .soc-result-card-header,
      html[data-theme="dark"] body > .floating-chat-widget .message-bubble strong {
        color: var(--kv-text-dark-strong) !important;
      }

      .dropdown-menu { 
        z-index: 2000 !important;
        box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
        border: 1px solid rgba(0, 0, 0, 0.15);
      }
      
      .dropdown-toggle {
        text-decoration: none !important;
      }
      
      .dropdown-toggle:hover {
        background-color: rgba(0, 0, 0, 0.05);
      }
      
      .dropdown-toggle:focus {
        box-shadow: 0 0 0 0.25rem rgba(13, 110, 253, 0.25);
      }
      
      .dropdown-item:hover {
        background-color: #f8f9fa;
      }
      
      /* Ensure dropdowns work over fixed elements */
      .top-header .dropdown {
        position: relative;
        z-index: 1050;
      }
      
      /* Debug helper - remove in production */
      .dropdown[data-bs-toggle="dropdown"]:not([aria-expanded]) {
        border: 1px dashed rgba(255, 0, 0, 0.3);
      }
