/* Accessibility Widget Styles */

:root {
    --access-primary: #0056b3;
    --access-bg: #ffffff;
    --access-text: #333333;
    --access-border: #cccccc;
}

/* Toggle Button */
#access-toggle-btn {
    position: fixed;
    bottom: 44%;
    left: 0;
    transform: translateY(-50%);
    background-color: var(--access-primary);
    color: white;
    border: none;
    border-radius: 0 4px 4px 0;
    padding: 8px;
    cursor: pointer;
    z-index: 10000;
    box-shadow: 2px 2px 5px rgba(0, 0, 0, 0.2);
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
}

#access-toggle-btn:hover {
    background-color: #004494;
    padding-left: 12px;
}

/* Header Integrated Theme Toggle */
.header-theme-toggle {
    position: absolute;
    right: var(--space);
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    width: 38px;
    height: 38px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    transition: all 0.3s ease;
    padding: 0;
    line-height: 1;
    z-index: 100;
}

.header-theme-toggle:hover {
    transform: translateY(-50%) scale(1.2);
    filter: drop-shadow(0 0 8px rgba(255, 255, 255, 0.4));
}

/* Mobile Adjustments */
@media (max-width: 1200px) {
    .header-theme-toggle {
        top: 20px;
        transform: none;
        right: -10px;
    }
    .header-theme-toggle:hover {
        transform: scale(1.2);
    }
}

#access-toggle-btn:focus {
    outline: 2px solid yellow;
}

/* Accessibility Menu */
#access-menu {
    position: fixed;
    top: 50%;
    left: -600px;
    transform: translateY(-50%);
    width: 280px;
    background-color: var(--access-bg);
    border: 1px solid var(--access-border);
    border-radius: 0 8px 8px 0;
    box-shadow: 4px 4px 10px rgba(0, 0, 0, 0.1);
    z-index: 9999;
    transition: left 0.3s ease-in-out;
    display: flex;
    flex-direction: column;
    padding: 20px;
}

#access-menu.open {
    left: 0;
}

/* When menu is open, move button */
#access-menu.open~#access-toggle-btn {
    left: 400px;
}

#access-menu h2 {
    margin-top: 0;
    font-size: 1.2rem;
    color: var(--access-text);
    border-bottom: 2px solid var(--access-primary);
    padding-bottom: 10px;
    margin-bottom: 15px;
    text-align: center;
}

.access-btn {
    background-color: #f0f0f0;
    border: 1px solid #ddd;
    padding: 10px;
    margin-bottom: 10px;
    cursor: pointer;
    text-align: center;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    font-size: 1rem;
    transition: background 0.2s;
}

.access-btn:hover {
    background-color: #e0e0e0;
}

.access-btn.active {
    background-color: var(--access-primary);
    color: white;
    border-color: var(--access-primary);
}

/* Accessibility Modes */

/* High Contrast */
body.access-high-contrast {
    filter: contrast(1.5);
    background-color: black !important;
    color: yellow !important;
}

body.access-high-contrast * {
    background-color: black !important;
    color: yellow !important;
    border-color: yellow !important;
}

body.access-high-contrast img {
    filter: invert(1);
}

/* Dark Mode */
html.access-dark-mode, body.access-dark-mode {
    --bg: #0f172a;
    --card: #1e293b;
    --text: #f1f5f9;
    --text-muted: #94a3b8;
    --border: #334155;
    background-color: var(--bg) !important;
    color: var(--text) !important;
}

html.access-dark-mode *, body.access-dark-mode * {
    border-color: var(--border) !important;
}

body.access-dark-mode .diag-card,
body.access-dark-mode .choice-btn,
body.access-dark-mode .test-selection-card,
body.access-dark-mode .modal-content,
body.access-dark-mode .lang-bar,
body.access-dark-mode .bottom-nav {
    background-color: var(--card) !important;
    color: var(--text) !important;
}

