/* ===== GUARDIAN POSSE THEME READABILITY SAFETY NET ===== */
/* Universal text contrast and readability rules that work across ALL themes */
/* This file ensures no text becomes invisible regardless of theme choice */

/* ===== DARK MODE (DEFAULT) READABILITY ===== */
/* Ensure dark-mode text is always light enough on dark backgrounds */

[data-guardian-theme="dark"] body,
[data-guardian-theme="dark"] {
    color-scheme: dark;
}

[data-guardian-theme="dark"] .card-body,
[data-guardian-theme="dark"] .card-text,
[data-guardian-theme="dark"] .card p,
[data-guardian-theme="dark"] .card li,
[data-guardian-theme="dark"] .card td {
    color: #E8DCC8;
}

[data-guardian-theme="dark"] h4,
[data-guardian-theme="dark"] h5,
[data-guardian-theme="dark"] h6 {
    color: #E8DCC8;
}

[data-guardian-theme="dark"] .form-label {
    color: #E8DCC8;
}

[data-guardian-theme="dark"] .text-muted {
    color: #C8B89F !important;
}

[data-guardian-theme="dark"] .table {
    color: #E8DCC8;
}

[data-guardian-theme="dark"] .table td,
[data-guardian-theme="dark"] .table th {
    border-color: rgba(93, 64, 55, 0.4);
}

[data-guardian-theme="dark"] .list-group-item {
    background-color: rgba(45, 35, 24, 0.6);
    border-color: rgba(93, 64, 55, 0.3);
    color: #E8DCC8;
}

[data-guardian-theme="dark"] .modal-body {
    color: #E8DCC8;
}

[data-guardian-theme="dark"] .modal-body p,
[data-guardian-theme="dark"] .modal-body li,
[data-guardian-theme="dark"] .modal-body label {
    color: #E8DCC8;
}

[data-guardian-theme="dark"] .dropdown-menu {
    background-color: #241b14;
    border-color: rgba(93, 64, 55, 0.4);
}

[data-guardian-theme="dark"] .dropdown-item {
    color: #E8DCC8;
}

[data-guardian-theme="dark"] .dropdown-item:hover {
    background-color: rgba(255, 167, 38, 0.15);
    color: #ffa726;
}

[data-guardian-theme="dark"] .form-control,
[data-guardian-theme="dark"] .form-select,
[data-guardian-theme="dark"] textarea,
[data-guardian-theme="dark"] input:not([type="checkbox"]):not([type="radio"]):not([type="submit"]):not(.btn) {
    background-color: rgba(45, 35, 24, 0.8);
    border-color: rgba(93, 64, 55, 0.5);
    color: #E8DCC8;
}

[data-guardian-theme="dark"] .form-control::placeholder,
[data-guardian-theme="dark"] .form-select::placeholder,
[data-guardian-theme="dark"] textarea::placeholder,
[data-guardian-theme="dark"] input::placeholder {
    color: rgba(200, 184, 159, 0.5);
}

[data-guardian-theme="dark"] .form-control:focus,
[data-guardian-theme="dark"] .form-select:focus {
    border-color: #ffa726;
    box-shadow: 0 0 0 0.2rem rgba(255, 167, 38, 0.15);
}

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

[data-guardian-theme="dark"] .alert-info {
    background: rgba(26, 77, 122, 0.3);
    border-color: rgba(26, 77, 122, 0.5);
}

[data-guardian-theme="dark"] .alert-success {
    background: rgba(45, 74, 43, 0.3);
    border-color: rgba(45, 74, 43, 0.5);
}

[data-guardian-theme="dark"] .alert-warning {
    background: rgba(184, 134, 11, 0.2);
    border-color: rgba(184, 134, 11, 0.4);
}

[data-guardian-theme="dark"] .alert-danger {
    background: rgba(139, 69, 19, 0.3);
    border-color: rgba(139, 69, 19, 0.5);
}

[data-guardian-theme="dark"] .badge {
    font-weight: 600;
}

/* ===== LIGHT MODE READABILITY ===== */

[data-guardian-theme="light"] body,
[data-guardian-theme="light"] {
    color-scheme: light;
}

/* Ensure ALL containers inside body get dark text in light mode */
[data-guardian-theme="light"] .container,
[data-guardian-theme="light"] .container-fluid,
[data-guardian-theme="light"] .container-lg,
[data-guardian-theme="light"] .container-xl {
    color: #2d1f15;
}

