/* RTL Support for Language Switcher */
[dir="rtl"] .language-switcher {
    direction: rtl;
}

[dir="rtl"] .language-switcher .dropdown-menu {
    right: 0 !important;
    left: auto !important;
    text-align: right;
}

[dir="rtl"] .language-switcher .dropdown-item {
    text-align: right;
}

[dir="rtl"] .language-switcher .btn {
    text-align: center;
}

/* تحسين مظهر الأيقونات في RTL */
[dir="rtl"] .language-switcher .fas {
    margin-left: 0;
    margin-right: 0.5rem;
}

[dir="rtl"] .language-switcher .dropdown-arrow {
    margin-right: 0;
    margin-left: 0.5rem;
}

/* تحسين تأثيرات Hover في RTL */
[dir="rtl"] .language-switcher .language-item:hover {
    transform: translateX(-4px);
}

[dir="rtl"] .language-switcher .language-item::before {
    transform: translateX(100%);
}

[dir="rtl"] .language-switcher .language-item:hover::before {
    transform: translateX(-100%);
}

/* تحسين مظهر العلم في RTL */
[dir="rtl"] .language-switcher .flag-icon {
    margin-left: 0;
    margin-right: 0.5rem;
}

/* تحسين مظهر علامة الاختيار في RTL */
[dir="rtl"] .language-switcher .check-icon {
    margin-left: 0;
    margin-right: auto;
    order: -1;
}

/* تحسين مظهر النص في RTL */
[dir="rtl"] .language-switcher .language-name {
    text-align: right;
    direction: rtl;
}

/* تحسين مظهر الزر في RTL */
[dir="rtl"] .language-switcher .language-btn {
    flex-direction: row-reverse;
    justify-content: center;
}

/* تحسين مظهر العناصر في القائمة المنسدلة */
[dir="rtl"] .language-switcher .language-item-content {
    flex-direction: row-reverse;
    justify-content: flex-start;
}

/* تحسين مظهر القائمة المنسدلة في الموبايل */
@media (max-width: 768px) {
    [dir="rtl"] .language-switcher .dropdown-menu {
        right: 0 !important;
        left: auto !important;
        min-width: 160px;
    }
    
    [dir="rtl"] .language-switcher .language-btn {
        min-width: 100px;
        justify-content: center;
    }
}

/* RTL Support for Arabic Language */

/* RTL Direction */
[dir="rtl"] {
    direction: rtl;
    text-align: right;
}

/* RTL Text Alignment */
[dir="rtl"] .text-start {
    text-align: right !important;
}

[dir="rtl"] .text-end {
    text-align: left !important;
}

/* RTL Margins and Paddings */
[dir="rtl"] .ms-auto {
    margin-left: 0 !important;
    margin-right: auto !important;
}

[dir="rtl"] .me-auto {
    margin-right: 0 !important;
    margin-left: auto !important;
}

[dir="rtl"] .ms-1 { margin-right: 0.25rem !important; margin-left: 0 !important; }
[dir="rtl"] .ms-2 { margin-right: 0.5rem !important; margin-left: 0 !important; }
[dir="rtl"] .ms-3 { margin-right: 1rem !important; margin-left: 0 !important; }
[dir="rtl"] .ms-4 { margin-right: 1.5rem !important; margin-left: 0 !important; }
[dir="rtl"] .ms-5 { margin-right: 3rem !important; margin-left: 0 !important; }

[dir="rtl"] .me-1 { margin-left: 0.25rem !important; margin-right: 0 !important; }
[dir="rtl"] .me-2 { margin-left: 0.5rem !important; margin-right: 0 !important; }
[dir="rtl"] .me-3 { margin-left: 1rem !important; margin-right: 0 !important; }
[dir="rtl"] .me-4 { margin-left: 1.5rem !important; margin-right: 0 !important; }
[dir="rtl"] .me-5 { margin-left: 3rem !important; margin-right: 0 !important; }

/* RTL Paddings */
[dir="rtl"] .ps-1 { padding-right: 0.25rem !important; padding-left: 0 !important; }
[dir="rtl"] .ps-2 { padding-right: 0.5rem !important; padding-left: 0 !important; }
[dir="rtl"] .ps-3 { padding-right: 1rem !important; padding-left: 0 !important; }
[dir="rtl"] .ps-4 { padding-right: 1.5rem !important; padding-left: 0 !important; }
[dir="rtl"] .ps-5 { padding-right: 3rem !important; padding-left: 0 !important; }