body.access-dark-mode .close,
body.access-dark-mode .close-modal,
body.access-dark-mode .btn-close-large,
body.access-dark-mode .image-modal-close,
body.access-dark-mode .btn-close-rating,
body.access-dark-mode .toast-close {
    color: #ffffff !important;
    opacity: 0.9;
}

body.access-dark-mode .close:hover,
body.access-dark-mode .close-modal:hover,
body.access-dark-mode .btn-close-large:hover,
body.access-dark-mode .image-modal-close:hover,
body.access-dark-mode .btn-close-rating:hover,
body.access-dark-mode .toast-close:hover {
    color: #ffffff !important;
    opacity: 1;
    text-shadow: 0 0 5px rgba(255,255,255,0.5);
}

body.access-dark-mode input:not([type="checkbox"]):not([type="radio"]),
body.access-dark-mode select,
body.access-dark-mode textarea {
    background-color: #0f172a !important;
    color: #ffffff !important;
    border-color: #334155 !important;
    background-image: none !important;
}

body.access-dark-mode input::placeholder,
body.access-dark-mode textarea::placeholder {
    color: rgba(255, 255, 255, 0.6) !important;
}

/* More aggressive input overrides for filled/focus/autofill states */
body.access-dark-mode input:not([type="checkbox"]):not([type="radio"]):focus,
body.access-dark-mode input:not([type="checkbox"]):not([type="radio"]):not(:placeholder-shown),
body.access-dark-mode input:not([type="checkbox"]):not([type="radio"]):-webkit-autofill,
body.access-dark-mode input:not([type="checkbox"]):not([type="radio"]):-webkit-autofill:hover,
body.access-dark-mode input:not([type="checkbox"]):not([type="radio"]):-webkit-autofill:focus,
body.access-dark-mode select:focus,
body.access-dark-mode textarea:focus {
    background-color: #0f172a !important;
    color: #ffffff !important;
    -webkit-text-fill-color: #ffffff !important;
    transition: background-color 5000s ease-in-out 0s;
    box-shadow: 0 0 0px 1000px #0f172a inset !important;
}

body.access-dark-mode .btn-secondary {
    background-color: #334155 !important;
    color: #ffffff !important;
}

body.access-dark-mode .text-muted {
    color: var(--text-muted) !important;
}

body.access-dark-mode img:not(.floating-logo):not(.choice-icon-img) {
    opacity: 0.8;
}

/* Diagnostic Titles */
body.access-dark-mode .result-title,
body.access-dark-mode .diag-text h3,
body.access-dark-mode .wizard-step h2,
body.access-dark-mode .wizard-step label,
body.access-dark-mode .wizard-step .form-label-bold,
body.access-dark-mode .wizard-step span:not(.badge):not(.status-icon),
body.access-dark-mode .wizard-step .btn-show-help,
body.access-dark-mode .wizard-step .btn-back-custom {
    color: #ffffff !important;
}

body.access-dark-mode #target-warning-eux {
    background: #2c1a04 !important;
    border-color: #b75c00 !important;
    color: #ffb84d !important;
}

/* Suggestion Components */
body.access-dark-mode .suggestion-header {
    background-color: var(--card) !important;
    color: var(--text) !important;
    border-bottom: 1px solid var(--border) !important;
}

body.access-dark-mode .suggestion-header.active,
body.access-dark-mode .suggestion-header:hover {
    background-color: var(--bg) !important;
}

body.access-dark-mode .suggestion-variants {
    background-color: var(--card) !important;
    border-bottom-color: var(--border) !important;
}

body.access-dark-mode .suggestion-group,
body.access-dark-mode .suggestion-item {
    background-color: var(--card) !important;
    color: var(--text) !important;
}

body.access-dark-mode .suggestion-item:hover {
    background-color: var(--bg) !important;
}

/* Results & Country Cards */
body.access-dark-mode .result-section {
    background-color: var(--card) !important;
    border-color: var(--border) !important;
}

body.access-dark-mode .tags-container,
body.access-dark-mode .results-list-premium {
    background-color: var(--bg) !important;
    border-color: var(--border) !important;
}

