/**
 * Energy Life Accessibility CSS
 * Ergänzende Styles für optimale Barrierefreiheit
 */

/* ===================================
   SCREEN READER ONLY TEXT
   =================================== */

.sr-only {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
}

/* Screen reader text that becomes visible on focus */
.sr-only-focusable:focus,
.sr-only-focusable:active {
    position: static !important;
    width: auto !important;
    height: auto !important;
    padding: inherit !important;
    margin: inherit !important;
    overflow: visible !important;
    clip: auto !important;
    white-space: inherit !important;
}

/* ===================================
   SKIP LINKS
   =================================== */

.skip-link {
    position: absolute;
    top: -40px;
    left: 6px;
    background: #000;
    color: #fff;
    padding: 8px 16px;
    text-decoration: none;
    border-radius: 4px;
    z-index: 9999;
    font-weight: bold;
    font-size: 14px;
    transition: top 0.2s ease-in-out;
}

.skip-link:focus {
    top: 6px;
    outline: 2px solid #fff;
    outline-offset: 2px;
}

/* ===================================
   FOCUS STYLES
   =================================== */

/* Verbesserte Fokus-Sichtbarkeit für alle interaktiven Elemente */
a:focus,
button:focus,
input:focus,
select:focus,
textarea:focus,
[tabindex]:focus {
    outline: 2px solid #0066cc !important;
    outline-offset: 2px !important;
    background-color: rgba(0, 102, 204, 0.1) !important;
}

/* Spezielle Fokus-Styles für Produktbilder */
.produkt_abbildung:focus,
a[href*="PRODUKT_LINK"]:focus img,
a[href*="PRODUKT_LINK"]:focus .produkt_abbildung {
    outline: 3px solid #0066cc !important;
    outline-offset: 3px !important;
}

/* Warenkorb-Button Fokus */
button[style*="warenkorb"]:focus,
a[href*="warenkorb"]:focus {
    outline: 2px solid #28a745 !important;
    outline-offset: 2px !important;
    background-color: rgba(40, 167, 69, 0.1) !important;
}

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

@media (prefers-contrast: high) {
    a:focus,
    button:focus,
    input:focus,
    select:focus,
    textarea:focus {
        outline: 3px solid #fff !important;
        background-color: #000 !important;
        color: #fff !important;
    }
    
    .skip-link {
        background: #fff !important;
        color: #000 !important;
        border: 2px solid #000 !important;
    }
}

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

@media (prefers-reduced-motion: reduce) {
    /* Animationen für bewegungsempfindliche Nutzer deaktivieren */
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
    
    .skip-link {
        transition: none !important;
    }
}

/* ===================================
   TEMPLATE-SPEZIFISCHE VERBESSERUNGEN
   =================================== */

/* Produktliste Container */
#produktliste {
    /* Bessere Struktur für Screenreader */
}

#produktliste h1,
#produktliste h2,
#produktliste h3 {
    /* Produkttitel hervorheben */
    font-weight: bold;
    margin-bottom: 0.5em;
}

/* Preisinformationen strukturieren */
#produktliste_preis,
.produktliste_preis {
    /* Preisbereich klar abgrenzen */
    border-left: 3px solid #e9ecef;
    padding-left: 10px;
    margin: 10px 0;
}

.preis {
    font-weight: bold;
    font-size: 1.2em;
}

.uvp {
    text-decoration: line-through;
    color: #6c757d;
}

.grundpreis {
    font-size: 0.9em;
    color: #6c757d;
}

/* Rabatt-Badges */
.rabatt_produktliste,
.rabatt_detailansicht {
    /* Bessere Lesbarkeit */
    background-color: #dc3545;
    color: #fff;
    font-weight: bold;
    padding: 2px 6px;
    border-radius: 3px;
    display: inline-block;
}

/* ===================================
   BUTTON VERBESSERUNGEN
   =================================== */

/* Alle Buttons sollten klar als solche erkennbar sein */
button,
.button_details,
a[href*="warenkorb"] {
    cursor: pointer;
    border: 1px solid transparent;
    border-radius: 4px;
    padding: 6px 12px;
    display: inline-block;
    text-decoration: none;
}

