/*
 * Global dark-mode readability overrides for legacy views.
 * Keep these selectors scoped to dark mode only so light mode remains unchanged.
 */
html.dark,
[data-bs-theme="dark"] {
  color-scheme: dark;
}

html.dark body,
[data-bs-theme="dark"] body {
  --dark-text-primary: #e6edf3;
  --dark-text-secondary: #b6c2d1;
  --dark-text-link: #8ec5ff;
  --dark-border: #334155;
}

html.dark body,
html.dark .content,
html.dark .card,
html.dark .modal-content,
html.dark .offcanvas,
html.dark .dropdown-menu,
html.dark .popover,
html.dark .tooltip-inner,
[data-bs-theme="dark"] body,
[data-bs-theme="dark"] .content,
[data-bs-theme="dark"] .card,
[data-bs-theme="dark"] .modal-content,
[data-bs-theme="dark"] .offcanvas,
[data-bs-theme="dark"] .dropdown-menu,
[data-bs-theme="dark"] .popover,
[data-bs-theme="dark"] .tooltip-inner {
  color: var(--dark-text-primary);
}

html.dark .table,
html.dark .table > :not(caption) > * > *,
[data-bs-theme="dark"] .table,
[data-bs-theme="dark"] .table > :not(caption) > * > * {
  color: var(--dark-text-primary);
  border-color: var(--dark-border);
}

html.dark .text-dark,
html.dark .text-black,
html.dark .text-body,
[data-bs-theme="dark"] .text-dark,
[data-bs-theme="dark"] .text-black,
[data-bs-theme="dark"] .text-body {
  color: var(--dark-text-primary) !important;
}

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

html.dark a:not(.btn),
[data-bs-theme="dark"] a:not(.btn) {
  color: var(--dark-text-link);
}

html.dark .form-control,
html.dark .form-select,
html.dark .form-check-input,
[data-bs-theme="dark"] .form-control,
[data-bs-theme="dark"] .form-select,
[data-bs-theme="dark"] .form-check-input {
  color: var(--dark-text-primary);
  border-color: var(--dark-border);
}

html.dark .form-control::placeholder,
html.dark .form-select::placeholder,
[data-bs-theme="dark"] .form-control::placeholder,
[data-bs-theme="dark"] .form-select::placeholder {
  color: var(--dark-text-secondary);
  opacity: 1;
}

html.dark .input-group-text,
html.dark .list-group-item,
html.dark .nav-link,
[data-bs-theme="dark"] .input-group-text,
[data-bs-theme="dark"] .list-group-item,
[data-bs-theme="dark"] .nav-link {
  color: var(--dark-text-primary);
  border-color: var(--dark-border);
}

html.dark hr,
[data-bs-theme="dark"] hr {
  border-color: var(--dark-border);
  opacity: 1;
}

/* Legacy <font color="..."> tags that still exist in multiple views. */
html.dark font[color="black"],
html.dark font[color="#000"],
html.dark font[color="#000000"],
[data-bs-theme="dark"] font[color="black"],
[data-bs-theme="dark"] font[color="#000"],
[data-bs-theme="dark"] font[color="#000000"] {
  color: var(--dark-text-primary) !important;
}

html.dark font[color="grey"],
html.dark font[color="gray"],
[data-bs-theme="dark"] font[color="grey"],
[data-bs-theme="dark"] font[color="gray"] {
  color: var(--dark-text-secondary) !important;
}

html.dark font[color="blue"],
html.dark font[color="purple"],
[data-bs-theme="dark"] font[color="blue"],
[data-bs-theme="dark"] font[color="purple"] {
  color: var(--dark-text-link) !important;
}

