/* Force RTL on all elements */
html[dir="rtl"] * {
    direction: rtl !important;
}

/* Layout RTL fixes */
html[dir="rtl"] body,
html[dir="rtl"] .container,
html[dir="rtl"] .container-fluid,
html[dir="rtl"] .row,
html[dir="rtl"] .col,
html[dir="rtl"] [class*="col-"] {
    direction: rtl !important;
    text-align: right !important;
}

/* Navigation RTL fixes */
html[dir="rtl"] .navbar,
html[dir="rtl"] .navbar-nav,
html[dir="rtl"] .nav {
    direction: rtl !important;
    padding-right: 0 !important;
}

html[dir="rtl"] .navbar .nav-link {
    text-align: right !important;
}

/* Dashboard components RTL */
html[dir="rtl"] .card,
html[dir="rtl"] .card-header,
html[dir="rtl"] .card-body,
html[dir="rtl"] .card-footer {
    direction: rtl !important;
    text-align: right !important;
}

html[dir="rtl"] .list-group,
html[dir="rtl"] .list-group-item {
    direction: rtl !important;
    text-align: right !important;
}

/* Form controls RTL */
html[dir="rtl"] .form-control,
html[dir="rtl"] .form-select,
html[dir="rtl"] .input-group {
    direction: rtl !important;
    text-align: right !important;
}

/* Email and password fields should always be LTR */
html[dir="rtl"] input[type="email"],
html[dir="rtl"] input[type="password"],
html[dir="rtl"] input[name="email"],
html[dir="rtl"] input[name="password"],
html[dir="rtl"] input[name="confirm_password"],
html[dir="rtl"] input[id="email"],
html[dir="rtl"] input[id="password"],
html[dir="rtl"] input[id="confirm_password"] {
    direction: ltr !important;
    text-align: left !important;
}

html[dir="rtl"] .input-group > :not(:first-child):not(.dropdown-menu):not(.valid-tooltip):not(.valid-feedback):not(.invalid-tooltip):not(.invalid-feedback) {
    margin-right: -1px !important;
    margin-left: 0 !important;
    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;
}

html[dir="rtl"] .input-group > :first-child:not(.dropdown-menu):not(.valid-tooltip):not(.valid-feedback):not(.invalid-tooltip):not(.invalid-feedback) {
    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;
}

/* Tables RTL */
html[dir="rtl"] .table th,
html[dir="rtl"] .table td {
    text-align: right !important;
}

/* Flexbox RTL fixes */
html[dir="rtl"] .d-flex {
    direction: rtl !important;
}

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

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

/* Margin and padding RTL fixes */
html[dir="rtl"] [class*="ms-"] {
    /* margin-right: var(--bs-gutter-x) !important; */
    margin-left: 1 !important;
}

html[dir="rtl"] [class*="me-"] {
    /* margin-left: var(--bs-gutter-x) !important; */
    margin-right: 0 !important;
}

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

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

/* Float RTL fixes */
html[dir="rtl"] .float-start {
    float: right !important;
}

html[dir="rtl"] .float-end {
    float: left !important;
}

/* Text alignment RTL fixes */
html[dir="rtl"] .text-start {
    text-align: right !important;
}

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

/* Dropdown menus RTL */
html[dir="rtl"] .dropdown-menu {
    text-align: right !important;
    left: auto !important;
    right: 0 !important;
}

/* Button groups RTL */
html[dir="rtl"] .btn-group {
    direction: rtl !important;
}

html[dir="rtl"] .btn-group > .btn:not(:last-child):not(.dropdown-toggle) {
    border-radius: 0 0.375rem 0.375rem 0 !important;
}

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

/* Custom dashboard elements RTL */
html[dir="rtl"] .activity-insights,
html[dir="rtl"] .recent-posts,
html[dir="rtl"] .recent-comments,
html[dir="rtl"] .statistics,
html[dir="rtl"] .comment-card,
html[dir="rtl"] .suggestion-item {
    direction: rtl !important;
    text-align: right !important;
}

/* Fix icon spacing in RTL mode - Comprehensive */

/* Insight icons */
html[dir="rtl"] .insight-icon,
html[dir="rtl"] .insight-item .insight-icon,
html[dir="rtl"] .ai-insights-grid .insight-icon {
    margin-right: 0 !important;
    margin-left: 0.75rem !important;
}

/* Section icons */
html[dir="rtl"] .section-icon,
html[dir="rtl"] .panel-title .section-icon {
    margin-right: 0 !important;
    margin-left: 0.75rem !important;
}

/* Metric icons */
html[dir="rtl"] .metric-icon,
html[dir="rtl"] .metric-card .metric-icon {
    margin-right: 0 !important;
    margin-left: 0.75rem !important;
}

/* Dashboard card icons - more specific */
html[dir="rtl"] .rominext-box i:not(.fa-times):not(.fa-close),
html[dir="rtl"] .card i:not(.fa-times):not(.fa-close) {
    margin-right: 0 !important;
    margin-left: 0.5rem !important;
}

