/* Enhanced Multi-Language Styling - Phase 5 */

/* Enhanced Language Switcher */
.lang-switcher-enhanced {
    position: relative;
    display: inline-block;
}

.lang-trigger {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    background: var(--bg-primary);
    border: 2px solid var(--border-color);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    font-weight: 500;
    min-height: 44px;
    color: var(--text-secondary);
}

.lang-trigger:hover,
.lang-trigger:focus {
    border-color: var(--primary);
    background: var(--primary-light);
    outline: none;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(196, 30, 58, 0.15);
}

.lang-trigger[aria-expanded="true"] {
    border-color: var(--primary);
    background: var(--primary-light);
}

.lang-flag {
    font-size: 1.25rem;
    line-height: 1;
}

.lang-name {
    font-size: 0.875rem;
    font-weight: 500;
}

.lang-arrow {
    font-size: 0.75rem;
    transition: transform 0.3s ease;
    margin-left: 0.25rem;
}

.lang-trigger[aria-expanded="true"] .lang-arrow {
    transform: rotate(180deg);
}

/* Language Dropdown */
.lang-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--bg-primary);
    border: 2px solid var(--primary);
    border-top: none;
    border-radius: 0 0 12px 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 1000;
    overflow: hidden;
    min-width: 200px;
}

.lang-dropdown.open {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.lang-option {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    width: 100%;
    padding: 0.875rem 1rem;
    background: none;
    border: none;
    cursor: pointer;
    transition: all 0.3s ease;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border-color);
}

.lang-option:last-child {
    border-bottom: none;
}

.lang-option:hover,
.lang-option:focus {
    background: var(--primary-light);
    color: var(--primary);
    outline: none;
}

.lang-option.active {
    background: var(--primary-light);
    color: var(--primary);
    font-weight: 600;
}

.lang-info {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    flex: 1;
}

.lang-region {
    font-size: 0.75rem;
    opacity: 0.7;
}

.lang-check {
    color: var(--success);
    font-weight: 700;
}

/* Language Loading State */
.language-loading {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(5px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    animation: fadeIn 0.3s ease;
}

.language-loading .loading-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--gray-200);
    border-top: 4px solid var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 1rem;
}

.language-loading p {
    color: var(--text-muted);
    font-weight: 500;
}

/* Language Suggestion Banner */
.language-suggestion {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    padding: 1rem;
    z-index: 9999;
    box-shadow: 0 4px 20px rgba(196, 30, 58, 0.3);
    animation: slideInDown 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.suggestion-content {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 1rem;
}

.suggestion-content p {
    margin: 0;
    font-weight: 500;
}

.suggestion-actions {
    display: flex;
    gap: 0.75rem;
}

.btn-switch,
.btn-dismiss {
    padding: 0.5rem 1rem;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.1);
    color: white;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 500;
    font-size: 0.875rem;
}

.btn-switch:hover,
.btn-dismiss:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.5);
    transform: translateY(-1px);
}

.btn-switch {
    background: rgba(255, 255, 255, 0.2);
}

/* Language Preferences Panel */
.language-preferences {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 1.5rem;
    margin: 1rem 0;
}

.language-preferences h3 {
    color: var(--text-secondary);
    font-size: 1.125rem;
    margin: 0 0 1.5rem 0;
    font-weight: 600;
}

.preference-group {
    margin: 1rem 0;
}

.preference-group label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-secondary);
    font-weight: 500;
    cursor: pointer;
}

.preference-group input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--primary);
}

.preference-group select {
    padding: 0.5rem;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    background: var(--bg-primary);
    color: var(--text-secondary);
    margin-left: 0.5rem;
}

/* RTL Layout Support */
.rtl-layout {
    direction: rtl;
}

.rtl-layout .lang-dropdown {
    left: auto;
    right: 0;
}

.rtl-layout .lang-arrow {
    margin-left: 0;
    margin-right: 0.25rem;
}

.rtl-layout .suggestion-content {
    text-align: right;
}

.rtl-layout .lang-info {
    align-items: flex-end;
}

/* Content Localization */
.localized-content {
    transition: opacity 0.3s ease;
}

.localized-content.loading {
    opacity: 0.5;
}

/* Number and Date Formatting */
[data-number],
[data-date],
[data-currency] {
    font-variant-numeric: tabular-nums;
}

/* Language-specific Typography */
:lang(fr) {
    quotes: "« " " »";
}

:lang(en) {
    quotes: """ """;
}

/* High Contrast Mode */
@media (prefers-contrast: high) {
    .lang-trigger,
    .lang-option {
        border-width: 3px;
    }

    .lang-trigger:focus,
    .lang-option:focus {
        outline: 3px solid currentColor;
        outline-offset: 2px;
    }
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .lang-switcher-enhanced {
        width: 100%;
    }

    .lang-trigger {
        width: 100%;
        justify-content: space-between;
    }

    .lang-dropdown {
        left: 0;
        right: 0;
        min-width: auto;
    }

    .suggestion-content {
        flex-direction: column;
        text-align: center;
    }

    .suggestion-actions {
        width: 100%;
        justify-content: center;
    }

    .btn-switch,
    .btn-dismiss {
        flex: 1;
        text-align: center;
    }

    .language-preferences {
        padding: 1rem;
    }

    .preference-group {
        margin: 0.75rem 0;
    }

    .preference-group label {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }

    .preference-group select {
        margin-left: 0;
        width: 100%;
    }
}

/* Print Styles */
@media print {
    .lang-switcher-enhanced,
    .language-suggestion,
    .language-loading {
        display: none !important;
    }
}

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
    .lang-trigger,
    .lang-dropdown,
    .language-preferences {
        background: var(--bg-primary);
        border-color: var(--border-color);
    }

    .lang-option {
        border-color: var(--border-color);
    }

    .language-loading {
        background: rgba(15, 23, 42, 0.9);
    }

    .language-loading .loading-spinner {
        border-color: var(--gray-600);
        border-top-color: var(--primary);
    }
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes slideInDown {
    from {
        opacity: 0;
        transform: translateY(-100%);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }
    100% {
        transform: rotate(360deg);
    }
}

/* Language-specific Flags */
.lang-flag {
    display: inline-block;
    width: 24px;
    height: 18px;
    background-size: cover;
    background-position: center;
    border-radius: 2px;
    flex-shrink: 0;
}

/* Alternative flag display for better accessibility */
@media (prefers-reduced-motion: reduce) {
    .lang-dropdown,
    .language-loading,
    .language-suggestion {
        animation: none;
        transition: none;
    }

    .lang-trigger[aria-expanded="true"] .lang-arrow {
        transform: none;
    }
}

/* Focus Management */
.lang-option:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: -2px;
}

.lang-trigger:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

/* Language Badge */
.lang-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.25rem 0.5rem;
    background: var(--primary-light);
    color: var(--primary);
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* Content Translation Indicator */
.translation-indicator {
    position: absolute;
    top: -8px;
    right: -8px;
    width: 16px;
    height: 16px;
    background: var(--success);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.6rem;
    font-weight: 700;
}

.translation-indicator::after {
    content: '✓';
}