/* ==========================================================================
   GearGen-3D Language Switcher & Full RTL Stylesheet
   EN, FR, AR with Automatic Direction Inversion
   ========================================================================== */

/* Language Switcher Component */
.language-switcher {
    position: relative;
    display: inline-block;
    user-select: none;
}

.language-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 0.825rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.language-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--border-focus);
}

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

.language-btn .fa-chevron-down {
    font-size: 0.65rem;
    color: var(--text-secondary);
    transition: transform var(--transition-fast);
}

.language-switcher.active .language-btn .fa-chevron-down {
    transform: rotate(180deg);
}

/* Language Dropdown */
.language-dropdown {
    display: none;
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    background: var(--background-panel);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-xl);
    min-width: 140px;
    padding: 4px;
    z-index: 1000;
}

.language-switcher.active .language-dropdown {
    display: block;
    animation: fadeInLang 0.12s ease-out;
}

@keyframes fadeInLang {
    from { opacity: 0; transform: translateY(-4px); }
    to { opacity: 1; transform: translateY(0); }
}

.language-option {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 0.825rem;
    cursor: pointer;
    transition: background var(--transition-fast);
}

.language-option:hover {
    background: rgba(255, 255, 255, 0.08);
}

.language-option.active {
    background: rgba(59, 130, 246, 0.15);
    color: var(--accent-primary);
    font-weight: 600;
}

.language-option .lang-flag {
    font-size: 1.1rem;
}

.language-option .lang-name {
    flex: 1;
}

/* ==========================================================================
   Full RTL (Right-to-Left) Mode for Arabic (dir="rtl")
   ========================================================================== */
html[dir="rtl"] {
    text-align: right;
    direction: rtl;
}

/* Invert Header Flow */
html[dir="rtl"] .top-bar-left {
    flex-direction: row;
}

html[dir="rtl"] .branding {
    flex-direction: row;
}

html[dir="rtl"] .menu-bar {
    flex-direction: row;
}

html[dir="rtl"] .menu-dropdown {
    left: auto;
    right: 0;
}

html[dir="rtl"] .menu-item {
    text-align: right;
    flex-direction: row-reverse;
}

html[dir="rtl"] .language-dropdown {
    right: auto;
    left: 0;
}

/* Invert 3-Panel Workspace in Desktop */
@media (min-width: 1024px) {
    html[dir="rtl"] .workspace-layout {
        grid-template-columns: var(--right-sidebar-width) 1fr var(--left-sidebar-width);
    }

    /* Keep left_sidebar (gear selector) on left side of the DOM flow or order */
    html[dir="rtl"] #left_sidebar {
        order: 3;
    }

    html[dir="rtl"] #center_viewport {
        order: 2;
    }

    html[dir="rtl"] #right_sidebar {
        order: 1;
    }
}

/* Invert Mesh Statistics Overlay */
html[dir="rtl"] .mesh-statistics-overlay {
    left: auto;
    right: 14px;
}

/* Invert Cards & Elements */
html[dir="rtl"] .gear-card-top {
    flex-direction: row-reverse;
}

html[dir="rtl"] .gear-card-icon-title {
    flex-direction: row;
}

html[dir="rtl"] .group-header {
    flex-direction: row-reverse;
}

html[dir="rtl"] .group-title {
    flex-direction: row;
}

html[dir="rtl"] .parameter-header {
    flex-direction: row-reverse;
}

html[dir="rtl"] .parameter-controls-row {
    flex-direction: row-reverse;
}

html[dir="rtl"] .input-stepper-group {
    flex-direction: row-reverse;
}

html[dir="rtl"] .preset-chips {
    flex-direction: row;
}

html[dir="rtl"] .kpi-row {
    flex-direction: row-reverse;
}

html[dir="rtl"] .modal-header {
    flex-direction: row-reverse;
}

html[dir="rtl"] .modal-header h2 {
    flex-direction: row;
}

html[dir="rtl"] .toast {
    flex-direction: row-reverse;
}

html[dir="rtl"] .toast-container {
    right: auto;
    left: 24px;
}