/* Hover-Effekte für bessere Usability */
button:hover,
.button_details:hover,
a[href*="warenkorb"]:hover {
    opacity: 0.8;
    transform: translateY(-1px);
    transition: all 0.2s ease;
}

@media (prefers-reduced-motion: reduce) {
    button:hover,
    .button_details:hover,
    a[href*="warenkorb"]:hover {
        transform: none !important;
        transition: none !important;
    }
}

/* ===================================
   FORM IMPROVEMENTS
   =================================== */

/* Formulare besser strukturieren */
form[id*="ARTIKEL"] {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 10px;
}

/* Hidden inputs sollten wirklich unsichtbar sein */
input[type="hidden"] {
    display: none !important;
}

/* Select-Felder verbessern */
select {
    border: 1px solid #ced4da;
    border-radius: 4px;
    padding: 6px 12px;
    background-color: #fff;
    font-size: 14px;
}

select:focus {
    border-color: #0066cc;
    box-shadow: 0 0 0 0.2rem rgba(0, 102, 204, 0.25);
}

/* ===================================
   RESPONSIVE IMPROVEMENTS
   =================================== */

/* Mobile Optimierungen */
@media (max-width: 768px) {
    .skip-link {
        left: 4px;
        right: 4px;
        text-align: center;
    }
    
    /* Größere Touch-Targets für mobile Geräte */
    button,
    a[href],
    .button_details {
        min-height: 44px;
        min-width: 44px;
        padding: 12px;
    }
    
    /* Fokus-Outlines auf mobilen Geräten weniger störend */
    @media (hover: none) and (pointer: coarse) {
        *:focus {
            outline-width: 1px !important;
        }
    }
}

/* ===================================
   PRINT STYLES
   =================================== */

@media print {
    .skip-link,
    .sr-only {
        display: none !important;
    }
    
    a[href]:after {
        content: " (" attr(href) ")";
        font-size: 0.8em;
        color: #666;
    }
    
    a[href^="javascript:"]:after,
    a[href^="#"]:after {
        content: "";
    }
}

/* ===================================
   BROWSER-SPEZIFISCHE FIXES
   =================================== */

/* Internet Explorer 11 */
@media screen and (-ms-high-contrast: active) {
    .skip-link {
        background: ButtonText !important;
        color: ButtonFace !important;
        border: 1px solid ButtonText !important;
    }
}

/* Safari spezifische Verbesserungen */
@supports (-webkit-appearance: none) {
    select {
        -webkit-appearance: none;
        background-image: url('data:image/svg+xml;charset=US-ASCII,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 4 5"><path fill="%23666" d="M2 0L0 2h4zm0 5L0 3h4z"/></svg>');
        background-repeat: no-repeat;
        background-position: right 8px center;
        background-size: 12px;
        padding-right: 30px;
    }
}

/* ===================================
   UTILITY CLASSES
   =================================== */

/* Für temporäres Ausblenden ohne Screenreader zu beeinträchtigen */
.visually-hidden {
    clip: rect(0 0 0 0);
    clip-path: inset(50%);
    height: 1px;
    overflow: hidden;
    position: absolute;
    white-space: nowrap;
    width: 1px;
}

/* Für Elemente die nur für Screenreader sichtbar sein sollen */
.screenreader-only {
    position: absolute !important;
    left: -10000px !important;
    width: 1px !important;
    height: 1px !important;
    overflow: hidden !important;
}

/* Focus trap für Modals/Overlays */
.focus-trap {
    position: relative;
}

.focus-trap::before,
.focus-trap::after {
    content: '';
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
    pointer-events: none;
}

/* ===================================
   ANIMATION SAFE DEFAULTS
   =================================== */

/* Sanfte Übergänge nur wenn keine Bewegungsreduzierung gewünscht */
@media (prefers-reduced-motion: no-preference) {
    .skip-link {
        transition: top 0.2s ease-in-out;
    }
    
    button,
    a[href] {
        transition: all 0.2s ease;
    }
}