/* RTL Support for Arabic Language */

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

[dir="rtl"] body {
    direction: rtl;
    text-align: right;
}

/* Header RTL adjustments */
[dir="rtl"] .ca-header-top-content {
    flex-direction: row-reverse;
}

[dir="rtl"] .ca-header-top-content .mr-8 {
    margin-right: 0;
    margin-left: 8px;
}

[dir="rtl"] .ca-header-top-content .ml-80 {
    margin-left: 0;
    margin-right: 80px;
}

/* Navigation RTL adjustments */
[dir="rtl"] .ca-main-menu ul {
    direction: rtl;
}

[dir="rtl"] .ca-main-menu ul li {
    float: right;
}

[dir="rtl"] .ca-main-menu ul li a {
    text-align: right;
}

[dir="rtl"] .ca-main-menu ul li .sub-menu {
    right: 0;
    left: auto;
}

[dir="rtl"] .ca-main-menu ul li:hover .sub-menu {
    right: 0;
    left: auto;
}

/* Language switcher RTL */
[dir="rtl"] .language-switcher {
    margin-right: 0;
    margin-left: 1rem;
}

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

/* Button RTL adjustments */
[dir="rtl"] .ca-btn-primary span {
    margin-left: 0;
    margin-right: 8px;
}

[dir="rtl"] .ca-btn-primary i {
    transform: rotate(180deg);
}

/* Hero section RTL */
[dir="rtl"] .ca-hero-content-1 {
    text-align: right;
}

[dir="rtl"] .ca-hero-content-1 h5,
[dir="rtl"] .ca-hero-content-1 h1,
[dir="rtl"] .ca-hero-content-1 p {
    text-align: right;
}

/* Content sections RTL */
[dir="rtl"] .ca-section-title,
[dir="rtl"] .ca-section-subtitle {
    text-align: right;
}

/* Footer RTL adjustments */
[dir="rtl"] .ca-footer-content {
    text-align: right;
}

[dir="rtl"] .ca-footer-widget ul li {
    text-align: right;
}

[dir="rtl"] .ca-footer-widget ul li a {
    text-align: right;
}

/* Form RTL adjustments */
[dir="rtl"] .form-control {
    text-align: right;
}

[dir="rtl"] .form-label {
    text-align: right;
}

/* Offcanvas RTL */
[dir="rtl"] .ca-offcanvas {
    right: 0;
    left: auto;
    transform: translateX(100%);
}

[dir="rtl"] .ca-offcanvas.show {
    transform: translateX(0);
}

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

[dir="rtl"] .ca-offcanvas-menu-1 ul li {
    text-align: right;
}

[dir="rtl"] .ca-offcanvas-menu-1 ul li a {
    text-align: right;
}

[dir="rtl"] .ca-sm-single-item-4 {
    flex-direction: row-reverse;
}

[dir="rtl"] .ca-sm-single-item-4 .icon {
    margin-left: 0;
    margin-right: 15px;
}

/* Responsive RTL adjustments */
@media (max-width: 991px) {
    [dir="rtl"] .ca-header-top-content .ml-80 {
        margin-right: 20px;
    }
}

@media (max-width: 767px) {
    [dir="rtl"] .ca-header-top-content .ml-80 {
        margin-right: 0;
    }
    
    [dir="rtl"] .ca-hero-content-1 br {
        display: none;
    }
}

/* Typography RTL adjustments */
[dir="rtl"] h1, [dir="rtl"] h2, [dir="rtl"] h3, [dir="rtl"] h4, [dir="rtl"] h5, [dir="rtl"] h6 {
    text-align: right;
}

[dir="rtl"] p {
    text-align: right;
}

/* Flexbox RTL utilities */
[dir="rtl"] .d-flex {
    flex-direction: row-reverse;
}

[dir="rtl"] .justify-content-end {
    justify-content: flex-start;
}

[dir="rtl"] .justify-content-start {
    justify-content: flex-end;
}

[dir="rtl"] .text-end {
    text-align: left;
}

[dir="rtl"] .text-start {
    text-align: right;
}

/* Margin and padding RTL utilities */
[dir="rtl"] .ms-3 {
    margin-left: 0 !important;
    margin-right: 1rem !important;
}

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

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

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

/* Language switcher specific styles - Consistent for all languages */
.language-switcher .dropdown-toggle {
    background: rgba(248, 249, 250, 0.95);
    border: 2px solid #dee2e6;
    color: #495057;
    font-size: 14px;
    font-weight: 600;
    padding: 8px 16px;
    border-radius: 8px;
    transition: all 0.3s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.08);
    min-width: 140px;
    text-align: center;
    backdrop-filter: blur(10px);
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif, 'Arabic UI Text', 'Geeza Pro', 'Damascus', 'Al Bayan', 'Al Tarikh', sans-serif;
    direction: ltr; /* Ensure consistent text direction for button */
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.language-switcher .dropdown-toggle:hover {
    background: rgba(255, 255, 255, 1);
    border-color: #6c757d;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.12);
    color: #212529;
}

