/* Theme accessibility hardening: global light/dark readability and contrast */

:root {
    --theme-bg: #edf6ef;
    --theme-surface: #ffffff;
    --theme-surface-soft: #f7fcf8;
    --theme-text: #1d3a2b;
    --theme-text-muted: #4f6f5c;
    --theme-text-subtle: #6f8d7c;
    --theme-border: #d7ebde;
    --theme-primary: #149a4b;
    --theme-primary-strong: #117a3c;
    --theme-link: #0f766e;
    --theme-link-hover: #0a5a54;
    --theme-focus: rgba(20, 154, 75, 0.45);
    --theme-warning-text: #6b3f00;
    --theme-danger-text: #8d2020;
    --theme-shadow: 0 10px 24px rgba(15, 23, 42, 0.08);
}

[data-theme="dark"] {
    --theme-bg: #0f1713;
    --theme-surface: #17201a;
    --theme-surface-soft: #122018;
    --theme-text: #ecfdf3;
    --theme-text-muted: #cdeed7;
    --theme-text-subtle: #b8e6c9;
    --theme-border: rgba(74, 222, 128, 0.24);
    --theme-primary: #4ade80;
    --theme-primary-strong: #22c55e;
    --theme-link: #86efac;
    --theme-link-hover: #bbf7d0;
    --theme-focus: rgba(134, 239, 172, 0.48);
    --theme-warning-text: #facc72;
    --theme-danger-text: #fecaca;
    --theme-shadow: 0 14px 30px rgba(0, 0, 0, 0.45);
}

/* Base readability layer */
body,
main,
.card,
.table,
.dropdown-menu,
.modal-content,
.offcanvas,
.list-group-item {
    color: var(--theme-text);
}

.text-muted,
.small,
.form-text,
.table td,
.table tbody th,
.list-group-item small {
    color: var(--theme-text-muted) !important;
}

.text-dark,
.text-body,
.text-body-secondary,
.text-secondary,
.text-black {
    color: var(--theme-text) !important;
}

/* Links and focus visibility */
a:not(.btn):not(.nav-link):not(.navbar-brand):not(.dropdown-item):not(.page-link):not(.badge) {
    color: var(--theme-link);
}

a:not(.btn):not(.nav-link):not(.navbar-brand):not(.dropdown-item):not(.page-link):not(.badge):hover {
    color: var(--theme-link-hover);
}

:focus-visible {
    outline: 2px solid var(--theme-focus) !important;
    outline-offset: 2px;
}

/* Inputs/buttons/icons/tables */
.form-control,
.form-select,
textarea,
input,
select {
    color: var(--theme-text);
    border-color: var(--theme-border);
}

[data-theme="dark"] .form-control,
[data-theme="dark"] .form-select,
[data-theme="dark"] textarea,
[data-theme="dark"] input,
[data-theme="dark"] select {
    background: rgba(14, 27, 20, 0.92);
}

.btn,
.badge,
.alert,
.nav-link,
.dropdown-item,
.table th,
.table td,
i.bi,
svg {
    color: inherit;
}

.table thead th {
    color: var(--theme-text);
    border-bottom-color: var(--theme-border);
}

/* Status utility for mixed old/new templates */
.theme-status-success {
    background: #dcfce7;
    color: #166534;
}

.theme-status-warning {
    background: #fef3c7;
    color: var(--theme-warning-text);
}

.theme-status-danger {
    background: #fee2e2;
    color: #991b1b;
}

.theme-status-neutral {
    background: #e5e7eb;
    color: #374151;
}

[data-theme="dark"] .theme-status-success {
    background: rgba(16, 78, 46, 0.82);
    color: #d1fae5;
}

[data-theme="dark"] .theme-status-warning {
    background: rgba(120, 53, 15, 0.78);
    color: #fde68a;
}

[data-theme="dark"] .theme-status-danger {
    background: rgba(127, 29, 29, 0.78);
    color: #fecaca;
}

[data-theme="dark"] .theme-status-neutral {
    background: rgba(34, 49, 40, 0.9);
    color: #cdeed7;
}

