/**
 * Granatello - Language Switcher Styles
 * Stili per i pulsanti di cambio lingua IT/EN
 * Integrazione con il design gold/black esistente
 */

/* Container dei pulsanti lingua */
.language-switcher {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: 24px;
    position: relative;
}

/* Pulsanti lingua */
.language-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border: 2px solid transparent;
    border-radius: 8px;
    background: transparent;
    color: #9ca3af;
    font-weight: 600;
    font-size: 14px;
    letter-spacing: 0.5px;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

/* Hover effect */
.language-btn:hover {
    color: #D4AF37;
    border-color: rgba(212, 175, 55, 0.3);
    background: rgba(212, 175, 55, 0.1);
    transform: translateY(-2px);
}

/* Stato attivo */
.language-btn.active {
    color: #000000;
    background: linear-gradient(135deg, #D4AF37, #B8941F);
    border-color: #D4AF37;
    box-shadow: 0 4px 12px rgba(212, 175, 55, 0.3);
}

/* Stato inattivo */
.language-btn.inactive {
    color: #6b7280;
    background: transparent;
    border-color: rgba(107, 114, 128, 0.2);
}

.language-btn.inactive:hover {
    color: #D4AF37;
    border-color: rgba(212, 175, 55, 0.3);
    background: rgba(212, 175, 55, 0.05);
}

/* Effetto ripple */
.language-btn::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(212, 175, 55, 0.3);
    transform: translate(-50%, -50%);
    transition: width 0.3s, height 0.3s;
}

.language-btn:active::after {
    width: 100px;
    height: 100px;
}

/* Separatore tra i pulsanti */
.language-separator {
    width: 1px;
    height: 20px;
    background: rgba(156, 163, 175, 0.3);
    margin: 0 4px;
}

/* Indicatore lingua attiva */
.language-indicator {
    position: absolute;
    bottom: -8px;
    left: 50%;
    transform: translateX(-50%);
    width: 20px;
    height: 2px;
    background: #D4AF37;
    border-radius: 1px;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.language-btn.active .language-indicator {
    opacity: 1;
}

/* Tooltip lingua */
.language-btn[data-tooltip]::before {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.9);
    color: #D4AF37;
    padding: 6px 10px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 500;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    pointer-events: none;
    margin-bottom: 8px;
    border: 1px solid rgba(212, 175, 55, 0.2);
}

.language-btn[data-tooltip]:hover::before {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(-4px);
}

/* Freccia del tooltip */
.language-btn[data-tooltip]::after {
    content: '';
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    border-top: 5px solid rgba(0, 0, 0, 0.9);
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    pointer-events: none;
    margin-bottom: 3px;
}

.language-btn[data-tooltip]:hover::after {
    opacity: 1;
    visibility: visible;
}

/* Animazione di switch */
@keyframes languageSwitch {
    0% { transform: scale(1) rotate(0deg); }
    50% { transform: scale(1.1) rotate(180deg); }
    100% { transform: scale(1) rotate(360deg); }
}

.language-btn.switching {
    animation: languageSwitch 0.6s ease-in-out;
}

/* Responsive Design */
@media (max-width: 1024px) {
    .language-switcher {
        margin-left: 16px;
        gap: 6px;
    }
    
    .language-btn {
        width: 36px;
        height: 36px;
        font-size: 13px;
    }
    
    .language-separator {
        height: 18px;
    }
}

@media (max-width: 768px) {
    .language-switcher {
        margin-left: 12px;
        gap: 4px;
    }
    
    .language-btn {
        width: 34px;
        height: 34px;
        font-size: 12px;
        border-radius: 6px;
    }
    
    /* Nascondi tooltip su mobile */
    .language-btn[data-tooltip]::before,
    .language-btn[data-tooltip]::after {
        display: none;
    }
}

@media (max-width: 640px) {
    .language-switcher {
        margin-left: 8px;
    }
    
    .language-btn {
        width: 32px;
        height: 32px;
        font-size: 11px;
    }
    
    .language-separator {
        height: 16px;
        margin: 0 2px;
    }
}

/* Dark mode compatibility */
@media (prefers-color-scheme: dark) {
    .language-btn.inactive {
        color: #9ca3af;
        border-color: rgba(156, 163, 175, 0.3);
    }
    
    .language-separator {
        background: rgba(156, 163, 175, 0.4);
    }
}

