/**
 * Layer 11: Multi-Language & Localization Styles
 * Includes language selector and RTL support
 */

/* Language Selector */
.language-selector {
    position: relative;
    display: inline-block;
}

.lang-current {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: var(--color-light, #ffffff);
    border: 1px solid var(--color-border, #e0e0e0);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 0.9rem;
}

.lang-current:hover {
    background: var(--color-light-secondary, #f5f5f5);
    border-color: var(--color-primary, #667eea);
}

.lang-flag {
    font-size: 1.2rem;
}

.lang-name {
    font-weight: 500;
}

.lang-arrow {
    font-size: 0.7rem;
    transition: transform 0.3s ease;
}

.lang-current:hover .lang-arrow {
    transform: translateY(2px);
}

/* Language Dropdown */
.lang-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 0.5rem;
    background: white;
    border: 1px solid var(--color-border, #e0e0e0);
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    min-width: 200px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.3s ease;
    z-index: 1000;
}

.lang-dropdown.active {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.lang-option {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    cursor: pointer;
    transition: background 0.2s ease;
}

.lang-option:hover {
    background: var(--color-light-secondary, #f5f5f5);
}

.lang-option.active {
    background: var(--color-primary-light, #e8ebfc);
    color: var(--color-primary, #667eea);
    font-weight: 500;
}

.lang-option:first-child {
    border-radius: 8px 8px 0 0;
}

.lang-option:last-child {
    border-radius: 0 0 8px 8px;
}

/* RTL Support */
html[dir="rtl"] {
    direction: rtl;
}

html[dir="rtl"] body {
    text-align: right;
}

/* RTL Navigation */
html[dir="rtl"] .nav-menu {
    flex-direction: row-reverse;
}

html[dir="rtl"] .nav-link {
    padding-right: 0;
    padding-left: 1rem;
}

/* RTL Buttons */
html[dir="rtl"] .btn {
    text-align: right;
}

/* RTL Forms */
html[dir="rtl"] input,
html[dir="rtl"] textarea,
html[dir="rtl"] select {
    text-align: right;
}

/* RTL Lists */
html[dir="rtl"] ul,
html[dir="rtl"] ol {
    padding-right: 1.5rem;
    padding-left: 0;
}

/* RTL Images */
html[dir="rtl"] .img-left {
    float: right;
    margin-left: 1rem;
    margin-right: 0;
}

html[dir="rtl"] .img-right {
    float: left;
    margin-right: 1rem;
    margin-left: 0;
}

/* RTL Icons */
html[dir="rtl"] .icon-left {
    margin-left: 0.5rem;
    margin-right: 0;
}

html[dir="rtl"] .icon-right {
    margin-right: 0.5rem;
    margin-left: 0;
}

/* RTL Arrows */
html[dir="rtl"] .arrow-right::after {
    content: "←";
}

html[dir="rtl"] .arrow-left::after {
    content: "→";
}

/* RTL Dropdown */
html[dir="rtl"] .lang-dropdown {
    left: 0;
    right: auto;
}

/* RTL Grid */
html[dir="rtl"] .grid {
    direction: rtl;
}

/* RTL Flex */
html[dir="rtl"] .flex-row {
    flex-direction: row-reverse;
}

/* Language-specific Fonts */
html[lang="ar"] {
    font-family: 'Tajawal', 'Arabic UI Text', Arial, sans-serif;
}

html[lang="zh"] {
    font-family: 'Noto Sans SC', 'Microsoft YaHei', Arial, sans-serif;
}

html[lang="ja"] {
    font-family: 'Noto Sans JP', 'Yu Gothic', Arial, sans-serif;
}

/* Mobile Language Selector */
@media (max-width: 768px) {
    .lang-dropdown {
        right: 0;
        left: auto;
        min-width: 180px;
    }

    html[dir="rtl"] .lang-dropdown {
        left: 0;
        right: auto;
    }

    .lang-current {
        padding: 0.4rem 0.8rem;
        font-size: 0.85rem;
    }

    .lang-name {
        display: none;
    }

    .lang-flag {
        font-size: 1.1rem;
    }
}

/* Accessibility */
.lang-option:focus,
.lang-current:focus {
    outline: 2px solid var(--color-primary, #667eea);
    outline-offset: 2px;
}

/* Animation */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.lang-dropdown.active {
    animation: fadeIn 0.3s ease;
}

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
    .lang-current {
        background: #2d3748;
        border-color: #4a5568;
        color: #e2e8f0;
    }

    .lang-current:hover {
        background: #374151;
        border-color: #667eea;
    }

    .lang-dropdown {
        background: #2d3748;
        border-color: #4a5568;
    }

    .lang-option:hover {
        background: #374151;
    }

    .lang-option.active {
        background: #4c51bf;
        color: #e2e8f0;
    }
}