/* Hardening for hardcoded inline text colors in legacy Blade */
[data-theme="dark"] [style*="color: white"],
[data-theme="dark"] [style*="color:white"],
[data-theme="dark"] [style*="color: #fff"],
[data-theme="dark"] [style*="color:#fff"],
[data-theme="dark"] [style*="color: #ffffff"],
[data-theme="dark"] [style*="color:#ffffff"],
[data-theme="dark"] [style*="color: #111827"],
[data-theme="dark"] [style*="color:#111827"],
[data-theme="dark"] [style*="color: #1f2937"],
[data-theme="dark"] [style*="color:#1f2937"],
[data-theme="dark"] [style*="color: #2d3748"],
[data-theme="dark"] [style*="color:#2d3748"],
[data-theme="dark"] [style*="color: #4a5568"],
[data-theme="dark"] [style*="color:#4a5568"],
[data-theme="dark"] [style*="color: #6b7280"],
[data-theme="dark"] [style*="color:#6b7280"],
[data-theme="dark"] [style*="color: #718096"],
[data-theme="dark"] [style*="color:#718096"],
[data-theme="dark"] [style*="color: #047857"],
[data-theme="dark"] [style*="color:#047857"],
[data-theme="dark"] [style*="color: #059669"],
[data-theme="dark"] [style*="color:#059669"],
[data-theme="dark"] [style*="color: #92400e"],
[data-theme="dark"] [style*="color:#92400e"],
[data-theme="dark"] [style*="color: #78350f"],
[data-theme="dark"] [style*="color:#78350f"],
[data-theme="dark"] [style*="color: #166534"],
[data-theme="dark"] [style*="color:#166534"],
[data-theme="dark"] [style*="color: #991b1b"],
[data-theme="dark"] [style*="color:#991b1b"],
[data-theme="dark"] [style*="color: #1a1d1f"],
[data-theme="dark"] [style*="color:#1a1d1f"],
[data-theme="dark"] [style*="color: #374151"],
[data-theme="dark"] [style*="color:#374151"],
[data-theme="dark"] [style*="color: #4b5563"],
[data-theme="dark"] [style*="color:#4b5563"],
[data-theme="dark"] [style*="color: #0f172a"],
[data-theme="dark"] [style*="color:#0f172a"],
[data-theme="dark"] [style*="color: #0d6f39"],
[data-theme="dark"] [style*="color:#0d6f39"],
[data-theme="dark"] [style*="color: #333333"],
[data-theme="dark"] [style*="color:#333333"],
[data-theme="dark"] [style*="color: #444444"],
[data-theme="dark"] [style*="color:#444444"],
[data-theme="dark"] [style*="color: #555555"],
[data-theme="dark"] [style*="color:#555555"],
[data-theme="dark"] [style*="color: #3d3d3d"],
[data-theme="dark"] [style*="color:#3d3d3d"],
[data-theme="dark"] [style*="color: #3b82f6"],
[data-theme="dark"] [style*="color:#3b82f6"] {
    color: var(--theme-text) !important;
}

/* ===== Dark theme: global text classes ===== */
/* Bootstrap text utilities */
[data-theme="dark"] .text-dark,
[data-theme="dark"] .text-black,
[data-theme="dark"] .text-body,
[data-theme="dark"] .text-body-secondary,
[data-theme="dark"] .text-secondary {
    color: var(--theme-text-muted) !important;
}

/* Global element readability in dark mode */
[data-theme="dark"] p:not([class*="bg-"]),
[data-theme="dark"] li,
[data-theme="dark"] label,
[data-theme="dark"] small,
[data-theme="dark"] caption {
    color: inherit;
}

/* ===== Dark theme: specific class overrides ===== */
/* Organizer/admin badge-modern */
[data-theme="dark"] .badge-modern {
    background: rgba(74, 222, 128, 0.15) !important;
    color: #86efac !important;
}

/* Participants page */
[data-theme="dark"] .participants-subtitle,
[data-theme="dark"] .participants-title {
    color: var(--theme-text) !important;
}

/* Help page CTA button — dark text on light bg */
[data-theme="dark"] .help-cta-button {
    color: #0f172a !important;
}

/* Breadcrumbs */
[data-theme="dark"] .breadcrumb:not(.breadcrumb-nav) {
    color: var(--theme-text-muted) !important;
}

/* Empty states */
[data-theme="dark"] .empty-state,
[data-theme="dark"] .empty-state-revised {
    color: var(--theme-text-muted) !important;
}

/* Sidebar cards */
[data-theme="dark"] .sidebar-card {
    background: rgba(14, 27, 20, 0.92) !important;
    border-color: rgba(74, 222, 128, 0.22) !important;
    color: var(--theme-text) !important;
}

/* races/show hardcoded colors */
[data-theme="dark"] .race-description-content,
[data-theme="dark"] .category-description {
    color: var(--theme-text-muted) !important;
}