body.access-dark-mode .country-card {
    background-color: var(--card) !important;
}

body.access-dark-mode .country-card.card-success {
    border-color: #059669 !important;
    background-color: rgba(5, 150, 105, 0.1) !important;
}

body.access-dark-mode .country-card.card-warning {
    border-color: #d97706 !important;
    background-color: rgba(217, 119, 6, 0.1) !important;
}

body.access-dark-mode .country-card.card-error {
    border-color: #dc2626 !important;
    background-color: rgba(220, 38, 38, 0.1) !important;
}

/* Extra support for buy-res elements */
body.access-dark-mode #buy-res-2-native,
body.access-dark-mode #buy-res-2-announce,
body.access-dark-mode #buy-res-3 {
    background-color: transparent !important;
}

/* Pop-up Menus */
body.access-dark-mode .mobile-pop-up-menu {
    background-color: rgba(30, 41, 59, 0.95) !important;
    backdrop-filter: blur(10px) !important;
    border-color: var(--border) !important;
}

/* Sticky Footer Fix */
body.access-dark-mode .new-check-container {
    background-color: rgba(15, 23, 42, 0.9) !important;
}

/* Community Section Fix */
body.access-dark-mode .community-section {
    background-color: var(--card) !important;
    border-color: var(--border) !important;
}

/* Recording Tabs & Purchase */
body.access-dark-mode .rec-tabs-container {
    background-color: var(--bg) !important;
}

body.access-dark-mode .rec-tab-btn.active {
    background-color: var(--card) !important;
}

body.access-dark-mode .purchase-terms-box {
    background-color: var(--bg) !important;
}

/* Detail Box Overrides (Fixing new inline styles) */
body.access-dark-mode #check1-details-box,
body.access-dark-mode #check4-details-box,
body.access-dark-mode #smart-analysis-box {
    background-color: var(--bg) !important;
    border-color: var(--border) !important;
}

/* Round 5: Secondary Pages & Modal Footer */
body.access-dark-mode .legal-page,
body.access-dark-mode .deletion-container,
body.access-dark-mode .flash-modal-content {
    background-color: var(--card) !important;
    color: var(--text) !important;
}

body.access-dark-mode .info-box-gray,
body.access-dark-mode .help-box,
body.access-dark-mode .highlight-box,
body.access-dark-mode .feedback-section,
body.access-dark-mode .warning-box,
body.access-dark-mode .privacy-highlight {
    background-color: var(--bg) !important;
    border-color: var(--border) !important;
    color: var(--text) !important;
}

body.access-dark-mode .sticky-modal-footer {
    background-color: rgba(15, 23, 42, 0.95) !important;
    backdrop-filter: blur(10px) !important;
    border-top-color: var(--border) !important;
}

body.access-dark-mode .checklist-item {
    background-color: var(--bg) !important;
    border-color: var(--border) !important;
}

body.access-dark-mode .sticky-back-btn {
    background-color: var(--card) !important;
    border-color: var(--border) !important;
    color: var(--text) !important;
}

body.access-dark-mode .step-title,
body.access-dark-mode .guide-title,
body.access-dark-mode .flash-modal-title,
body.access-dark-mode .modal-content h1,
body.access-dark-mode .modal-content h2,
body.access-dark-mode .modal-content h3,
body.access-dark-mode .modal-content h4,
body.access-dark-mode .modal-content h5,
body.access-dark-mode .modal-content h6,
body.access-dark-mode .modal-content p,
body.access-dark-mode .modal-content li,
body.access-dark-mode .modal-content label,
body.access-dark-mode .modal-content span:not(.icon):not(.bullet),
body.access-dark-mode .legal-page h1,
body.access-dark-mode .legal-page h2,
body.access-dark-mode .legal-page h3,
body.access-dark-mode .legal-page h4,
body.access-dark-mode .legal-page p,
body.access-dark-mode .legal-page li,
body.access-dark-mode .deletion-container h1,
body.access-dark-mode .deletion-container h2,
body.access-dark-mode .deletion-container h3,
body.access-dark-mode .deletion-container p,
body.access-dark-mode .deletion-container label,
body.access-dark-mode .deletion-container li {
    color: var(--text) !important;
}

