/* Multilingual Support CSS */
/* This file handles dynamic RTL/LTR switching and language-specific fonts */

/* Base font families for each language */
:root {
    --font-persian: "Vazirmatn", "Segoe UI", sans-serif;
    --font-english: "Inter", "Roboto", "Open Sans", sans-serif;
    --font-chinese: "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;
}

/* Language-specific font families */
html[lang="fa"], html[lang="fa-IR"] {
    font-family: var(--font-persian);
}

html[lang="en"], html[lang="en-US"] {
    font-family: var(--font-english);
}

html[lang="zh"], html[lang="zh-CN"] {
    font-family: var(--font-chinese);
}

/* RTL Support */
html[dir="rtl"] {
    direction: rtl;
    text-align: right;
}

html[dir="ltr"] {
    direction: ltr;
    text-align: left;
}

/* Bootstrap RTL adjustments */
html[dir="rtl"] .navbar .navbar-collapse {
    text-align: right;
}

html[dir="rtl"] .navbar .navbar-nav.ms-auto {
    margin-left: 0;
    margin-right: auto;
}

html[dir="rtl"] .form-control,
html[dir="rtl"] .form-select {
    text-align: right;
}

html[dir="rtl"] .form-check {
    padding-right: 1.25rem;
    padding-left: 0;
}

html[dir="rtl"] .form-check .form-check-input {
    float: right;
    margin-left: .5rem;
    margin-right: 0;
}

/* Card and list alignment for RTL */
html[dir="rtl"] .card-header,
html[dir="rtl"] .list-group-item {
    text-align: right;
}

/* Margin adjustments for RTL */
html[dir="rtl"] .ms-2 {
    margin-right: .5rem !important;
    margin-left: 0 !important;
}

html[dir="rtl"] .me-2 {
    margin-left: .5rem !important;
    margin-right: 0 !important;
}

html[dir="rtl"] .ms-3 {
    margin-right: 1rem !important;
    margin-left: 0 !important;
}

html[dir="rtl"] .me-3 {
    margin-left: 1rem !important;
    margin-right: 0 !important;
}

/* Toast container positioning for RTL */
html[dir="rtl"] .toast-container.bottom-0.end-0 {
    right: auto;
    left: 0;
}

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

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

/* Button group alignment */
html[dir="rtl"] .btn-group > .btn:not(:last-child):not(.dropdown-toggle) {
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
    border-top-left-radius: .375rem;
    border-bottom-left-radius: .375rem;
}

html[dir="rtl"] .btn-group > .btn:not(:first-child) {
    margin-left: 0;
    margin-right: -1px;
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
    border-top-right-radius: .375rem;
    border-bottom-right-radius: .375rem;
}

/* Input group adjustments */
html[dir="rtl"] .input-group > .form-control:not(:last-child),
html[dir="rtl"] .input-group > .form-select:not(:last-child) {
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
    border-top-left-radius: .375rem;
    border-bottom-left-radius: .375rem;
}

html[dir="rtl"] .input-group > .form-control:not(:first-child),
html[dir="rtl"] .input-group > .form-select:not(:first-child) {
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
    border-top-right-radius: .375rem;
    border-bottom-right-radius: .375rem;
}

html[dir="rtl"] .input-group-text {
    border-radius: .375rem;
}

html[dir="rtl"] .input-group > .input-group-text:not(:last-child) {
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
    border-top-left-radius: .375rem;
    border-bottom-left-radius: .375rem;
}

html[dir="rtl"] .input-group > .input-group-text:not(:first-child) {
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
    border-top-right-radius: .375rem;
    border-bottom-right-radius: .375rem;
}

/* Chat message alignment */
html[dir="rtl"] .message-bubble {
    text-align: right;
}

html[dir="ltr"] .message-bubble {
    text-align: left;
}

/* Navigation adjustments */
html[dir="rtl"] .navbar-nav .nav-link {
    padding-right: .5rem;
    padding-left: .5rem;
}

/* Breadcrumb adjustments */
html[dir="rtl"] .breadcrumb-item + .breadcrumb-item::before {
    float: right;
    padding-right: .5rem;
    padding-left: 0;
    content: var(--bs-breadcrumb-divider, "/");
}

/* Table adjustments */
html[dir="rtl"] .table th,
html[dir="rtl"] .table td {
    text-align: right;
}

/* Pagination adjustments */
html[dir="rtl"] .pagination {
    direction: rtl;
}

/* Language selector specific styles */
.language-selector {
    position: relative;
}

.language-selector .dropdown-menu {
    min-width: 200px;
}

.language-selector .dropdown-item {
    display: flex;
    align-items: center;
    padding: 0.5rem 1rem;
}

.language-selector .dropdown-item .flag {
    margin-right: 0.5rem;
    font-size: 1.2em;
}

html[dir="rtl"] .language-selector .dropdown-item .flag {
    margin-right: 0;
    margin-left: 0.5rem;
}

.language-selector .dropdown-item.active {
    background-color: var(--bs-primary);
    color: white;
}

/* Smooth transitions for direction changes */
html {
    transition: direction 0.3s ease;
}

body {
    transition: font-family 0.3s ease;
}

/* Ensure proper text alignment for different languages */
html[lang="fa"] input,
html[lang="fa"] textarea,
html[lang="fa"] .form-control {
    text-align: right;
}

html[lang="en"] input,
html[lang="en"] textarea,
html[lang="en"] .form-control {
    text-align: left;
}

html[lang="zh"] input,
html[lang="zh"] textarea,
html[lang="zh"] .form-control {
    text-align: left;
}

/* Language-specific number formatting */
html[lang="fa"] .number {
    font-family: "Vazirmatn", monospace;
}

html[lang="en"] .number {
    font-family: "Inter", monospace;
}

html[lang="zh"] .number {
    font-family: "Noto Sans SC", monospace;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    html[dir="rtl"] .navbar-collapse {
        text-align: right;
    }
    
    html[dir="ltr"] .navbar-collapse {
        text-align: left;
    }
}

/* Print styles */
@media print {
    html[dir="rtl"] {
        direction: rtl;
    }
    
    html[dir="ltr"] {
        direction: ltr;
    }
}