[dir="rtl"] .pe-1 { padding-left: 0.25rem !important; padding-right: 0 !important; }
[dir="rtl"] .pe-2 { padding-left: 0.5rem !important; padding-right: 0 !important; }
[dir="rtl"] .pe-3 { padding-left: 1rem !important; padding-right: 0 !important; }
[dir="rtl"] .pe-4 { padding-left: 1.5rem !important; padding-right: 0 !important; }
[dir="rtl"] .pe-5 { padding-left: 3rem !important; padding-right: 0 !important; }

/* RTL Float */
[dir="rtl"] .float-start {
    float: right !important;
}

[dir="rtl"] .float-end {
    float: left !important;
}

/* RTL Border Radius */
[dir="rtl"] .rounded-start {
    border-top-left-radius: 0 !important;
    border-bottom-left-radius: 0 !important;
    border-top-right-radius: 0.375rem !important;
    border-bottom-right-radius: 0.375rem !important;
}

[dir="rtl"] .rounded-end {
    border-top-right-radius: 0 !important;
    border-bottom-right-radius: 0 !important;
    border-top-left-radius: 0.375rem !important;
    border-bottom-left-radius: 0.375rem !important;
}

/* RTL Form Elements */
[dir="rtl"] .form-check {
    padding-left: 0;
    padding-right: 1.5em;
}

[dir="rtl"] .form-check-input {
    margin-left: 0;
    margin-right: -1.5em;
}

[dir="rtl"] .form-check-label {
    margin-bottom: 0;
}

/* RTL Dropdown */
[dir="rtl"] .dropdown-menu {
    text-align: right;
}

[dir="rtl"] .dropdown-item {
    text-align: right;
}

/* RTL Navigation */
[dir="rtl"] .navbar-nav {
    padding-right: 0;
}

[dir="rtl"] .nav-link {
    padding-right: 0.5rem;
    padding-left: 0.5rem;
}

/* RTL Buttons */
[dir="rtl"] .btn-group > .btn:not(:last-child):not(.dropdown-toggle) {
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
    border-top-right-radius: 0.375rem;
    border-bottom-right-radius: 0.375rem;
}

[dir="rtl"] .btn-group > .btn:not(:first-child) {
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
    border-top-left-radius: 0.375rem;
    border-bottom-left-radius: 0.375rem;
}

/* RTL Tables */
[dir="rtl"] .table th,
[dir="rtl"] .table td {
    text-align: right;
}

/* RTL Lists */
[dir="rtl"] .list-group {
    padding-right: 0;
}

[dir="rtl"] .list-group-item {
    text-align: right;
}

/* RTL Cards */
[dir="rtl"] .card-header {
    text-align: right;
}

[dir="rtl"] .card-footer {
    text-align: right;
}

/* RTL Alerts */
[dir="rtl"] .alert {
    text-align: right;
}

/* RTL Modal */
[dir="rtl"] .modal-header .btn-close {
    margin: -0.5rem auto -0.5rem -0.5rem;
}

[dir="rtl"] .modal-footer {
    justify-content: flex-start;
}

/* RTL Pagination */
[dir="rtl"] .pagination {
    justify-content: flex-start;
}

/* RTL Breadcrumb */
[dir="rtl"] .breadcrumb-item + .breadcrumb-item::before {
    float: right;
    padding-left: 0.5rem;
    padding-right: 0;
}

/* RTL Progress */
[dir="rtl"] .progress-bar {
    float: right;
}

/* RTL Badge */
[dir="rtl"] .badge {
    text-align: center;
}

/* RTL Tooltip */
[dir="rtl"] .tooltip {
    text-align: right;
}

/* RTL Popover */
[dir="rtl"] .popover {
    text-align: right;
}

/* RTL Carousel */
[dir="rtl"] .carousel-control-prev {
    left: auto;
    right: 0;
}

[dir="rtl"] .carousel-control-next {
    right: auto;
    left: 0;
}

/* RTL Accordion */
[dir="rtl"] .accordion-button {
    text-align: right;
}

[dir="rtl"] .accordion-button::after {
    margin-left: 0;
    margin-right: auto;
}

/* RTL Offcanvas */
[dir="rtl"] .offcanvas-header .btn-close {
    margin: -0.5rem auto -0.5rem -0.5rem;
}

/* RTL Toast */
[dir="rtl"] .toast-header {
    text-align: right;
}