/* Ensure global loading page follows dark mode theme. */
html.dark .initial-loader,
[data-bs-theme="dark"] .initial-loader {
  background: linear-gradient(135deg, #0f172a 0%, #111827 100%) !important;
}

html.dark .initial-loader .spinner,
[data-bs-theme="dark"] .initial-loader .spinner {
  border-color: rgba(148, 163, 184, 0.25) !important;
  border-top-color: #93c5fd !important;
}

html.dark .initial-loader .loader-text h4,
[data-bs-theme="dark"] .initial-loader .loader-text h4 {
  color: #e2e8f0 !important;
}

html.dark .initial-loader .loader-text p,
[data-bs-theme="dark"] .initial-loader .loader-text p {
  color: #94a3b8 !important;
}

html.dark .initial-loader .loader-percentage,
[data-bs-theme="dark"] .initial-loader .loader-percentage {
  color: #dbeafe !important;
  text-shadow: none !important;
}

html.dark .initial-loader .loader-progress-track,
[data-bs-theme="dark"] .initial-loader .loader-progress-track {
  background: rgba(148, 163, 184, 0.2) !important;
}

html.dark .initial-loader .loader-progress-fill,
[data-bs-theme="dark"] .initial-loader .loader-progress-fill {
  background: linear-gradient(90deg, #3b82f6 0%, #38bdf8 50%, #7dd3fc 100%) !important;
}

html.dark .initial-loader .loader-container,
[data-bs-theme="dark"] .initial-loader .loader-container {
  background: linear-gradient(165deg, rgba(15, 23, 42, 0.9), rgba(15, 23, 42, 0.74)) !important;
  border-color: rgba(148, 163, 184, 0.3) !important;
  box-shadow: 0 24px 54px rgba(2, 8, 23, 0.55) !important;
}

/* Animated text and accent lines: force readable contrast in dark mode. */
html.dark .welcome-title,
html.dark .welcome-desc,
html.dark .subtitle,
html.dark .page-subtitle,
html.dark .form-label,
html.dark .forgot-link,
html.dark .check-btn,
html.dark .menu-button,
html.dark .dashboard-link,
html.dark .notification,
[data-bs-theme="dark"] .welcome-title,
[data-bs-theme="dark"] .welcome-desc,
[data-bs-theme="dark"] .subtitle,
[data-bs-theme="dark"] .page-subtitle,
[data-bs-theme="dark"] .form-label,
[data-bs-theme="dark"] .forgot-link,
[data-bs-theme="dark"] .check-btn,
[data-bs-theme="dark"] .menu-button,
[data-bs-theme="dark"] .dashboard-link,
[data-bs-theme="dark"] .notification {
  color: #e2e8f0 !important;
}

html.dark .subtitle,
[data-bs-theme="dark"] .subtitle {
  color: #fca5a5 !important;
  text-shadow: 0 0 8px rgba(252, 165, 165, 0.25) !important;
}

html.dark .welcome-title::after,
[data-bs-theme="dark"] .welcome-title::after {
  background: linear-gradient(90deg, #60a5fa, #7dd3fc) !important;
}

html.dark .welcome-desc::after,
[data-bs-theme="dark"] .welcome-desc::after,
html.dark .divider,
[data-bs-theme="dark"] .divider {
  background: linear-gradient(90deg, transparent, rgba(125, 211, 252, 0.8), transparent) !important;
}

html.dark .divider-circle,
[data-bs-theme="dark"] .divider-circle {
  background: linear-gradient(135deg, #2563eb 0%, #38bdf8 100%) !important;
  box-shadow: 0 0 10px rgba(56, 189, 248, 0.32) !important;
}

html.dark .dashboard-link::after,
[data-bs-theme="dark"] .dashboard-link::after {
  background: #7dd3fc !important;
}

html.dark .form-icon,
html.dark .password-toggle,
[data-bs-theme="dark"] .form-icon,
[data-bs-theme="dark"] .password-toggle {
  color: #cbd5e1 !important;
}

html.dark .form-icon-container.focused .form-icon,
html.dark .password-toggle:hover,
[data-bs-theme="dark"] .form-icon-container.focused .form-icon,
[data-bs-theme="dark"] .password-toggle:hover {
  color: #93c5fd !important;
}

html.dark .check-btn,
[data-bs-theme="dark"] .check-btn {
  border-color: #60a5fa !important;
  color: #bfdbfe !important;
}

html.dark .check-btn:hover,
[data-bs-theme="dark"] .check-btn:hover {
  border-color: transparent !important;
  color: #f8fafc !important;
}

html.dark .notification,
[data-bs-theme="dark"] .notification {
  background-color: #0f172a !important;
  border: 1px solid #334155 !important;
  box-shadow: 0 10px 24px rgba(2, 8, 23, 0.55) !important;
}

html.dark .notification.success,
[data-bs-theme="dark"] .notification.success {
  border-left: 4px solid #22c55e !important;
}

html.dark .notification.error,
[data-bs-theme="dark"] .notification.error {
  border-left: 4px solid #ef4444 !important;
}

html.dark .notification.info,
[data-bs-theme="dark"] .notification.info {
  border-left: 4px solid #38bdf8 !important;
}
