/* =========================================
   CORREZIONI CONTRASTO - TravellingFox
   Fix specifici per i problemi evidenziati
   ========================================= */

/* --- CORREZIONI PULSANTE AREA PERSONALE --- */
/* Problema: bg-primary con hover:bg-orange-50 hover:text-primary */

.area-personale-btn,
button[class*="bg-primary"][class*="hover:bg-orange-50"] {
    /* Sfondo più contrastante */
    background-color: #014177 !important; /* blue-700 invece di bg-primary */
    color: #ffffff !important;
    border: 2px solid #014177 !important;
    font-weight: 600;
    transition: all 0.2s ease;
}

.area-personale-btn:hover,
button[class*="bg-primary"][class*="hover:bg-orange-50"]:hover {
    /* Hover con contrasto 7:1 */
    background-color: #ffffff !important;
    color: #014177 !important; /* Contrasto 12.6:1 */
    border-color: #014177 !important;
}

.area-personale-btn:focus,
button[class*="bg-primary"][class*="hover:bg-orange-50"]:focus {
    outline: 3px solid #fbbf24 !important; /* yellow-400 per focus visibile */
    outline-offset: 2px;
    box-shadow: 0 0 0 6px rgba(251, 191, 36, 0.2) !important;
}

/* --- CORREZIONI PULSANTE "SCOPRI LE DESTINAZIONI" --- */
/* Problema: bg-primary text-white con hover poco contrastante */

.hero-btn-primary,
a[class*="bg-primary"][class*="text-white"],
button[class*="bg-primary"][class*="text-white"] {
    /* Arancione più scuro per contrasto 4.7:1 */
    background-color: #c2410c !important; /* orange-700 */
    color: #ffffff !important;
    border: 2px solid #c2410c !important;
    font-weight: 700;
    padding: 0.875rem 1.5rem;
    font-size: 1.125rem; /* text-lg */
    transition: all 0.2s ease;
}

.hero-btn-primary:hover,
a[class*="bg-primary"][class*="text-white"]:hover,
button[class*="bg-primary"][class*="text-white"]:hover {
    /* Hover ancora più scuro per contrasto 6.1:1 */
    background-color: #9a3412 !important; /* orange-800 */
    border-color: #9a3412 !important;
    transform: translateY(-2px);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.2) !important;
}

.hero-btn-primary:focus,
a[class*="bg-primary"][class*="text-white"]:focus,
button[class*="bg-primary"][class*="text-white"]:focus {
    outline: 3px solid #fed7aa !important; /* orange-200 */
    outline-offset: 2px;
    box-shadow: 0 0 0 6px rgba(254, 215, 170, 0.3) !important;
}

/* --- CORREZIONI PULSANTE "RICHIEDI INFO" --- */
/* Problema: bg-white text-primary con hover:bg-gray poco contrastante */

.hero-btn-secondary,
a[class*="bg-white"][class*="text-primary"],
button[class*="bg-white"][class*="text-primary"] {
    /* Sfondo bianco con testo più scuro */
    background-color: #ffffff !important;
    color: #014177 !important; /* blue-700 per contrasto 12.6:1 */
    border: 3px solid #014177 !important; /* Bordo più spesso e scuro */
    font-weight: 700;
    padding: 0.875rem 1.5rem;
    border-radius: 0.375rem;
    font-size: 1.125rem;
    transition: all 0.2s ease;
}

.hero-btn-secondary:hover,
a[class*="bg-white"][class*="text-primary"]:hover,
button[class*="bg-white"][class*="text-primary"]:hover {
    /* Hover con sfondo scuro per contrasto 21:1 */
    background-color: #014177 !important; /* blue-700 */
    color: #ffffff !important;
    border-color: #014177 !important;
    transform: translateY(-2px);
    box-shadow: 0 4px 6px -1px rgba(30, 64, 175, 0.3) !important;
}

.hero-btn-secondary:focus,
a[class*="bg-white"][class*="text-primary"]:focus,
button[class*="bg-white"][class*="text-primary"]:focus {
    outline: 3px solid #fbbf24 !important; /* yellow-400 */
    outline-offset: 2px;
    box-shadow: 0 0 0 6px rgba(251, 191, 36, 0.2) !important;
}

/* --- CORREZIONI GENERALI PER CLASSI PERSONALIZZATE --- */

/* Fix per bg-primary generico */
.bg-primary,
[class*="bg-primary"]:not([class*="hover"]) {
    background-color: #014177 !important; /* blue-700 */
}

/* Fix per text-primary generico */
.text-primary,
[class*="text-primary"]:not([class*="hover"]) {
    color: #014177 !important; /* blue-700 */
}

/* Fix per hover:text-primary */
[class*="hover:text-primary"]:hover {
    color: #014177 !important; /* blue-700 */
}

/* Fix per hover:bg-orange-50 per garantire contrasto */
[class*="hover:bg-orange-50"]:hover {
    background-color: #ffffff !important;
}

/* --- CORREZIONI PER STATI FOCUS VISIBILI --- */