/* RTL Spinner */
[dir="rtl"] .spinner-border,
[dir="rtl"] .spinner-grow {
    margin: 0 auto;
}

/* RTL Utilities */
[dir="rtl"] .start-0 {
    right: 0 !important;
    left: auto !important;
}

[dir="rtl"] .end-0 {
    left: 0 !important;
    right: auto !important;
}

/* RTL Custom Components */
[dir="rtl"] .navbar-brand {
    margin-right: 0;
    margin-left: 1rem;
}

[dir="rtl"] .navbar-nav .nav-link {
    padding-right: 0.5rem;
    padding-left: 0.5rem;
}

/* RTL Form Validation */
[dir="rtl"] .invalid-feedback {
    text-align: right;
}

[dir="rtl"] .valid-feedback {
    text-align: right;
}

/* RTL Input Groups */
[dir="rtl"] .input-group-text {
    border-left: 0;
    border-right: 1px solid #ced4da;
}

[dir="rtl"] .input-group > .form-control:not(:last-child) {
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
    border-top-right-radius: 0.375rem;
    border-bottom-right-radius: 0.375rem;
}

[dir="rtl"] .input-group > .form-control:not(:first-child) {
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
    border-top-left-radius: 0.375rem;
    border-bottom-left-radius: 0.375rem;
}

/* Smooth Language Transition */
html {
    transition: all 0.3s ease-in-out;
}

/* Language Switch Animation */
.language-switcher .dropdown-item {
    transition: all 0.2s ease-in-out;
}

.language-switcher .dropdown-item:hover {
    transform: translateX(5px);
}

[dir="rtl"] .language-switcher .dropdown-item:hover {
    transform: translateX(-5px);
}

/* Enhanced RTL Support for Hero Section */
[dir="rtl"] .hero-section {
    text-align: right;
}

[dir="rtl"] .hero-section .hero-content {
    padding-right: 0;
    padding-left: 2rem;
}

[dir="rtl"] .hero-section .hero-image {
    margin-right: 0;
    margin-left: auto;
}

/* Enhanced RTL Support for Navigation */
[dir="rtl"] .navbar-nav .nav-item {
    margin-right: 0;
    margin-left: 1rem;
}

[dir="rtl"] .navbar-nav .nav-item:last-child {
    margin-left: 0;
}

/* Enhanced RTL Support for Buttons */
[dir="rtl"] .btn-group .btn:not(:last-child) {
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
    border-top-right-radius: 0.375rem;
    border-bottom-right-radius: 0.375rem;
}

[dir="rtl"] .btn-group .btn:not(:first-child) {
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
    border-top-left-radius: 0.375rem;
    border-bottom-left-radius: 0.375rem;
}

/* Enhanced RTL Support for Forms */
[dir="rtl"] .form-floating > label {
    right: 0.75rem;
    left: auto;
}

[dir="rtl"] .form-floating > .form-control:focus ~ label,
[dir="rtl"] .form-floating > .form-control:not(:placeholder-shown) ~ label {
    transform: scale(0.85) translateY(-0.5rem) translateX(0.15rem);
}

/* Enhanced RTL Support for Cards */
[dir="rtl"] .card-img-top {
    border-top-left-radius: 0;
    border-top-right-radius: 0.375rem;
}

[dir="rtl"] .card-img-bottom {
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0.375rem;
}

/* Enhanced RTL Support for Alerts */
[dir="rtl"] .alert-dismissible .btn-close {
    right: auto;
    left: 0;
}

/* Enhanced RTL Support for Modals */
[dir="rtl"] .modal-header .btn-close {
    margin: -0.5rem auto -0.5rem -0.5rem;
}

[dir="rtl"] .modal-footer {
    justify-content: flex-start;
}

/* Enhanced RTL Support for Tooltips */
[dir="rtl"] .tooltip {
    text-align: right;
}

[dir="rtl"] .tooltip .tooltip-inner {
    text-align: right;
}

/* Enhanced RTL Support for Popovers */
[dir="rtl"] .popover {
    text-align: right;
}

[dir="rtl"] .popover .popover-body {
    text-align: right;
}

/* Language Indicator */
.language-indicator {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 8px;
}

[dir="rtl"] .language-indicator {
    margin-right: 0;
    margin-left: 8px;
}

.language-indicator.ar {
    background-color: #28a745;
}

.language-indicator.en {
    background-color: #007bff;
}

/* Smooth Direction Change */
body {
    transition: direction 0.3s ease-in-out;
}
