/* ============================================
   WCAG Accessibility Toolbar
   Etap 3: Suwak rozmiaru czcionki A-/A+
   Etap 4: Motywy jasny/ciemny/wysoki kontrast
   ============================================ */

/* ---- Zmienne bazowe ---- */
:root {
    --exam-font-size: 18px;

    /* Motyw jasny (domyślny) */
    --exam-bg: #ffffff;
    --exam-bg-gradient-start: #e8f5f1;
    --exam-text: #1a1a1a;
    --exam-text-secondary: #4a5568;
    --exam-text-muted: #8492a6;
    --exam-accent: #1ab394;
    --exam-accent-hover: #159c80;
    --exam-accent-shadow: rgba(26, 179, 148, 0.25);
    --exam-accent-shadow-hover: rgba(26, 179, 148, 0.35);
    --exam-heading: #2c3e50;
    --exam-border: #dce1e8;
    --exam-border-light: #f0f2f5;
    --exam-card-bg: #fff;
    --exam-card-shadow: rgba(0, 0, 0, 0.08);
    --exam-ibox-shadow: rgba(0, 0, 0, 0.07);
    --exam-ibox-header-bg: linear-gradient(to right, #f9fafb, #fff);
    --exam-info-bg: #f9fafb;
    --exam-modal-shadow: rgba(0, 0, 0, 0.15);
    --exam-danger: #c0392b;
    --exam-danger-bg: #fdf0f0;
    --exam-warning-icon: #f0ad4e;
    --exam-gccs-info-bg: #f7faf9;
    --exam-declaration-bg: #f9fafb;
    --exam-dropzone-bg: #f9fdfb;
    --exam-dropzone-hover-bg: #f0faf6;
    --exam-focus-ring: #005fcc;
    --exam-focus-shadow: rgba(0, 95, 204, 0.25);
}

/* ---- Motyw ciemny ---- */
body.theme-dark {
    --exam-bg: #1e1e2e;
    --exam-bg-gradient-start: #1e1e2e;
    --exam-text: #e0e0e0;
    --exam-text-secondary: #b0b8c4;
    --exam-text-muted: #8892a0;
    --exam-accent: #2ed8b6;
    --exam-accent-hover: #26b89a;
    --exam-accent-shadow: rgba(46, 216, 182, 0.25);
    --exam-accent-shadow-hover: rgba(46, 216, 182, 0.35);
    --exam-heading: #e8ecf0;
    --exam-border: #3a3a4e;
    --exam-border-light: #2e2e42;
    --exam-card-bg: #28283c;
    --exam-card-shadow: rgba(0, 0, 0, 0.3);
    --exam-ibox-shadow: rgba(0, 0, 0, 0.25);
    --exam-ibox-header-bg: linear-gradient(to right, #2a2a3e, #28283c);
    --exam-info-bg: #2a2a3e;
    --exam-modal-shadow: rgba(0, 0, 0, 0.4);
    --exam-danger: #e74c3c;
    --exam-danger-bg: #3a1a1a;
    --exam-warning-icon: #f0ad4e;
    --exam-gccs-info-bg: #2a2a3e;
    --exam-declaration-bg: #2a2a3e;
    --exam-dropzone-bg: #2a2a3e;
    --exam-dropzone-hover-bg: #323248;
    --exam-focus-ring: #5ca8ff;
    --exam-focus-shadow: rgba(92, 168, 255, 0.3);
}

/* ---- Motyw wysoki kontrast ---- */
body.theme-high-contrast {
    --exam-bg: #000000;
    --exam-bg-gradient-start: #000000;
    --exam-text: #ffffff;
    --exam-text-secondary: #ffffff;
    --exam-text-muted: #cccccc;
    --exam-accent: #ffff00;
    --exam-btn-primary-text: #000000;
    --exam-accent-hover: #ffdd00;
    --exam-accent-shadow: rgba(255, 255, 0, 0.3);
    --exam-accent-shadow-hover: rgba(255, 255, 0, 0.45);
    --exam-heading: #ffffff;
    --exam-border: #ffffff;
    --exam-border-light: #666666;
    --exam-card-bg: #000000;
    --exam-card-shadow: none;
    --exam-ibox-shadow: none;
    --exam-ibox-header-bg: #000000;
    --exam-info-bg: #1a1a1a;
    --exam-modal-shadow: rgba(255, 255, 255, 0.2);
    --exam-danger: #ff4444;
    --exam-danger-bg: #330000;
    --exam-warning-icon: #ffff00;
    --exam-gccs-info-bg: #1a1a1a;
    --exam-declaration-bg: #1a1a1a;
    --exam-dropzone-bg: #1a1a1a;
    --exam-dropzone-hover-bg: #2a2a2a;
    --exam-focus-ring: #ffff00;
    --exam-focus-shadow: rgba(255, 255, 0, 0.4);
}

/* ---- Systemowe preferencje jako fallback ---- */
@media (prefers-color-scheme: dark) {
    body:not(.theme-light):not(.theme-high-contrast) {
        --exam-bg: #1e1e2e;
        --exam-bg-gradient-start: #1e1e2e;
        --exam-text: #e0e0e0;
        --exam-text-secondary: #b0b8c4;
        --exam-text-muted: #8892a0;
        --exam-accent: #2ed8b6;
        --exam-accent-hover: #26b89a;
        --exam-accent-shadow: rgba(46, 216, 182, 0.25);
        --exam-accent-shadow-hover: rgba(46, 216, 182, 0.35);
        --exam-heading: #e8ecf0;
        --exam-border: #3a3a4e;
        --exam-border-light: #2e2e42;
        --exam-card-bg: #28283c;
        --exam-card-shadow: rgba(0, 0, 0, 0.3);
        --exam-ibox-shadow: rgba(0, 0, 0, 0.25);
        --exam-ibox-header-bg: linear-gradient(to right, #2a2a3e, #28283c);
        --exam-info-bg: #2a2a3e;
        --exam-modal-shadow: rgba(0, 0, 0, 0.4);
        --exam-danger: #e74c3c;
        --exam-danger-bg: #3a1a1a;
        --exam-warning-icon: #f0ad4e;
        --exam-gccs-info-bg: #2a2a3e;
        --exam-declaration-bg: #2a2a3e;
        --exam-dropzone-bg: #2a2a3e;
        --exam-dropzone-hover-bg: #323248;
        --exam-focus-ring: #5ca8ff;
        --exam-focus-shadow: rgba(92, 168, 255, 0.3);
    }
}

@media (prefers-contrast: more) {
    body:not(.theme-light):not(.theme-dark) {
        --exam-bg: #000000;
        --exam-bg-gradient-start: #000000;
        --exam-text: #ffffff;
        --exam-text-secondary: #ffffff;
        --exam-text-muted: #cccccc;
        --exam-accent: #ffff00;
        --exam-btn-primary-text: #000000;
        --exam-accent-hover: #ffdd00;
        --exam-accent-shadow: rgba(255, 255, 0, 0.3);
        --exam-accent-shadow-hover: rgba(255, 255, 0, 0.45);
        --exam-heading: #ffffff;
        --exam-border: #ffffff;
        --exam-border-light: #666666;
        --exam-card-bg: #000000;
        --exam-card-shadow: none;
        --exam-ibox-shadow: none;
        --exam-ibox-header-bg: #000000;
        --exam-info-bg: #1a1a1a;
        --exam-modal-shadow: rgba(255, 255, 255, 0.2);
        --exam-danger: #ff4444;
        --exam-danger-bg: #330000;
        --exam-warning-icon: #ffff00;
        --exam-gccs-info-bg: #1a1a1a;
        --exam-declaration-bg: #1a1a1a;
        --exam-dropzone-bg: #1a1a1a;
        --exam-dropzone-hover-bg: #2a2a2a;
        --exam-focus-ring: #ffff00;
        --exam-focus-shadow: rgba(255, 255, 0, 0.4);
    }
}

/* Nadpisanie font-size na html — rem skaluje się od tej wartości */
html {
    font-size: var(--exam-font-size) !important;
}

/* Pasek narzędzi WCAG */
.wcag-toolbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 9999;
    background: #f8f9fa;
    border-bottom: 1px solid #dce1e8;
    padding: 6px 16px;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    font-family: 'Inter', 'Open Sans', 'Helvetica Neue', Helvetica, Arial, sans-serif;
    font-size: 14px !important; /* toolbar nie skaluje się z resztą */
}

/* Odsunięcie body od góry żeby toolbar nie zasłaniał treści */
body.wcag-toolbar-active {
    padding-top: 42px !important;
}

/* Grupa suwaka */
.wcag-font-group {
    display: flex;
    align-items: center;
    gap: 4px;
}

.wcag-font-group label {
    font-size: 13px !important;
    color: #4a5568;
    margin: 0;
    white-space: nowrap;
}

/* Przyciski A- / A+ */
.wcag-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border: 1px solid #c0c8d0;
    border-radius: 4px;
    background: #fff;
    color: #2c3e50;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
    font-size: 14px !important;
    padding: 0;
    line-height: 1;
}

.wcag-btn:hover {
    background: #e8ecf0;
    border-color: #9aa5b0;
}

.wcag-btn:focus-visible {
    outline: 3px solid #005fcc !important;
    outline-offset: 2px !important;
}

/* Wyświetlacz aktualnego rozmiaru */
.wcag-font-size-display {
    font-size: 13px !important;
    color: #2c3e50;
    min-width: 38px;
    text-align: center;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

/* Reset — przycisk przywracania domyślnych */
.wcag-btn-reset {
    font-size: 12px !important;
    width: auto;
    padding: 0 8px;
    color: #8492a6;
    border-color: transparent;
    background: transparent;
}

.wcag-btn-reset:hover {
    color: #2c3e50;
    background: #e8ecf0;
}

/* ---- Grupa motywów ---- */
.wcag-theme-group {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-right: 12px;
    padding-right: 12px;
    border-right: 1px solid #dce1e8;
}

.wcag-theme-group label {
    font-size: 13px !important;
    color: #4a5568;
    margin: 0;
    white-space: nowrap;
}

.wcag-btn-theme {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 32px;
    height: 32px;
    border: 1px solid #c0c8d0;
    border-radius: 4px;
    background: #fff;
    color: #2c3e50;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
    font-size: 13px !important;
    padding: 0 6px;
    line-height: 1;
}

.wcag-btn-theme:hover {
    background: #e8ecf0;
    border-color: #9aa5b0;
}

.wcag-btn-theme:focus-visible {
    outline: 3px solid var(--exam-focus-ring, #005fcc) !important;
    outline-offset: 2px !important;
}

.wcag-btn-theme.active {
    background: #005fcc;
    color: #fff;
    border-color: #005fcc;
}

/* ---- Toolbar w motywach ciemnym / HC ---- */
body.theme-dark .wcag-toolbar {
    background: #28283c;
    border-bottom-color: #3a3a4e;
}
body.theme-dark .wcag-toolbar label,
body.theme-dark .wcag-font-size-display {
    color: #b0b8c4;
}
body.theme-dark .wcag-btn {
    background: #3a3a4e;
    border-color: #4a4a5e;
    color: #e0e0e0;
}
body.theme-dark .wcag-btn:hover {
    background: #4a4a5e;
}
body.theme-dark .wcag-btn-theme {
    background: #3a3a4e;
    border-color: #4a4a5e;
    color: #e0e0e0;
}
body.theme-dark .wcag-btn-theme:hover {
    background: #4a4a5e;
}
body.theme-dark .wcag-btn-theme.active {
    background: #5ca8ff;
    color: #1a1a2e;
    border-color: #5ca8ff;
}
body.theme-dark .wcag-theme-group {
    border-right-color: #4a4a5e;
}

body.theme-high-contrast .wcag-toolbar {
    background: #000;
    border-bottom: 2px solid #fff;
}
body.theme-high-contrast .wcag-toolbar label,
body.theme-high-contrast .wcag-font-size-display {
    color: #fff;
}
body.theme-high-contrast .wcag-btn {
    background: #000;
    border: 2px solid #fff;
    color: #fff;
}
body.theme-high-contrast .wcag-btn:hover {
    background: #333;
}
body.theme-high-contrast .wcag-btn-theme {
    background: #000;
    border: 2px solid #fff;
    color: #fff;
}
body.theme-high-contrast .wcag-btn-theme:hover {
    background: #333;
}
body.theme-high-contrast .wcag-btn-theme.active {
    background: #ffff00;
    color: #000;
    border-color: #ffff00;
}
body.theme-high-contrast .wcag-theme-group {
    border-right-color: #fff;
}

/* ---- Etap 5: Info o skrótach klawiaturowych ---- */
.wcag-shortcuts-info {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-left: 12px;
    padding-left: 12px;
    border-left: 1px solid #dce1e8;
}

.wcag-shortcuts-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border: 1px solid #c0c8d0;
    border-radius: 50%;
    background: #fff;
    color: #4a5568;
    font-weight: 700;
    font-size: 14px !important;
    cursor: pointer;
    position: relative;
}

.wcag-shortcuts-toggle:focus-visible {
    outline: 3px solid var(--exam-focus-ring, #005fcc) !important;
    outline-offset: 2px !important;
}

.wcag-shortcuts-panel {
    display: none;
    position: fixed;
    top: 42px;
    right: 8px;
    z-index: 10000;
    background: var(--exam-card-bg, #fff);
    border: 1px solid var(--exam-border, #dce1e8);
    border-radius: 8px;
    padding: 12px 16px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.12);
    font-size: 13px !important;
    color: var(--exam-text, #1a1a1a);
    min-width: 220px;
}

.wcag-shortcuts-panel.visible {
    display: block;
}

.wcag-shortcuts-panel table {
    width: 100%;
    border-collapse: collapse;
}

.wcag-shortcuts-panel td {
    padding: 3px 0;
    font-size: 13px !important;
}

.wcag-shortcuts-panel td:first-child {
    font-weight: 700;
    padding-right: 12px;
    white-space: nowrap;
}

.wcag-shortcuts-panel kbd {
    display: inline-block;
    background: var(--exam-info-bg, #f0f2f5);
    border: 1px solid var(--exam-border, #dce1e8);
    border-radius: 3px;
    padding: 1px 6px;
    font-size: 12px !important;
    font-family: monospace;
}

/* Motywy dla shortcuts */
body.theme-dark .wcag-shortcuts-toggle {
    background: #3a3a4e;
    border-color: #4a4a5e;
    color: #b0b8c4;
}
body.theme-dark .wcag-shortcuts-info {
    border-left-color: #4a4a5e;
}

body.theme-high-contrast .wcag-shortcuts-toggle {
    background: #000;
    border: 2px solid #fff;
    color: #fff;
}
body.theme-high-contrast .wcag-shortcuts-info {
    border-left-color: #fff;
}