/* High contrast mode */
@media (prefers-contrast: high) {
    .language-btn {
        border-width: 3px;
    }
    
    .language-btn.active {
        border-color: #D4AF37;
        box-shadow: 0 0 0 2px rgba(212, 175, 55, 0.5);
    }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
    .language-btn,
    .language-btn::after,
    .language-indicator,
    .language-btn[data-tooltip]::before,
    .language-btn[data-tooltip]::after {
        transition: none;
    }
    
    .language-btn.switching {
        animation: none;
    }
    
    .language-btn:hover {
        transform: none;
    }
}

/* Focus accessibility */
.language-btn:focus {
    outline: 2px solid #D4AF37;
    outline-offset: 2px;
}

.language-btn:focus:not(:focus-visible) {
    outline: none;
}

.language-btn:focus-visible {
    outline: 2px solid #D4AF37;
    outline-offset: 2px;
}

/* Print styles */
@media print {
    .language-switcher {
        display: none;
    }
}

/* Compatibilità cross-browser migliorata */

/* Webkit/Blink browsers (Chrome, Safari, Edge) */
@supports (-webkit-appearance: none) {
    .language-btn:hover {
        -webkit-transform: translateY(-2px);
    }
    
    .language-btn::after {
        -webkit-border-radius: 50%;
        -webkit-transform: translate(-50%, -50%);
        -webkit-transition: width 0.3s, height 0.3s;
    }
}

/* Firefox specific */
@-moz-document url-prefix() {
    .language-btn {
        -moz-user-select: none;
    }
}

/* Internet Explorer/Edge legacy */
@media all and (-ms-high-contrast: none), (-ms-high-contrast: active) {
    .language-btn {
        display: inline-block;
        vertical-align: middle;
    }
    
    .language-switcher {
        display: inline-block;
    }
}

/* Safari iOS specific fixes */
@supports (-webkit-touch-callout: none) {
    .language-btn {
        -webkit-tap-highlight-color: transparent;
        -webkit-touch-callout: none;
        -webkit-user-select: none;
    }
}

/* Android Chrome specific */
@media screen and (-webkit-device-pixel-ratio: 1) {
    .language-btn:active {
        background-color: rgba(212, 175, 55, 0.2);
    }
}

/* Touch device optimizations */
@media (pointer: coarse) {
    .language-btn {
        min-width: 44px;
        min-height: 44px;
    }
    
    .language-btn:hover {
        transform: none; /* Disable transform on touch devices */
    }
    
    .language-btn:active {
        transform: scale(0.95);
        transition: transform 0.1s ease;
    }
}

/* Modern browser with backdrop-filter support */
@supports (backdrop-filter: blur(10px)) {
    .language-btn:hover {
        backdrop-filter: blur(10px);
    }
}

/* Fallback per browser senza backdrop-filter */
@supports not (backdrop-filter: blur(10px)) {
    .language-btn:hover {
        background: rgba(212, 175, 55, 0.15);
    }
}

/* Custom properties per personalizzazione */
:root {
    --language-gold: #D4AF37;
    --language-gold-dark: #B8941F;
    --language-text-inactive: #6b7280;
    --language-text-hover: #D4AF37;
    --language-bg-hover: rgba(212, 175, 55, 0.1);
    --language-border-hover: rgba(212, 175, 55, 0.3);
    --language-shadow-active: rgba(212, 175, 55, 0.3);
}

/* Browser compatibility fallbacks per CSS custom properties */
.language-btn {
    color: #6b7280; /* Fallback */
    color: var(--language-text-inactive);
}

.language-btn:hover {
    color: #D4AF37; /* Fallback */
    color: var(--language-text-hover);
    background: rgba(212, 175, 55, 0.1); /* Fallback */
    background: var(--language-bg-hover);
    border-color: rgba(212, 175, 55, 0.3); /* Fallback */
    border-color: var(--language-border-hover);
}

.language-btn.active {
    background: linear-gradient(135deg, #D4AF37, #B8941F); /* Fallback */
    background: linear-gradient(135deg, var(--language-gold), var(--language-gold-dark));
    box-shadow: 0 4px 12px rgba(212, 175, 55, 0.3); /* Fallback */
    box-shadow: 0 4px 12px var(--language-shadow-active);
}