[data-theme="dark"] .category-meta-label {
    color: var(--theme-text-muted) !important;
}

[data-theme="dark"] .category-meta-value {
    color: var(--theme-text) !important;
}

[data-theme="dark"] .category-current-price-label {
    color: #86efac !important;
}

[data-theme="dark"] .category-current-price-rsd {
    color: #4ade80 !important;
}

[data-theme="dark"] .category-current-price-rsd-currency,
[data-theme="dark"] .category-current-price-eur-label {
    color: var(--theme-text-muted) !important;
}

[data-theme="dark"] .category-current-price-eur-value {
    color: var(--theme-text) !important;
}

/* Hardening for hardcoded light backgrounds in legacy Blade */
/* Light gradient backgrounds — price cards, info cards */
[data-theme="dark"] [style*="background: linear-gradient(135deg, #ecfdf5"],
[data-theme="dark"] [style*="background: linear-gradient(135deg, #d1fae5"],
[data-theme="dark"] [style*="background: linear-gradient(135deg, #fef3c7"],
[data-theme="dark"] [style*="background: linear-gradient(135deg, #fde68a"],
[data-theme="dark"] [style*="background: linear-gradient(135deg, #eff6ff"],
[data-theme="dark"] [style*="background: linear-gradient(135deg, #f0fdf4"],
[data-theme="dark"] [style*="background: linear-gradient(135deg, #f8f9fa"],
[data-theme="dark"] [style*="background: linear-gradient(135deg, #edf6ef"],
[data-theme="dark"] [style*="background: linear-gradient(135deg, #e4f4e9"] {
    background: rgba(14, 27, 20, 0.92) !important;
    border-color: rgba(74, 222, 128, 0.28) !important;
}
[data-theme="dark"] [style*="background: #fff"],
[data-theme="dark"] [style*="background:#fff"],
[data-theme="dark"] [style*="background: #ffffff"],
[data-theme="dark"] [style*="background:#ffffff"],
[data-theme="dark"] [style*="background: #f8f9fa"],
[data-theme="dark"] [style*="background:#f8f9fa"],
[data-theme="dark"] [style*="background: #f9fafb"],
[data-theme="dark"] [style*="background:#f9fafb"],
[data-theme="dark"] [style*="background: #ecfdf5"],
[data-theme="dark"] [style*="background:#ecfdf5"],
[data-theme="dark"] [style*="background: #d1fae5"],
[data-theme="dark"] [style*="background:#d1fae5"],
[data-theme="dark"] [style*="background: #fef3c7"],
[data-theme="dark"] [style*="background:#fef3c7"],
[data-theme="dark"] [style*="background: #fde68a"],
[data-theme="dark"] [style*="background:#fde68a"],
[data-theme="dark"] [style*="background: rgba(255,255,255"],
[data-theme="dark"] [style*="background: rgba(255, 255, 255"] {
    background: var(--theme-surface) !important;
    border-color: var(--theme-border) !important;
}

[data-theme="dark"] [style*="border: 2px solid #10b981"],
[data-theme="dark"] [style*="border:2px solid #10b981"],
[data-theme="dark"] [style*="border: 2px solid #f59e0b"],
[data-theme="dark"] [style*="border:2px solid #f59e0b"],
[data-theme="dark"] [style*="border: 1px solid rgba(16, 185, 129"],
[data-theme="dark"] [style*="border: 1px solid rgba(34, 166, 90"],
[data-theme="dark"] [style*="border: 1px solid rgba(239, 68, 68"],
[data-theme="dark"] [style*="border: 1px solid rgba(107, 114, 128"] {
    border-color: var(--theme-border) !important;
}

/* Keep dark-mode warning/info badges readable */
[data-theme="dark"] .badge.bg-warning,
[data-theme="dark"] .badge.bg-warning.text-dark,
[data-theme="dark"] .badge.bg-light,
[data-theme="dark"] .badge.bg-light.text-dark,
[data-theme="dark"] .bg-warning.text-dark,
[data-theme="dark"] .bg-light.text-dark {
    color: #102013 !important;
    font-weight: 700;
}

/* Avoid harsh black for readability */
[data-theme="dark"] [style*="background: #000"],
[data-theme="dark"] [style*="background:#000"],
[data-theme="dark"] [style*="background: #0f172a"],
[data-theme="dark"] [style*="background:#0f172a"] {
    background: #16221b !important;
}