/* ===== TRANSITION SMOOTHING ===== */
/* Smooth transition when switching themes */

html[data-guardian-theme] body,
html[data-guardian-theme] .card,
html[data-guardian-theme] .navbar,
html[data-guardian-theme] .modal-content,
html[data-guardian-theme] .form-control,
html[data-guardian-theme] .form-select,
html[data-guardian-theme] .btn,
html[data-guardian-theme] .alert,
html[data-guardian-theme] .badge,
html[data-guardian-theme] .dropdown-menu,
html[data-guardian-theme] .list-group-item,
html[data-guardian-theme] .table,
html[data-guardian-theme] .tab-content,
html[data-guardian-theme] .accordion-item {
    transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease;
}

/* ===== UNIVERSAL FONT SIZE PREFERENCES ===== */

html[data-font-size="small"] body { font-size: 13px; }
html[data-font-size="normal"] body { font-size: 16px; }
html[data-font-size="large"] body { font-size: 19px; }
html[data-font-size="large"] .navbar { font-size: 17px; }
html[data-font-size="large"] h1 { font-size: 2.5rem; }
html[data-font-size="large"] h2 { font-size: 2rem; }
html[data-font-size="large"] h3 { font-size: 1.6rem; }

/* ===== HIGH CONTRAST MODE ===== */

html[data-high-contrast="true"] body {
    font-weight: 500;
}

html[data-high-contrast="true"][data-guardian-theme="light"] body {
    background-color: #ffffff !important;
    color: #000000 !important;
}

html[data-high-contrast="true"][data-guardian-theme="light"] .card {
    background: #ffffff !important;
    border: 2px solid #000000 !important;
    color: #000000 !important;
}

html[data-high-contrast="true"][data-guardian-theme="light"] a:not(.btn):not(.nav-link) {
    color: #0000cc !important;
    text-decoration: underline !important;
}

html[data-high-contrast="true"][data-guardian-theme="dark"] body {
    background-color: #000000 !important;
    color: #ffffff !important;
}

html[data-high-contrast="true"][data-guardian-theme="dark"] .card {
    background: #111111 !important;
    border: 2px solid #ffffff !important;
    color: #ffffff !important;
}

html[data-high-contrast="true"][data-guardian-theme="dark"] a:not(.btn):not(.nav-link) {
    color: #66ccff !important;
    text-decoration: underline !important;
}

/* ===== REDUCED MOTION ===== */

html[data-reduced-motion="true"] *,
html[data-reduced-motion="true"] *::before,
html[data-reduced-motion="true"] *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
}

/* ===== UNIVERSAL READABLE FOCUS STATES ===== */

[data-guardian-theme="light"] :focus-visible {
    outline: 2px solid #1a4d7a;
    outline-offset: 2px;
}

[data-guardian-theme="dark"] :focus-visible {
    outline: 2px solid #ffa726;
    outline-offset: 2px;
}

/* ===== PREVENT INVISIBLE PLACEHOLDER TEXT ===== */

[data-guardian-theme="light"] ::placeholder {
    color: #8B7355 !important;
    opacity: 0.8;
}

[data-guardian-theme="dark"] ::placeholder {
    color: #8B7355 !important;
    opacity: 0.7;
}

/* ===== SELECTION COLOR ===== */

[data-guardian-theme="light"] ::selection {
    background: rgba(26, 77, 122, 0.3);
    color: #000000;
}

[data-guardian-theme="dark"] ::selection {
    background: rgba(255, 167, 38, 0.3);
    color: #ffffff;
}

/* ===== CHART & DATA VIS READABILITY ===== */

[data-guardian-theme="light"] canvas {
    filter: none;
}

/* ===== PRINT READABILITY ===== */
@media print {
    body {
        background: #ffffff !important;
        color: #000000 !important;
    }

    .card {
        background: #ffffff !important;
        border: 1px solid #cccccc !important;
        color: #000000 !important;
        box-shadow: none !important;
    }

    .navbar, footer, .theme-switcher-btn, .cyber-background-particles,
    .cyber-golden-spiral, .cyber-fibonacci-grid {
        display: none !important;
    }

    a {
        color: #000000 !important;
        text-decoration: underline !important;
    }

    h1, h2, h3, h4, h5, h6 {
        color: #000000 !important;
        -webkit-text-fill-color: #000000 !important;
    }
}
