/* ============================================
   Styles d'Accessibilité (A11y)
   Mayram Fashion House
   ============================================ */

/* Conformité WCAG 2.1 AA */

/* ============================================
   1. SKIP TO MAIN CONTENT
   ============================================ */

.skip-to-main {
    position: absolute;
    top: -100px;
    left: 0;
    background: var(--primary-color, #1a1a1a);
    color: white;
    padding: 1rem 2rem;
    text-decoration: none;
    font-weight: 600;
    z-index: 10000;
    border-radius: 0 0 4px 0;
    transition: top 0.3s ease;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
}

.skip-to-main:focus {
    top: 0;
    outline: 3px solid var(--secondary-color, #d4af37);
    outline-offset: 2px;
}

/* ============================================
   2. SCREEN READER ONLY
   ============================================ */

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

.sr-only-focusable:active,
.sr-only-focusable:focus {
    position: static;
    width: auto;
    height: auto;
    overflow: visible;
    clip: auto;
    white-space: normal;
}

/* ============================================
   3. FOCUS VISIBLE
   ============================================ */

/* Focus outline cohérent pour tous les éléments interactifs */
a:focus,
button:focus,
input:focus,
select:focus,
textarea:focus,
[tabindex]:focus {
    outline: 3px solid var(--secondary-color, #d4af37);
    outline-offset: 2px;
}

/* Focus visible uniquement au clavier (pas au clic souris) */
a:focus:not(:focus-visible),
button:focus:not(:focus-visible),
input:focus:not(:focus-visible),
select:focus:not(:focus-visible),
textarea:focus:not(:focus-visible) {
    outline: none;
}

a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
    outline: 3px solid var(--secondary-color, #d4af37);
    outline-offset: 2px;
}

/* ============================================
   4. CONTRASTE COULEURS (WCAG AA)
   ============================================ */

/* Boutons secondaires - amélioration contraste */
.btn-secondary {
    background: #475569;
    color: white;
    border-color: #475569;
}

.btn-secondary:hover {
    background: #334155;
    border-color: #334155;
}

/* Texte secondaire - contraste amélioré */
.text-secondary,
.product-creator,
.creator-specialty,
.creator-location {
    color: #475569;
}

/* Liens - contraste suffisant */
a {
    color: #1a56db; /* Ratio 4.5:1 sur fond blanc */
}

a:hover {
    color: #1e429f;
}

/* Badges - contraste amélioré */
.badge {
    font-weight: 600;
}

.badge-success {
    background: #047857; /* Vert foncé */
    color: white;
}

.badge-warning {
    background: #d97706; /* Orange foncé */
    color: white;
}

.badge-danger {
    background: #dc2626; /* Rouge */
    color: white;
}

.badge-info {
    background: #0369a1; /* Bleu foncé */
    color: white;
}

/* Placeholders - contraste suffisant */
::placeholder {
    color: #6b7280; /* Ratio 4.5:1 */
    opacity: 1;
}

/* ============================================
   5. NAVIGATION CLAVIER
   ============================================ */

/* Indicateurs de focus renforcés pour la navigation */
.navbar .nav-link:focus {
    background: rgba(212, 175, 55, 0.1);
    outline: 3px solid var(--secondary-color);
    outline-offset: -3px;
}

/* Focus sur les cards */
.product-card:focus-within,
.creator-card:focus-within {
    outline: 3px solid var(--secondary-color);
    outline-offset: 2px;
    box-shadow: 0 8px 20px rgba(212, 175, 55, 0.3);
}

/* Focus sur les boutons de formulaire */
.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    border-color: var(--secondary-color);
    box-shadow: 0 0 0 3px rgba(212, 175, 55, 0.2);
}

/* ============================================
   6. TAILLE MINIMALE DES CIBLES
   ============================================ */

/* Cibles tactiles minimum 44x44px (WCAG 2.1 AA) */
button,
.btn,
a.btn,
input[type="submit"],
input[type="button"],
.favorite-toggle,
.pagination a {
    min-height: 44px;
    min-width: 44px;
    padding: 0.5rem 1rem;
}

/* Icônes interactives */
.icon-button,
.social-link,
.favorite-toggle {
    min-width: 44px;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* ============================================
   7. STATES VISUELS
   ============================================ */

/* Disabled state */
button:disabled,
input:disabled,
select:disabled,
textarea:disabled,
.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

/* Required fields */
input:required,
select:required,
textarea:required {
    border-left: 3px solid #d97706;
}

input:required:valid {
    border-left-color: #047857;
}

input:required:invalid:not(:placeholder-shown) {
    border-left-color: #dc2626;
}

/* ============================================
   8. MODALS & DIALOGS
   ============================================ */

/* Modal accessible avec focus trap */
.modal[role="dialog"] {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 9999;
    background: rgba(0, 0, 0, 0.75);
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background: white;
    padding: 2rem;
    border-radius: 8px;
    max-width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
}

.modal-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    min-width: 44px;
    min-height: 44px;
    border: none;
    background: transparent;
    cursor: pointer;
    font-size: 1.5rem;
}

.modal-close:hover,
.modal-close:focus {
    color: var(--secondary-color);
}

/* ============================================
   9. TABLES RESPONSIVE & ACCESSIBLE
   ============================================ */

/* Wrapper pour tables responsive */
.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

table {
    width: 100%;
    border-collapse: collapse;
}

/* Headers accessibles */
th {
    text-align: left;
    font-weight: 600;
    padding: 0.75rem;
    background: #f3f4f6;
    border-bottom: 2px solid #e5e7eb;
}

td {
    padding: 0.75rem;
    border-bottom: 1px solid #e5e7eb;
}

/* Focus sur les lignes de table */
tr:focus-within {
    background: rgba(212, 175, 55, 0.05);
    outline: 2px solid var(--secondary-color);
    outline-offset: -2px;
}

/* ============================================
   10. MESSAGES D'ERREUR & VALIDATION
   ============================================ */

/* Messages d'erreur accessibles */
.error-message {
    color: #dc2626;
    font-size: 0.875rem;
    margin-top: 0.25rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.error-message::before {
    content: "⚠";
    font-weight: bold;
}

.success-message {
    color: #047857;
    font-size: 0.875rem;
    margin-top: 0.25rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.success-message::before {
    content: "✓";
    font-weight: bold;
}

/* ============================================
   11. ANIMATIONS RESPECTUEUSES
   ============================================ */

/* Respecter la préférence utilisateur pour mouvement réduit */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* ============================================
   12. DARK MODE ACCESSIBLE
   ============================================ */

/* Contraste suffisant en mode sombre */
[data-theme="dark"] a {
    color: #60a5fa; /* Bleu clair avec bon contraste */
}

[data-theme="dark"] .text-secondary {
    color: #9ca3af;
}

[data-theme="dark"] .btn-secondary {
    background: #64748b;
    color: white;
}

[data-theme="dark"] .form-input,
[data-theme="dark"] .form-select,
[data-theme="dark"] .form-textarea {
    border-color: #4b5563;
}

[data-theme="dark"] .form-input:focus,
[data-theme="dark"] .form-select:focus,
[data-theme="dark"] .form-textarea:focus {
    border-color: var(--secondary-color);
}

/* ============================================
   13. PRINT STYLES ACCESSIBLES
   ============================================ */

@media print {
    /* Afficher les URLs des liens */
    a[href]:after {
        content: " (" attr(href) ")";
        font-size: 0.8em;
        color: #666;
    }
    
    /* Ne pas afficher les URLs pour les ancres */
    a[href^="#"]:after {
        content: "";
    }
    
    /* Forcer le noir et blanc pour meilleure lisibilité */
    * {
        color: #000 !important;
        background: #fff !important;
        box-shadow: none !important;
        text-shadow: none !important;
    }
    
    /* Pages orphelines */
    h1, h2, h3 {
        page-break-after: avoid;
    }
    
    img {
        page-break-inside: avoid;
    }
}

/* ============================================
   14. UTILITIES
   ============================================ */

/* Visually hidden but accessible to screen readers */
.visually-hidden {
    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;
}

/* Focus indicator for keyboard navigation */
.focus-ring:focus {
    outline: 3px solid var(--secondary-color);
    outline-offset: 2px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    * {
        border-color: currentColor;
    }
    
    button,
    .btn {
        border: 2px solid currentColor;
    }
}

/* ============================================
   15. RESPONSIVE TEXT
   ============================================ */

/* Tailles de texte adaptées et lisibles */
body {
    font-size: 16px; /* Minimum recommandé */
    line-height: 1.5; /* WCAG recommande 1.5 */
}

h1 {
    font-size: 2.5rem;
    line-height: 1.2;
}

h2 {
    font-size: 2rem;
    line-height: 1.3;
}

h3 {
    font-size: 1.5rem;
    line-height: 1.4;
}

p {
    max-width: 70ch; /* Largeur optimale pour lecture */
    line-height: 1.6;
}

/* Zoom texte jusqu'à 200% sans perte de contenu */
@media (min-width: 320px) {
    html {
        font-size: 16px;
    }
}

@media (min-width: 768px) {
    html {
        font-size: 17px;
    }
}

@media (min-width: 1024px) {
    html {
        font-size: 18px;
    }
}