body.access-dark-mode .deletion-container p {
    color: var(--text-muted) !important;
}

body.access-dark-mode .deletion-container input[readonly] {
    background-color: rgba(22, 101, 52, 0.2) !important;
    color: #86efac !important;
    border-color: #16a34a !important;
}

body.access-dark-mode .auto-detect-badge {
    background-color: rgba(22, 101, 52, 0.2) !important;
    color: #86efac !important;
    border-color: #16a34a !important;
}

body.access-dark-mode .legal-notice {
    color: #f87171 !important;
}

/* Incremental Font Scaling */
body {
    --access-font-scale: 1;
}

body.access-font-scaled,
body.access-font-scaled p,
body.access-font-scaled h1,
body.access-font-scaled h2,
body.access-font-scaled h3,
body.access-font-scaled h4,
body.access-font-scaled h5,
body.access-font-scaled h6,
body.access-font-scaled span,
body.access-font-scaled div,
body.access-font-scaled a,
body.access-font-scaled li,
body.access-font-scaled td,
body.access-font-scaled th,
body.access-font-scaled button,
body.access-font-scaled input,
body.access-font-scaled select,
body.access-font-scaled textarea {
    /* Most elements scale by a factor slightly less than the body to maintain balance */
    font-size: calc(100% * ((var(--access-font-scale) - 1) * 0.5 + 1)) !important;
    overflow-wrap: break-word !important;
}

/* Prevent bottom nav from inheriting generic 100% scaling rule which makes it huge */
body.access-font-scaled .bottom-nav {
    font-size: 1rem !important;
}

body.access-font-scaled .bottom-nav-btn {
    font-size: 1rem !important;
}

body.access-font-scaled .nav-icon {
    font-size: 1.2rem !important;
}

body.access-font-scaled .nav-label {
    font-size: 0.6rem !important;
}

body.access-font-enlarged .bottom-nav-btn {
    font-size: calc(1rem * ((var(--access-nav-scale) - 1) * 0.5 + 1)) !important;
}

body.access-font-enlarged .nav-icon {
    font-size: calc(1.2rem * ((var(--access-nav-scale) - 1) * 0.5 + 1)) !important;
}

body.access-font-enlarged .nav-label {
    font-size: calc(0.6rem * ((var(--access-nav-scale) - 1) * 0.5 + 1)) !important;
}

body.access-font-scaled .footer-device-id {
    font-size: 10px !important;
}

body.access-font-scaled {
    font-size: calc(100% * var(--access-font-scale)) !important;
}

/* Neutralize inherited scaling for the bar itself */
body.access-font-enlarged .bottom-nav {
    font-size: 1rem !important;
}

/* Layout fixing for large fonts */
body.access-font-scaled .diag-card,
body.access-font-scaled .diag-info,
body.access-font-scaled .wizard-nav-container,
body.access-font-scaled .csc-version-row,
body.access-font-scaled .choice-grid,
body.access-font-scaled .tests-selection-grid {
    flex-wrap: wrap !important;
    height: auto !important;
}

body.access-font-scaled .diag-info {
    align-items: flex-start !important;
}

body.access-font-scaled .diag-status {
    width: 100% !important;
    text-align: start !important;
    margin-top: 10px !important;
    margin-left: 0 !important;
}

/* Bottom Nav Scaling Fixes (Only on Enlarge) */
body.access-font-enlarged .bottom-nav {
    height: auto !important;
    padding: 10px 5px !important;
    gap: 2px !important;
}

body.access-font-enlarged .bottom-nav-btn {
    flex-direction: column !important;
    gap: 4px !important;
}

/* Grayscale */
body.access-grayscale {
    filter: grayscale(100%);
}

