/**
 * Barrierefreiheits-Assistent - Accessibility Widget
 * WCAG 2.1 konform
 */

/* ===== Accessibility Toggle Button ===== */
.a11y-toggle {
    position: fixed;
    right: 20px;
    bottom: 100px;
    width: 56px;
    height: 56px;
    background: linear-gradient(135deg, #0066cc 0%, #004499 100%);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    z-index: 99998;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 20px rgba(0, 102, 204, 0.4);
    transition: all 0.3s ease;
}

.a11y-toggle:hover,
.a11y-toggle:focus {
    transform: scale(1.1);
    box-shadow: 0 6px 25px rgba(0, 102, 204, 0.5);
    outline: 3px solid #fff;
    outline-offset: 2px;
}

.a11y-toggle svg {
    width: 28px;
    height: 28px;
    fill: #fff;
}

.a11y-toggle .a11y-label {
    position: absolute;
    right: 70px;
    background: #333;
    color: #fff;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 14px;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.a11y-toggle:hover .a11y-label,
.a11y-toggle:focus .a11y-label {
    opacity: 1;
    visibility: visible;
}

/* ===== Accessibility Panel ===== */
.a11y-panel {
    position: fixed;
    right: 20px;
    bottom: 170px;
    width: 340px;
    max-height: calc(100vh - 200px);
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 10px 50px rgba(0, 0, 0, 0.2);
    z-index: 99999;
    overflow: hidden;
    transform: translateY(20px);
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.a11y-panel.active {
    transform: translateY(0);
    opacity: 1;
    visibility: visible;
}

.a11y-panel-header {
    background: linear-gradient(135deg, #0066cc 0%, #004499 100%);
    color: #fff;
    padding: 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.a11y-panel-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 10px;
}

.a11y-panel-header h3 svg {
    width: 24px;
    height: 24px;
    fill: currentColor;
}

.a11y-panel-close {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.a11y-panel-close:hover,
.a11y-panel-close:focus {
    background: rgba(255, 255, 255, 0.3);
    outline: 2px solid #fff;
}

.a11y-panel-close svg {
    width: 16px;
    height: 16px;
    fill: #fff;
}

.a11y-panel-body {
    padding: 20px;
    max-height: calc(100vh - 250px);
    overflow-y: auto;
}

/* ===== Option Groups ===== */
.a11y-group {
    margin-bottom: 20px;
}

.a11y-group:last-child {
    margin-bottom: 0;
}

.a11y-group-title {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #666;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid #eee;
}

/* ===== Option Items ===== */
.a11y-option {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px;
    background: #f8f9fa;
    border-radius: 10px;
    margin-bottom: 8px;
    transition: all 0.2s ease;
}

.a11y-option:hover {
    background: #e9ecef;
}

.a11y-option:last-child {
    margin-bottom: 0;
}

.a11y-option-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.a11y-option-icon {
    width: 40px;
    height: 40px;
    background: #fff;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.a11y-option-icon svg {
    width: 20px;
    height: 20px;
    fill: #0066cc;
}

.a11y-option-text h4 {
    margin: 0 0 2px 0;
    font-size: 14px;
    font-weight: 600;
    color: #333;
}

.a11y-option-text p {
    margin: 0;
    font-size: 11px;
    color: #888;
}

/* ===== Toggle Switch ===== */
.a11y-switch {
    position: relative;
    width: 48px;
    height: 26px;
}

.a11y-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.a11y-switch-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: #ccc;
    border-radius: 26px;
    transition: all 0.3s ease;
}

.a11y-switch-slider:before {
    position: absolute;
    content: "";
    height: 20px;
    width: 20px;
    left: 3px;
    bottom: 3px;
    background: #fff;
    border-radius: 50%;
    transition: all 0.3s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.a11y-switch input:checked + .a11y-switch-slider {
    background: #0066cc;
}

.a11y-switch input:checked + .a11y-switch-slider:before {
    transform: translateX(22px);
}

.a11y-switch input:focus + .a11y-switch-slider {
    box-shadow: 0 0 0 3px rgba(0, 102, 204, 0.3);
}

/* ===== Slider Control ===== */
.a11y-slider-control {
    display: flex;
    align-items: center;
    gap: 8px;
}

.a11y-slider-control button {
    width: 28px;
    height: 28px;
    border: 1px solid #ddd;
    background: #fff;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    font-weight: 600;
    color: #333;
    transition: all 0.2s ease;
}

.a11y-slider-control button:hover {
    background: #0066cc;
    border-color: #0066cc;
    color: #fff;
}

.a11y-slider-control button:focus {
    outline: 2px solid #0066cc;
    outline-offset: 2px;
}

.a11y-slider-value {
    min-width: 40px;
    text-align: center;
    font-size: 14px;
    font-weight: 600;
    color: #333;
}

/* ===== Reset Button ===== */
.a11y-reset {
    width: 100%;
    padding: 14px;
    background: #f8f9fa;
    border: 2px dashed #ddd;
    border-radius: 10px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    color: #666;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-top: 15px;
}

.a11y-reset:hover {
    background: #fff3cd;
    border-color: #ffc107;
    color: #856404;
}

.a11y-reset:focus {
    outline: 2px solid #0066cc;
    outline-offset: 2px;
}

.a11y-reset svg {
    width: 18px;
    height: 18px;
    fill: currentColor;
}

/* ===== Accessibility Mode Classes ===== */

/* Schriftgröße */
html.a11y-font-size-1 { font-size: 100%; }
html.a11y-font-size-2 { font-size: 112.5%; }
html.a11y-font-size-3 { font-size: 125%; }
html.a11y-font-size-4 { font-size: 137.5%; }
html.a11y-font-size-5 { font-size: 150%; }

/* Hoher Kontrast */
body.a11y-high-contrast {
    filter: contrast(1.25);
}

body.a11y-high-contrast * {
    border-color: #000 !important;
}

/* Invertierte Farben */
body.a11y-invert-colors {
    filter: invert(1) hue-rotate(180deg);
}

body.a11y-invert-colors img,
body.a11y-invert-colors video,
body.a11y-invert-colors iframe {
    filter: invert(1) hue-rotate(180deg);
}

/* Graustufen */
body.a11y-grayscale {
    filter: grayscale(1);
}

/* Links hervorheben */
body.a11y-highlight-links a {
    background: #ff0 !important;
    color: #000 !important;
    padding: 2px 4px !important;
    text-decoration: underline !important;
    font-weight: bold !important;
}

/* Überschriften hervorheben */
body.a11y-highlight-headings h1,
body.a11y-highlight-headings h2,
body.a11y-highlight-headings h3,
body.a11y-highlight-headings h4,
body.a11y-highlight-headings h5,
body.a11y-highlight-headings h6 {
    background: #0ff !important;
    color: #000 !important;
    padding: 4px 8px !important;
}

/* Große Cursor */
body.a11y-big-cursor,
body.a11y-big-cursor * {
    cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='48' height='48' viewBox='0 0 24 24'%3E%3Cpath fill='%23000' stroke='%23fff' stroke-width='1' d='M5 3l14 9-7 2-4 7-3-18z'/%3E%3C/svg%3E"), auto !important;
}

/* Lesehilfe / Leselineal */
body.a11y-reading-guide .a11y-reading-line {
    display: block !important;
}

.a11y-reading-line {
    display: none;
    position: fixed;
    left: 0;
    right: 0;
    height: 40px;
    background: rgba(255, 255, 0, 0.3);
    border-top: 2px solid #ff0;
    border-bottom: 2px solid #ff0;
    pointer-events: none;
    z-index: 99990;
    transition: top 0.05s ease;
}

/* Animationen stoppen */
body.a11y-stop-animations,
body.a11y-stop-animations * {
    animation: none !important;
    transition: none !important;
}

/* Dyslexie-freundliche Schrift */
body.a11y-dyslexia-font {
    font-family: 'OpenDyslexic', 'Comic Sans MS', sans-serif !important;
}

body.a11y-dyslexia-font * {
    font-family: inherit !important;
    letter-spacing: 0.05em !important;
    word-spacing: 0.1em !important;
    line-height: 1.8 !important;
}

/* Zeilenabstand erhöhen */
body.a11y-line-height * {
    line-height: 2 !important;
}

/* Wortabstand erhöhen */
body.a11y-word-spacing * {
    word-spacing: 0.2em !important;
}

/* Text ausrichten (linksbündig für bessere Lesbarkeit) */
body.a11y-text-align-left * {
    text-align: left !important;
}

/* Fokus-Indikator verstärken */
body.a11y-focus-indicator *:focus {
    outline: 4px solid #ff0 !important;
    outline-offset: 4px !important;
    box-shadow: 0 0 0 6px rgba(0, 0, 0, 0.8) !important;
}

/* Tastaturnavigation sichtbar */
body.a11y-keyboard-nav *:focus {
    outline: 3px dashed #0066cc !important;
    outline-offset: 3px !important;
}

/* ===== Mobile Responsive ===== */
@media (max-width: 768px) {
    .a11y-toggle {
        right: 10px;
        bottom: 60px;
        width: 40px;
        height: 40px;
    }
    
    .a11y-toggle svg {
        width: 20px;
        height: 20px;
    }
    
    .a11y-panel {
        left: 8px;
        right: 8px;
        bottom: 110px;
        width: auto;
        max-height: calc(100vh - 130px);
        border-radius: 16px;
    }
    
    .a11y-panel-header {
        padding: 15px;
    }
    
    .a11y-panel-header h3 {
        font-size: 16px;
    }
    
    .a11y-panel-body {
        padding: 15px;
        max-height: calc(100vh - 200px);
    }
    
    .a11y-toggle .a11y-label {
        display: none;
    }
}

/* ===== Print Styles ===== */
@media print {
    .a11y-toggle,
    .a11y-panel,
    .a11y-reading-line {
        display: none !important;
    }
}

/* ===== Reduced Motion Preference ===== */
@media (prefers-reduced-motion: reduce) {
    .a11y-toggle,
    .a11y-panel,
    .a11y-switch-slider,
    .a11y-switch-slider:before {
        transition: none;
    }
}

/* ===== High Contrast Mode Preference ===== */
@media (prefers-contrast: high) {
    .a11y-panel {
        border: 3px solid #000;
    }
    
    .a11y-option {
        border: 1px solid #333;
    }
}

/* ===== Scrollbar für Panel ===== */
.a11y-panel-body::-webkit-scrollbar {
    width: 6px;
}

.a11y-panel-body::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.a11y-panel-body::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 3px;
}

.a11y-panel-body::-webkit-scrollbar-thumb:hover {
    background: #999;
}
