/* ===============================================
   TOPOCLIMB CH - ACCESSIBILITÉ ET RESPONSIVE
   WCAG 2.1 AA Compliant
   =============================================== */

/* ===== FOCUS VISIBLE ===== */
/* Focus visible amélioré pour la navigation clavier */
*:focus-visible {
    outline: 3px solid var(--primary-color, #3b4b9b);
    outline-offset: 2px;
    border-radius: 4px;
}

/* Focus pour les liens */
a:focus-visible {
    outline: 3px solid var(--primary-color, #3b4b9b);
    outline-offset: 2px;
    text-decoration: underline;
}

/* Focus pour les boutons */
button:focus-visible,
.btn:focus-visible {
    outline: 3px solid var(--primary-color, #3b4b9b);
    outline-offset: 2px;
    box-shadow: 0 0 0 4px rgba(59, 75, 155, 0.2);
}

/* Focus pour les formulaires */
input:focus-visible,
textarea:focus-visible,
select:focus-visible {
    outline: 3px solid var(--primary-color, #3b4b9b);
    outline-offset: 1px;
    border-color: var(--primary-color, #3b4b9b);
    box-shadow: 0 0 0 3px rgba(59, 75, 155, 0.1);
}

/* ===== SKIP LINKS ===== */
.skip-link {
    position: absolute;
    top: 10px;
    left: 10px;
    background: var(--primary-color, #3b4b9b);
    color: white;
    padding: 8px 16px;
    text-decoration: none;
    z-index: 10000;
    border-radius: 4px;
    font-weight: 600;
    transform: translateY(-200%);
    transition: transform 0.3s ease-in-out;
}

.skip-link:focus {
    transform: translateY(0);
}

/* ===== SCREEN READER ONLY ===== */
.sr-only, .visually-hidden {
    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:focus,
.sr-only-focusable:active {
    position: static;
    width: auto;
    height: auto;
    overflow: visible;
    clip: auto;
    white-space: normal;
}

/* ===== CONTRASTE AMÉLIORÉ ===== */
/* Assurer un contraste minimum de 4.5:1 */
.text-muted {
    color: #6c757d !important;
    /* Contraste 4.54:1 sur blanc */
}

.text-secondary {
    color: #4a5568 !important;
    /* Contraste 7.35:1 sur blanc */
}

/* Badge avec contraste amélioré */
.badge {
    font-weight: 600;
    /* Améliore la lisibilité */
}

.badge.bg-warning {
    color: #000 !important;
    /* Meilleur contraste sur fond jaune */
}

/* ===== RESPONSIVE MOBILE ===== */

/* Fix overflow horizontal */
body,
html {
    overflow-x: hidden;
    max-width: 100vw;
}

* {
    max-width: 100%;
}

/* Container responsive */
.container {
    padding-left: 1rem;
    padding-right: 1rem;
}

@media (max-width: 375px) {
    .container {
        padding-left: 0.75rem;
        padding-right: 0.75rem;
    }
}

@media (max-width: 320px) {
    .container {
        padding-left: 0.5rem;
        padding-right: 0.5rem;
    }
}

/* ===== NAVIGATION RESPONSIVE ===== */

/* Burger menu optimisé */
@media (max-width: 991px) {
    .navbar-toggler {
        border: none;
        padding: 0.5rem;
        margin: 0;
    }

    .navbar-toggler:focus-visible {
        outline: 3px solid rgba(255, 255, 255, 0.8);
        outline-offset: 2px;
    }

    .navbar-collapse {
        background: rgba(0, 0, 0, 0.95);
        margin: 0.5rem -1rem 0;
        padding: 1rem;
        border-radius: 8px;
    }

    .navbar-nav {
        gap: 0.5rem;
    }

    .nav-link {
        padding: 0.75rem 1rem !important;
        border-radius: 6px;
        transition: background-color 0.2s ease;
    }

    .nav-link:hover,
    .nav-link:focus {
        background: rgba(255, 255, 255, 0.1);
    }

    .dropdown-menu {
        background: rgba(20, 20, 20, 0.95);
        border: 1px solid rgba(255, 255, 255, 0.1);
        margin-top: 0.5rem;
    }

    .dropdown-item {
        color: rgba(255, 255, 255, 0.9);
        padding: 0.75rem 1rem;
    }

    .dropdown-item:hover,
    .dropdown-item:focus {
        background: rgba(255, 255, 255, 0.1);
        color: white;
    }
}

/* ===== TYPOGRAPHIE RESPONSIVE ===== */

@media (max-width: 768px) {
    h1 {
        font-size: 2rem;
    }

    h2 {
        font-size: 1.75rem;
    }

    h3 {
        font-size: 1.5rem;
    }

    h4 {
        font-size: 1.25rem;
    }

    h5 {
        font-size: 1.125rem;
    }
}

@media (max-width: 576px) {
    h1 {
        font-size: 1.75rem;
    }

    h2 {
        font-size: 1.5rem;
    }

    h3 {
        font-size: 1.25rem;
    }

    h4 {
        font-size: 1.125rem;
    }

    body {
        font-size: 0.9375rem;
    }
}

@media (max-width: 375px) {
    h1 {
        font-size: 1.5rem;
    }

    h2 {
        font-size: 1.375rem;
    }

    body {
        font-size: 0.875rem;
    }
}

/* ===== IMAGES RESPONSIVE ===== */

img {
    max-width: 100%;
    height: auto;
}

picture {
    display: block;
    max-width: 100%;
}

/* ===== TABLEAUX RESPONSIVE ===== */

@media (max-width: 768px) {
    .table-responsive {
        display: block;
        width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    table {
        font-size: 0.875rem;
    }
}

/* ===== BOUTONS RESPONSIVE ===== */

@media (max-width: 576px) {
    .btn {
        padding: 0.625rem 1rem;
        font-size: 0.875rem;
    }

    .btn-lg {
        padding: 0.75rem 1.25rem;
        font-size: 1rem;
    }

    .btn-sm {
        padding: 0.375rem 0.75rem;
        font-size: 0.8125rem;
    }

    /* Boutons empilés sur mobile */
    .btn-group-vertical-mobile {
        flex-direction: column;
        width: 100%;
    }

    .btn-group-vertical-mobile .btn {
        width: 100%;
        margin-bottom: 0.5rem;
    }
}

/* ===== CARTES RESPONSIVE ===== */

@media (max-width: 768px) {
    .card {
        margin-bottom: 1rem;
    }

    .card-body {
        padding: 1rem;
    }

    .card-header,
    .card-footer {
        padding: 0.75rem 1rem;
    }
}

@media (max-width: 576px) {
    .card-body {
        padding: 0.75rem;
    }

    .card-header,
    .card-footer {
        padding: 0.625rem 0.75rem;
    }
}

/* ===== MODALES RESPONSIVE ===== */

@media (max-width: 576px) {
    .modal-dialog {
        margin: 0.5rem;
    }

    .modal-content {
        border-radius: 8px;
    }

    .modal-body {
        padding: 1rem;
    }

    .modal-header,
    .modal-footer {
        padding: 0.75rem 1rem;
    }
}

/* ===== FORMULAIRES RESPONSIVE ===== */

@media (max-width: 576px) {
    .form-control,
    .form-select {
        font-size: 0.875rem;
        padding: 0.625rem 0.75rem;
    }

    .form-label {
        font-size: 0.875rem;
        margin-bottom: 0.375rem;
    }

    .input-group {
        flex-wrap: wrap;
    }
}

/* ===== NAVIGATION PAR CLAVIER ===== */

/* Indicateur de navigation clavier */
body.user-is-tabbing *:focus {
    outline: 3px solid var(--primary-color, #3b4b9b) !important;
    outline-offset: 2px !important;
}

/* États hover/focus cohérents */
a:hover,
a:focus-visible {
    color: var(--primary-dark, #5a67d8);
}

button:hover,
button:focus-visible,
.btn:hover,
.btn:focus-visible {
    transform: translateY(-1px);
    transition: all 0.2s ease;
}

/* ===== ANIMATIONS RESPECTUEUSES ===== */

/* Désactiver les animations si l'utilisateur préfère */
@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;
    }
}

/* ===== LOADING SPINNER ===== */

.spinner-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.9);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.spinner-overlay.active {
    display: flex;
}

.spinner {
    width: 48px;
    height: 48px;
    border: 4px solid rgba(59, 75, 155, 0.2);
    border-top-color: var(--primary-color, #3b4b9b);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Spinner inline pour boutons */
.btn-spinner {
    display: inline-block;
    width: 1rem;
    height: 1rem;
    border: 2px solid currentColor;
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-right: 0.5rem;
}

/* ===== TOAST NOTIFICATIONS AMÉLIORÉES ===== */

.toast-container {
    position: fixed;
    top: 80px;
    right: 1rem;
    z-index: 1055;
    max-width: 400px;
}

@media (max-width: 768px) {
    .toast-container {
        top: 70px;
        left: 1rem;
        right: 1rem;
        max-width: none;
    }
}

@media (max-width: 576px) {
    .toast-container {
        top: 60px;
        left: 0.5rem;
        right: 0.5rem;
    }
}

.toast {
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    margin-bottom: 0.75rem;
    border: none;
}

.toast-header {
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    font-weight: 600;
}

/* ===== CONFIRMATION DIALOGS ===== */

.confirm-dialog-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1060;
    padding: 1rem;
}

.confirm-dialog-overlay.active {
    display: flex;
}

.confirm-dialog {
    background: white;
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
    max-width: 500px;
    width: 100%;
    padding: 1.5rem;
    animation: scaleIn 0.2s ease-out;
}

@keyframes scaleIn {
    from {
        transform: scale(0.95);
        opacity: 0;
    }
    to {
        transform: scale(1);
        opacity: 1;
    }
}

.confirm-dialog-title {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: var(--text-primary, #2d3748);
}

.confirm-dialog-message {
    color: var(--text-secondary, #4a5568);
    margin-bottom: 1.5rem;
    line-height: 1.6;
}

.confirm-dialog-actions {
    display: flex;
    gap: 0.75rem;
    justify-content: flex-end;
}

@media (max-width: 576px) {
    .confirm-dialog {
        padding: 1.25rem;
    }

    .confirm-dialog-actions {
        flex-direction: column-reverse;
    }

    .confirm-dialog-actions .btn {
        width: 100%;
    }
}

/* ===== AMÉLIORATION DES DROPDOWNS ===== */

.dropdown-menu {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 8px;
    padding: 0.5rem 0;
}

.dropdown-item {
    padding: 0.625rem 1rem;
    transition: background-color 0.15s ease;
}

.dropdown-item:focus-visible {
    background-color: var(--primary-color, #3b4b9b);
    color: white;
    outline: none;
}

.dropdown-item:hover {
    background-color: rgba(59, 75, 155, 0.1);
}

.dropdown-header {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted, #6c757d);
    padding: 0.5rem 1rem 0.25rem;
}

/* ===== BREADCRUMBS ACCESSIBLES ===== */

.breadcrumb {
    padding: 0.75rem 1rem;
}

.breadcrumb-item + .breadcrumb-item::before {
    color: var(--text-muted, #6c757d);
}

.breadcrumb-item a:focus-visible {
    outline: 2px solid var(--primary-color, #3b4b9b);
    outline-offset: 2px;
    border-radius: 3px;
}

/* ===== PAGINATION ACCESSIBLE ===== */

.pagination .page-link {
    padding: 0.5rem 0.75rem;
    margin: 0 0.125rem;
    border-radius: 6px;
}

.pagination .page-link:focus-visible {
    outline: 2px solid var(--primary-color, #3b4b9b);
    outline-offset: 2px;
    z-index: 3;
}

.pagination .page-item.active .page-link {
    background-color: var(--primary-color, #3b4b9b);
    border-color: var(--primary-color, #3b4b9b);
}

/* ===== ACCORDÉONS ACCESSIBLES ===== */

.accordion-button {
    font-weight: 600;
}

.accordion-button:focus {
    border-color: var(--primary-color, #3b4b9b);
    box-shadow: 0 0 0 3px rgba(59, 75, 155, 0.2);
}

.accordion-button:not(.collapsed) {
    background-color: rgba(59, 75, 155, 0.1);
    color: var(--primary-color, #3b4b9b);
}

/* ===== UTILITAIRES TOUCH-FRIENDLY ===== */

/* Augmenter la zone tactile des éléments interactifs */
@media (pointer: coarse) {
    button,
    a,
    input[type="checkbox"],
    input[type="radio"],
    select {
        min-height: 44px;
        min-width: 44px;
    }

    .btn {
        padding: 0.75rem 1.25rem;
    }

    .nav-link {
        padding: 0.75rem 1rem;
    }
}

/* ===== DARK MODE SUPPORT ===== */

@media (prefers-color-scheme: dark) {
    /* Les variables seront gérées par le thème global */
    .confirm-dialog {
        background: #1a202c;
        color: #e2e8f0;
    }

    .confirm-dialog-title {
        color: #e2e8f0;
    }

    .confirm-dialog-message {
        color: #cbd5e0;
    }
}

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

@media print {
    .navbar,
    .footer,
    .btn,
    .modal,
    .toast,
    .alert,
    .skip-link {
        display: none !important;
    }

    a[href]:after {
        content: " (" attr(href) ")";
    }

    abbr[title]:after {
        content: " (" attr(title) ")";
    }
}

/* Ensure text in dropdown menu is readable in dark mode */
.theme-dark .dropdown-menu {
    background-color: #2b3035 !important;
}
.theme-dark .dropdown-menu .dropdown-item {
    color: #e9ecef !important;
}
.theme-dark .dropdown-menu .dropdown-item:hover {
    background-color: #343a40 !important;
    color: #fff !important;
}
.dropdown-menu {
    background-color: #fff !important;
}
.dropdown-menu .dropdown-item {
    color: #212529 !important;
}

/* Reduce motion based on user preference and general reduction of superfluous animations */
@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;
    }
}

/* Tone down general transitions for better performance and UX */
.btn, .card, .nav-link, a {
    transition: all 0.15s ease-in-out !important; /* Faster, more subtle */
}

/* Tone down hero and heavy animations */
.hero-modern, .fade-in, .slide-in-up {
    animation-duration: 0.3s !important; /* Faster */
    animation-timing-function: ease-out !important;
}

/* ===== LIENS DANS LES BLOCS DE TEXTE ===== */
p a:not(.btn):not(.nav-link):not(.text-decoration-none),
li a:not(.btn):not(.nav-link):not(.page-link):not(.text-decoration-none),
.text-block a:not(.btn):not(.nav-link):not(.text-decoration-none),
.breadcrumbs a:not(.btn):not(.nav-link):not(.text-decoration-none) {
    text-decoration: underline;
    text-underline-offset: 2px;
}

p a:not(.btn):not(.nav-link):not(.text-decoration-none):hover,
li a:not(.btn):not(.nav-link):not(.page-link):not(.text-decoration-none):hover,
.text-block a:not(.btn):not(.nav-link):not(.text-decoration-none):hover,
.breadcrumbs a:not(.btn):not(.nav-link):not(.text-decoration-none):hover {
    text-decoration: underline;
    text-decoration-thickness: 2px;
}

/* ===============================================
   HERO SECTION - AMÉLIORATION DU CONTRASTE ET ACCESSIBILITÉ
   WCAG 2.1 AA Compliant (Contraste 4.5:1 / 3.1)
   =============================================== */

/* Garantie de lisibilité du texte sur fond gradient/image */
.hero-modern {
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
}

.hero-modern h1 {
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.6);
}

/* Annulation de l'ombre sur les boutons pour la clarté */
.hero-modern .btn {
    text-shadow: none;
}

/* Focus visible garanti sur fond sombre (Hero) */
.hero-modern .btn:focus-visible {
    outline: 3px solid #ffcc00 !important;
    outline-offset: 2px;
    box-shadow: 0 0 0 4px rgba(0, 0, 0, 0.5);
}

/* Contraste forcé pour les boutons transparents au hover/active */
.hero-modern .btn-outline-light:hover,
.hero-modern .btn-outline-light:active {
    background-color: #ffffff !important;
    color: #212529 !important; /* Force un texte sombre sur fond clair */
    border-color: #ffffff !important;
}

/* Réduction stricte des animations et scroll parallax pour l'accessibilité */
@media (prefers-reduced-motion: reduce) {
    .hero-modern,
    .hero-modern .fade-in,
    .hero-modern .slide-in-up,
    .hero-modern .hero-content {
        animation: none !important;
        transform: none !important;
        transition: none !important;
        opacity: 1 !important;
    }
}