.language-switcher .dropdown-toggle:focus {
    background: rgba(255, 255, 255, 1);
    border-color: #495057;
    box-shadow: 0 0 0 3px rgba(108, 117, 125, 0.25);
    color: #212529;
}

.language-switcher .dropdown-toggle::after {
    margin-left: 8px;
    border-top-color: #495057;
}

.language-switcher .dropdown-menu {
    background: rgba(255, 255, 255, 0.98);
    border: 2px solid #e9ecef;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
    border-radius: 8px;
    min-width: 160px;
    padding: 8px 0;
    margin-top: 8px;
    animation: fadeInDown 0.3s ease;
    backdrop-filter: blur(10px);
}

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

.language-switcher .dropdown-item {
    padding: 10px 20px;
    font-size: 14px;
    font-weight: 500;
    color: #495057;
    transition: all 0.2s ease;
    border-left: 3px solid transparent;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif, 'Arabic UI Text', 'Geeza Pro', 'Damascus', 'Al Bayan', 'Al Tarikh', sans-serif;
    direction: ltr; /* Consistent text direction for all language options */
    text-align: left;
}

.language-switcher .dropdown-item:hover {
    background: rgba(248, 249, 250, 0.8);
    color: #212529;
    border-left-color: #6c757d;
    padding-left: 22px;
}

.language-switcher .dropdown-item.active {
    background: rgba(108, 117, 125, 0.1);
    color: #495057;
    border-left-color: #6c757d;
    font-weight: 600;
}

.language-switcher .dropdown-item.active:hover {
    background: rgba(108, 117, 125, 0.15);
    color: #212529;
}

/* Responsive styles for language switcher */
@media (max-width: 768px) {
    .language-switcher .dropdown-toggle {
        padding: 6px 12px;
        font-size: 13px;
        min-width: 120px;
    }
    
    .language-switcher .dropdown-menu {
        min-width: 140px;
    }
    
    .language-switcher .dropdown-item {
        padding: 8px 16px;
        font-size: 13px;
    }
}

/* Special styling for header language switcher */
.ca-header-area .language-switcher .dropdown-toggle {
    background: rgba(255, 255, 255, 0.95);
    border: 2px solid rgba(255, 255, 255, 0.8);
    color: #495057;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.ca-header-area .language-switcher .dropdown-toggle:hover {
    background: rgba(255, 255, 255, 1);
    border-color: rgba(255, 255, 255, 1);
    color: #212529;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.ca-header-area .language-switcher .dropdown-toggle:focus {
    background: rgba(255, 255, 255, 1);
    border-color: rgba(255, 255, 255, 1);
    box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.3);
    color: #212529;
}

.ca-header-area .language-switcher .dropdown-toggle::after {
    border-top-color: #495057;
}

/* Consistent styling for all language options */
.language-switcher .dropdown-toggle,
.language-switcher .dropdown-item {
    font-feature-settings: "liga" 1, "kern" 1;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Ensure all language flags and text have consistent spacing */
.language-switcher .dropdown-toggle span,
.language-switcher .dropdown-item span {
    display: inline-block;
    margin-right: 8px;
    vertical-align: middle;
}

/* Consistent flag emoji sizing for all languages */
.language-switcher .dropdown-toggle,
.language-switcher .dropdown-item {
    font-size: 14px;
    line-height: 1.4;
}

/* Ensure flag emojis are same size */
.language-switcher .dropdown-toggle::before,
.language-switcher .dropdown-item::before {
    font-size: 16px;
    margin-right: 6px;
}

/* Specific styling for each language to ensure consistency */
.language-switcher .dropdown-toggle,
.language-switcher .dropdown-item {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Force consistent button appearance for all languages */
.language-switcher .dropdown-toggle {
    min-height: 40px;
    max-width: 160px;
    text-transform: none;
    letter-spacing: normal;
}

/* Ensure dropdown items have same styling */
.language-switcher .dropdown-item {
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 36px;
}

/* Override any language-specific styles */
.language-switcher .dropdown-toggle,
.language-switcher .dropdown-item {
    font-style: normal !important;
    font-variant: normal !important;
    text-decoration: none !important;
}

/* Arabic font improvements */
[dir="rtl"] {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif, 'Arabic UI Text', 'Geeza Pro', 'Damascus', 'Al Bayan', 'Al Tarikh', sans-serif;
}

/* Ensure proper Arabic text rendering */
[dir="rtl"] * {
    font-feature-settings: "liga" 1, "kern" 1;
    text-rendering: optimizeLegibility;
}