/* --- ZMIENNE GLOBALNE --- */
:root {
    --wcag-primary-color: #242321;
    --wcag-primary-hover: #D6BEA1;
    --wcag-background-color: #ffffff;
    --wcag-panel-background: #fdfdfd;
    --wcag-text-color: #2c3e50;
    --wcag-text-light: #576a7e;
    --wcag-border-color: #e9eef2;
    --wcag-shadow: 0 8px 30px rgba(0, 0, 0, 0.12);
    --wcag-shadow-light: 0 2px 8px rgba(0, 0, 0, 0.08);
    --wcag-success-color: #27ae60;
    --wcag-reset-color: #7f8c8d;
    --wcag-reset-hover: #6c7a7b;
    --wcag-font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

/* --- KONTENER I PRZYCISK GŁÓWNY --- */
.wcag-panel-container {
    position: fixed;
    top: 50%;
    right: 0;
    transform: translateY(-50%);
    z-index: 99999;
    font-family: var(--wcag-font-family);
}

.wcag-trigger {
    background-color: var(--wcag-primary-color);
    border: none;
    width: 56px;
    height: 56px;
    border-radius: 12px 0 0 12px;
    cursor: pointer;
    box-shadow: var(--wcag-shadow);
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
}
.wcag-trigger:hover {
    background-color: var(--wcag-primary-hover);
    transform: scale(1.05);
}
.wcag-trigger .lucide { width: 28px; height: 28px; }

/* --- PANEL GŁÓWNY --- */
.wcag-panel {
    position: absolute;
    top: 50%;
    right: calc(100% + 15px);
    width: 310px;
    background: var(--wcag-background-color);
    box-shadow: var(--wcag-shadow);
    border-radius: 12px;
    opacity: 0;
    transform: translate(15px, -50%);
    visibility: hidden;
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    border: 1px solid var(--wcag-border-color);
    overflow: hidden;
}
.wcag-panel:not(.wcag-panel-hidden) {
    opacity: 1;
    transform: translate(0, -50%);
    visibility: visible;
}

/* --- STRUKTURA PANELU --- */
.wcag-panel-header {
    padding: 16px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--wcag-border-color);
}
.wcag-panel-header h2 { margin: 0; font-size: 18px; font-weight: 600; color: var(--wcag-text-color); }
#wcag-panel-close { background: none; border: none; cursor: pointer; color: var(--wcag-text-light); padding: 4px; border-radius: 50%;}
#wcag-panel-close:hover { background-color: #f0f0f0; }

.wcag-panel-body { padding: 8px 20px; }
.wcag-option {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 0;
    border-bottom: 1px solid var(--wcag-border-color);
}
.wcag-option:last-child { border-bottom: none; }

.wcag-label {
    font-size: 16px; color: var(--wcag-text-color); font-weight: 500;
    display: flex; align-items: center; gap: 10px;
}
.wcag-label .lucide { color: var(--wcag-primary-color); }

.wcag-controls { display: flex; gap: 8px; align-items: center; }

/* --- KONTROLKI (PRZYCISKI) --- */
/* Przyciski +/- */
#wcag-font-decrease, #wcag-font-increase {
    width: 40px; height: 40px; border-radius: 8px;
    background-color: #fff; border: 1px solid var(--wcag-border-color);
    box-shadow: var(--wcag-shadow-light); cursor: pointer; color: var(--wcag-text-light);
    display: flex; align-items: center; justify-content: center;
    transition: all 0.2s ease;
}
#wcag-font-decrease:hover, #wcag-font-increase:hover {
    border-color: var(--wcag-primary-hover); transform: translateY(-1px); color: var(--wcag-primary-hover);
}

/* Przyciski przełączające (toggle switch) */
.wcag-toggle-button {
    --width: 48px; --height: 26px;
    position: relative; width: var(--width); height: var(--height);
    background-color: #bdc3c7; border-radius: 20px; border: none;
    cursor: pointer; transition: background-color 0.3s ease;
}
.wcag-toggle-slider {
    position: absolute; top: 3px; left: 4px;
    width: calc(var(--height) - 6px); height: calc(var(--height) - 6px);
    background-color: white; border-radius: 50%;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
    transition: transform 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}
.wcag-toggle-button[aria-pressed="true"] { background-color: var(--wcag-success-color); }
.wcag-toggle-button[aria-pressed="true"] .wcag-toggle-slider {
    transform: translateX(calc(var(--width) - var(--height)));
}

/* Przycisk resetu */
.wcag-panel-footer { padding: 16px 20px; border-top: 1px solid var(--wcag-border-color); background: #fafafa; }
.wcag-reset-button {
    width: 100%; padding: 12px; background: var(--wcag-reset-color); color: white;
    border: none; border-radius: 8px; cursor: pointer;
    font-size: 14px; font-weight: 500; text-align: center;
    display: flex; align-items: center; justify-content: center; gap: 8px;
    transition: background-color 0.2s;
}
.wcag-reset-button:hover { background: var(--wcag-reset-hover); }


/* --- ⭐ OSTATECZNY, NIEZAWODNY TRYB WYSOKIEGO KONTRASTU ⭐ --- */

/* Ustawiamy globalne tło na czarne i domyślny kolor tekstu na żółty */
html.wcag-high-contrast body {
    background-color: #000 !important;
    color: #ffff00 !important; /* Jaskrawy żółty */
}

/*
 * Używamy selektora uniwersalnego (*), ale z bardzo ważnym wyjątkiem :not().
 * Wykluczamy z działania wszystkie elementy wewnątrz naszego panelu.
 * To daje nam pewność, że wtyczka ZAWSZE będzie wyglądać normalnie.
*/
html.wcag-high-contrast body *:not(.wcag-panel-container *):not(path):not(svg *) {
    background-color: transparent !important;
    color: inherit !important; /* Dziedziczymy żółty kolor z body */
    border-color: #ffff00 !important;
    box-shadow: none !important;
}

/* Linki dla lepszej widoczności dostają inny, jasny kolor (cyjanowy) */
html.wcag-high-contrast body a:not(.wcag-panel-container *),
html.wcag-high-contrast body a:not(.wcag-panel-container *):link,
html.wcag-high-contrast body a:not(.wcag-panel-container *):visited {
    color: #00ffff !important; /* Jaskrawy cyjanowy */
}

/* Przyciski i pola formularzy muszą mieć widoczne tło i ramki */
html.wcag-high-contrast body button:not(.wcag-panel-container *),
html.wcag-high-contrast body input:not(.wcag-panel-container *),
html.wcag-high-contrast body select:not(.wcag-panel-container *),
html.wcag-high-contrast body textarea:not(.wcag-panel-container *) {
    background-color: #000 !important;
    color: #ffff00 !important;
    border: 2px solid #00ffff !important;
}

/* Obrazki i multimedia są odwracane, aby ciemne elementy stały się jasne */
html.wcag-high-contrast img,
html.wcag-high-contrast video {
    filter: invert(1) hue-rotate(180deg);
}


/* --- PODKREŚLANIE LINKÓW --- */
body.wcag-underline-links a:not([class*="button"]) { /* Wykluczamy linki-przyciski */
    text-decoration: underline !important;
    text-decoration-thickness: 2px !important;
    text-underline-offset: 3px;
}