/**
 * Internationalization (i18n) Styles
 * Supports RTL and proper fonts for Arabic, Persian, Turkish, and English
 */

/* Import Google Fonts for RTL languages */
@import url('https://fonts.googleapis.com/css2?family=Cairo:wght@400;600;700&family=Vazirmatn:wght@400;600;700&display=swap');

/* RTL Support */
html[dir="rtl"] {
    direction: rtl;
}

html[dir="rtl"] body {
    direction: rtl;
    text-align: right;
}

html[dir="ltr"] {
    direction: ltr;
}

html[dir="ltr"] body {
    direction: ltr;
    text-align: left;
}

/* Font Families */
.lang-fa,
html[lang="fa"] {
    font-family: 'Vazirmatn', 'Tahoma', 'Arial', sans-serif !important;
}

.lang-ar,
html[lang="ar"] {
    font-family: 'Cairo', 'Arial', sans-serif !important;
}

.lang-tr,
html[lang="tr"] {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', sans-serif !important;
}

.lang-en,
html[lang="en"] {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', sans-serif !important;
}

/* RTL Layout Adjustments */
html[dir="rtl"] .header-left {
    flex-direction: row-reverse;
}

html[dir="rtl"] .header-right {
    flex-direction: row-reverse;
}

html[dir="rtl"] .nav-link {
    margin-left: 0;
    margin-right: 0.5rem;
}

/* Language Selector */
.language-selector {
    position: relative;
    display: inline-block;
}

.language-selector .current-lang:hover {
    background: rgba(255, 255, 255, 0.1);
}

.language-selector .lang-option:hover {
    background: rgba(255, 255, 255, 0.1) !important;
}

/* RTL adjustments for language selector */
html[dir="rtl"] .language-selector .lang-dropdown {
    left: auto;
    right: 0;
}

/* Text alignment in RTL */
html[dir="rtl"] .text-left {
    text-align: right !important;
}

html[dir="rtl"] .text-right {
    text-align: left !important;
}

html[dir="rtl"] .text-center {
    text-align: center !important;
}

/* Form elements in RTL */
html[dir="rtl"] input,
html[dir="rtl"] textarea,
html[dir="rtl"] select {
    text-align: right;
    direction: rtl;
}

html[dir="rtl"] input[type="number"] {
    direction: ltr; /* Numbers stay LTR */
    text-align: left;
}

html[dir="rtl"] input[type="number"] + span {
    direction: rtl;
}

/* Table adjustments */
html[dir="rtl"] table {
    direction: rtl;
}

html[dir="rtl"] th,
html[dir="rtl"] td {
    text-align: right;
}

/* Modal and dropdown positioning */
html[dir="rtl"] .modal,
html[dir="rtl"] .dropdown {
    text-align: right;
}

html[dir="rtl"] .modal-header {
    flex-direction: row-reverse;
}

html[dir="rtl"] .modal-footer {
    flex-direction: row-reverse;
}

/* Button groups in RTL */
html[dir="rtl"] .button-group {
    flex-direction: row-reverse;
}

html[dir="rtl"] .btn-group {
    flex-direction: row-reverse;
}

/* Card content alignment */
html[dir="rtl"] .card,
html[dir="rtl"] .panel {
    text-align: right;
}

/* Lists */
html[dir="rtl"] ul,
html[dir="rtl"] ol {
    padding-right: 1.5rem;
    padding-left: 0;
}

/* Icon and text spacing */
html[dir="rtl"] .icon-text {
    flex-direction: row-reverse;
}

html[dir="rtl"] .icon-left {
    margin-left: 0.5rem;
    margin-right: 0;
}

html[dir="rtl"] .icon-right {
    margin-right: 0.5rem;
    margin-left: 0;
}

/* Float adjustments */
html[dir="rtl"] .float-left {
    float: right !important;
}

html[dir="rtl"] .float-right {
    float: left !important;
}

/* Margin and padding utilities for RTL */
html[dir="rtl"] .ml-auto {
    margin-left: 0 !important;
    margin-right: auto !important;
}

html[dir="rtl"] .mr-auto {
    margin-right: 0 !important;
    margin-left: auto !important;
}

html[dir="rtl"] .pl-0 {
    padding-left: 0 !important;
    padding-right: 0 !important;
}

html[dir="rtl"] .pr-0 {
    padding-right: 0 !important;
    padding-left: 0 !important;
}

/* Flag display */
.flag-icon {
    display: inline-block;
    font-size: 1.2em;
    vertical-align: middle;
    margin: 0 0.25em;
}

/* Ensure proper number formatting */
.number {
    direction: ltr;
    display: inline-block;
}

/* Currency symbols in RTL */
html[dir="rtl"] .currency::before {
    content: '';
}

html[dir="rtl"] .currency::after {
    content: attr(data-currency);
}

/* Tooltip positioning in RTL */
html[dir="rtl"] .tooltip {
    left: auto;
    right: 50%;
    transform: translateX(50%);
}

/* Responsive adjustments for RTL */
@media (max-width: 768px) {
    html[dir="rtl"] .header-content {
        flex-direction: column-reverse;
    }
    
    html[dir="rtl"] .mobile-menu-toggle {
        left: auto;
        right: 1rem;
    }
}

/* Animation for language change */
* {
    transition: font-family 0.3s ease;
}

/* Ensure proper spacing in RTL */
html[dir="rtl"] .space-between {
    flex-direction: row-reverse;
}

/* Loading spinner direction */
html[dir="rtl"] .spinner {
    animation-direction: reverse;
}