/* Big Cursor */
body.access-big-cursor {
    cursor: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewport="0 0 48 48" style="fill:black;stroke:white;stroke-width:2px;"><path d="M10 40 L10 10 L35 25 L20 25 Z"/></svg>') 10 10, auto !important;
}

body.access-big-cursor a,
body.access-big-cursor button,
body.access-big-cursor input {
    cursor: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewport="0 0 48 48" style="fill:black;stroke:white;stroke-width:2px;"><path d="M10 40 L10 10 L35 25 L20 25 Z"/></svg>') 10 10, pointer !important;
}

/* Reading Guide */
#access-guide-line {
    position: fixed;
    left: 0;
    width: 100%;
    height: 4px;
    background-color: rgba(255, 255, 0, 0.5);
    border-top: 2px solid red;
    border-bottom: 2px solid red;
    pointer-events: none;
    z-index: 2147483647;
    /* Max z-index */
    transform: translateY(-50%);
    display: none;
}

body.access-reading-guide #access-guide-line {
    display: block;
}

/* Highlight Links */
body.access-highlight-links a {
    text-decoration: underline !important;
    background-color: yellow !important;
    color: black !important;
    font-weight: bold !important;
}

/* Readable Font */
body.access-readable-font {
    font-family: Arial, Helvetica, sans-serif !important;
}

/* Reset Button */
#access-reset {
    margin-top: 10px;
    background-color: #d9534f;
    color: white;
    border: none;
}

#access-reset:hover {
    background-color: #c9302c;
}

/* Ad Ready Toast Optimization */
.ad-ready-toast {
    position: fixed;
    bottom: 25px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    color: #1e293b;
    padding: 12px 20px;
    border-radius: 16px;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
    z-index: 10000;
    display: flex;
    align-items: center;
    gap: 15px;
    border: 1px solid rgba(0, 107, 229, 0.15);
    transition: transform 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275), opacity 0.5s ease;
    opacity: 0;
    min-width: 280px;
    max-width: 90%;
}

.ad-ready-toast.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

.ad-ready-toast .toast-icon {
    font-size: 1.4rem;
    animation: adBounce 2s infinite;
}

.ad-ready-toast .toast-text {
    font-weight: 600;
    font-size: 0.95rem;
    flex-grow: 1;
}

.ad-ready-toast .toast-close {
    background: rgba(0, 0, 0, 0.05);
    border: none;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 1.1rem;
    color: #64748b;
    transition: background 0.2s ease, color 0.2s ease;
}

.ad-ready-toast .toast-close:hover {
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
}

@keyframes adBounce {
    0%, 20%, 50%, 80%, 100% { transform: translateY(0); }
    40% { transform: translateY(-5px); }
    60% { transform: translateY(-3px); }
}

.supported-region-badge {
    background: rgba(0, 0, 0, 0.06);
    color: #000000 !important;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.9em;
    font-weight: 600;
}

body.access-dark-mode .supported-region-badge {
    background: rgba(255, 255, 255, 0.1);
    color: #ffffff !important;
}

[dir="rtl"] .ad-ready-toast {
    direction: rtl;
}

body.access-dark-mode .copyright,
body.access-dark-mode .footer-device-id,
body.access-dark-mode #footerDeviceId {
    color: #FFFFFF !important;
}

/* Premium Why Pay styles for Dark Mode */
body.access-dark-mode .btn-why-pay-premium {
    background: linear-gradient(135deg, #1e293b, #334155) !important;
    border-color: rgba(255, 255, 255, 0.1) !important;
    color: #ffffff !important;
}

body.access-dark-mode .btn-why-pay-premium:hover {
    background: var(--primary) !important;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.4) !important;
}

body.access-dark-mode .why-pay-box-premium {
    background: linear-gradient(to bottom, #1e293b, #0f172a) !important;
    border-color: rgba(255, 255, 255, 0.1) !important;
    color: #f1f5f9 !important;
}

body.access-dark-mode .info-icon-lg {
    background: #1e293b !important;
    border-color: #334155 !important;
}