/* Focus generale per tutti i pulsanti */
button:focus,
a[role="button"]:focus,
.btn:focus {
    outline: 3px solid #fbbf24 !important; /* yellow-400 */
    outline-offset: 2px !important;
    box-shadow: 0 0 0 6px rgba(251, 191, 36, 0.2) !important;
}

/* --- CORREZIONI PER HIGH CONTRAST MODE --- */
@media (prefers-contrast: high) {
    .area-personale-btn,
    .hero-btn-primary,
    .hero-btn-secondary,
    button[class*="bg-primary"],
    a[class*="bg-primary"] {
        border-width: 3px !important;
        font-weight: 700 !important;
    }

    .area-personale-btn {
        background-color: #000000 !important;
        color: #ffffff !important;
        border-color: #ffffff !important;
    }

    .area-personale-btn:hover {
        background-color: #ffffff !important;
        color: #000000 !important;
        border-color: #000000 !important;
    }

    .hero-btn-primary {
        background-color: #000000 !important;
        color: #ffffff !important;
        border-color: #ffffff !important;
    }

    .hero-btn-primary:hover {
        background-color: #ffffff !important;
        color: #000000 !important;
        border-color: #000000 !important;
    }

    .hero-btn-secondary {
        background-color: #ffffff !important;
        color: #000000 !important;
        border-color: #000000 !important;
    }

    .hero-btn-secondary:hover {
        background-color: #000000 !important;
        color: #ffffff !important;
        border-color: #ffffff !important;
    }
}

/* --- CORREZIONI PER FORCED COLORS MODE (Windows High Contrast) --- */
@media (forced-colors: active) {
    .area-personale-btn,
    .hero-btn-primary,
    .hero-btn-secondary,
    button[class*="bg-primary"],
    a[class*="bg-primary"] {
        background-color: ButtonFace !important;
        color: ButtonText !important;
        border: 2px solid ButtonBorder !important;
    }

    .area-personale-btn:hover,
    .hero-btn-primary:hover,
    .hero-btn-secondary:hover,
    button[class*="bg-primary"]:hover,
    a[class*="bg-primary"]:hover {
        background-color: Highlight !important;
        color: HighlightText !important;
        border-color: Highlight !important;
    }

    .area-personale-btn:focus,
    .hero-btn-primary:focus,
    .hero-btn-secondary:focus,
    button[class*="bg-primary"]:focus,
    a[class*="bg-primary"]:focus {
        outline: 2px solid ButtonText !important;
        outline-offset: 2px !important;
    }
}

/* --- CORREZIONI MOBILE per TOUCH TARGETS --- */
@media (max-width: 768px) {
    .area-personale-btn,
    .hero-btn-primary,
    .hero-btn-secondary,
    button[class*="bg-primary"],
    a[class*="bg-primary"] {
        /* Touch target minimo 44px x 44px */
        min-height: 44px !important;
        min-width: 44px !important;
        padding: 0.75rem 1.5rem !important;
    }
}

/* --- TEST HELPERS (rimuovi in produzione) --- */

/* Classe helper per testare i contrasti */
.contrast-test {
    position: relative;
}

.contrast-test::after {
    content: "Contrasto: " attr(data-contrast-ratio);
    position: absolute;
    top: -25px;
    left: 0;
    font-size: 11px;
    background: #000;
    color: #fff;
    padding: 2px 4px;
    border-radius: 2px;
    opacity: 0;
    transition: opacity 0.2s;
}

.contrast-test:hover::after {
    opacity: 1;
}

/* --- UTILITIES per DEBUGGING CONTRASTI --- */
@media screen and (min-width: 1px) {
    /* Mostra bordi rossi per elementi con potenziali problemi di contrasto */
    .debug-contrast [class*="bg-primary"],
    .debug-contrast [class*="text-primary"] {
        box-shadow: 0 0 0 2px red !important;
    }

    /* Mostra bordi verdi per elementi corretti */
    .debug-contrast .hero-btn-primary,
    .debug-contrast .hero-btn-secondary,
    .debug-contrast .area-personale-btn {
        box-shadow: 0 0 0 2px green !important;
    }
}

/* Per attivare il debug, aggiungi classe 'debug-contrast' al body */
.sr-only {
            position: absolute;
            width: 1px;
            height: 1px;
            padding: 0;
            margin: -1px;
            overflow: hidden;
            clip: rect(0, 0, 0, 0);
            white-space: nowrap;
            border: 0;
        }

        .sr-only.focus:not-sr-only {
            position: static;
            width: auto;
            height: auto;
            padding: inherit;
            margin: inherit;
            overflow: visible;
            clip: auto;
            white-space: normal;
        }

        /* Supporto per alto contrasto */
        @media (prefers-contrast: high) {
            .bg-gradient-to-r,
            .bg-gradient-to-br {
                background: #000 !important;
                color: #fff !important;
            }
        }

        /* Supporto per movimento ridotto */
        @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;
            }
        }

        /* Indicatori di focus migliorati */
        *:focus {
            outline: 2px solid #FF6B35;
            outline-offset: 2px;
        }