/* Panel title icons */
html[dir="rtl"] .panel-title i,
html[dir="rtl"] h3 i,
html[dir="rtl"] h4 i,
html[dir="rtl"] h5 i {
    margin-right: 0 !important;
    margin-left: 0.5rem !important;
}

/* Card header icons */
html[dir="rtl"] .card-header i,
html[dir="rtl"] .card-title i {
    margin-right: 0 !important;
    margin-left: 0.5rem !important;
}

/* Button icons */
html[dir="rtl"] .btn i {
    margin-right: 0 !important;
    margin-left: 0.5rem !important;
}

/* List item icons */
html[dir="rtl"] .list-group-item i,
html[dir="rtl"] li i {
    margin-right: 0 !important;
    margin-left: 0.5rem !important;
}

/* Platform stat icons */
html[dir="rtl"] .platform-icon,
html[dir="rtl"] .platform-stat-item .platform-icon {
    margin-right: 0 !important;
    margin-left: 0.75rem !important;
}

/* Fix Bootstrap grid system for RTL */
html[dir="rtl"] .offset-1 { margin-right: 8.333333% !important; margin-left: 0 !important; }
html[dir="rtl"] .offset-2 { margin-right: 16.666667% !important; margin-left: 0 !important; }
html[dir="rtl"] .offset-3 { margin-right: 25% !important; margin-left: 0 !important; }
html[dir="rtl"] .offset-4 { margin-right: 33.333333% !important; margin-left: 0 !important; }
html[dir="rtl"] .offset-5 { margin-right: 41.666667% !important; margin-left: 0 !important; }
html[dir="rtl"] .offset-6 { margin-right: 50% !important; margin-left: 0 !important; }
html[dir="rtl"] .offset-7 { margin-right: 58.333333% !important; margin-left: 0 !important; }
html[dir="rtl"] .offset-8 { margin-right: 66.666667% !important; margin-left: 0 !important; }
html[dir="rtl"] .offset-9 { margin-right: 75% !important; margin-left: 0 !important; }
html[dir="rtl"] .offset-10 { margin-right: 83.333333% !important; margin-left: 0 !important; }
html[dir="rtl"] .offset-11 { margin-right: 91.666667% !important; margin-left: 0 !important; }

/* Fix icon positioning */
html[dir="rtl"] .fas,
html[dir="rtl"] .far,
html[dir="rtl"] .fab {
    margin-left: 0.5rem !important;
    margin-right: 0 !important;
}

/* Fix Bootstrap utilities */
html[dir="rtl"] .pe-0 { padding-left: 0 !important; padding-right: initial !important; }
html[dir="rtl"] .ps-0 { padding-right: 0 !important; padding-left: initial !important; }
html[dir="rtl"] .pe-1 { padding-left: 0.25rem !important; padding-right: initial !important; }
html[dir="rtl"] .ps-1 { padding-right: 0.25rem !important; padding-left: initial !important; }
html[dir="rtl"] .pe-2 { padding-left: 0.5rem !important; padding-right: initial !important; }
html[dir="rtl"] .ps-2 { padding-right: 0.5rem !important; padding-left: initial !important; }
html[dir="rtl"] .pe-3 { padding-left: 1rem !important; padding-right: initial !important; }
html[dir="rtl"] .ps-3 { padding-right: 1rem !important; padding-left: initial !important; }
html[dir="rtl"] .pe-4 { padding-left: 1.5rem !important; padding-right: initial !important; }
html[dir="rtl"] .ps-4 { padding-right: 1.5rem !important; padding-left: initial !important; }
html[dir="rtl"] .pe-5 { padding-left: 3rem !important; padding-right: initial !important; }
html[dir="rtl"] .ps-5 { padding-right: 3rem !important; padding-left: initial !important; }

/* Landing page RTL fixes */
html[dir="rtl"] .modern-comparison-section .row {
    flex-direction: row-reverse !important;
}

html[dir="rtl"] .modern-comparison-section .col-lg-6:first-child {
    order: 2 !important;
}

html[dir="rtl"] .modern-comparison-section .col-lg-6:last-child {
    order: 1 !important;
}

/* Fix text alignment in RTL hero section */
html[dir="rtl"] .modern-comparison-section .col-lg-6:first-child {
    text-align: center !important;
}

/* Fix circle background positioning for RTL */
html[dir="rtl"] .circle-bg {
    transform: translate(-50%, -40%) !important; /* Center the image */
    top: 50% !important; /* Position higher in container */
}

/* Fix illustration positioning for RTL */
html[dir="rtl"] .illustration-placeholder {
    text-align: center !important;
    display: flex !important;
    align-items: flex-end !important; /* Align to bottom */
    justify-content: center !important;
}

/* Ensure proper text centering in RTL */
html[dir="rtl"] .modern-comparison-section h2,
html[dir="rtl"] .modern-comparison-section p {
    text-align: center !important;
}

/* Fix button alignment in RTL */
html[dir="rtl"] .modern-comparison-section .d-flex {
    justify-content: center !important;
}