/* ===================================
   RTL (RIGHT-TO-LEFT) SUPPORT
   Comprehensive RTL styling for Arabic and other RTL languages
   =================================== */

/* Base RTL Direction */
body.rtl {
    direction: rtl;
    text-align: right;
}

/* Form Elements RTL Adjustments */
body.rtl .form-group label,
body.rtl h3 {
    text-align: right;
}

body.rtl h2 {
    text-align: center;
}

body.rtl .form-actions {
    justify-content: flex-start;
}

/* Phone Input (intl-tel-input) RTL Adjustments */
body.rtl .iti__flag-container {
    /* Keep the flag on the left in RTL */
    left: 0;
    right: auto;
}

body.rtl .iti--separate-dial-code .iti__selected-flag {
    border-radius: 0 8px 8px 0;
}

body.rtl .phone-input {
    padding-left: 8px !important;
    padding-right: 92px !important;
    text-align: right;
}

/* Custom Select/Dropdown RTL Adjustments */
body.rtl .custom-select-toggle::after {
    left: 15px;
    right: auto;
}

body.rtl .custom-select-toggle {
    text-align: right;
}

body.rtl .custom-option .checkmark {
    margin-right: auto;
    margin-left: 10px;
}

/* Upload Button RTL Fix */
body.rtl .upload-button {
    direction: ltr;
    /* Keep button content LTR for icon alignment */
}

/* Additional RTL Form Adjustments */
body.rtl .form-row {
    flex-direction: row-reverse;
}

body.rtl input[type="text"],
body.rtl input[type="number"],
body.rtl input[type="tel"],
body.rtl textarea {
    text-align: right;
}

body.rtl .custom-select-options {
    left: auto;
    right: 0;
    min-width: 100%;
    width: 100%;
}

/* RTL Language Switcher */
body.rtl .language-switcher {
    direction: ltr;
    /* Keep language buttons in LTR order */
}

/* User Menu Dropdown RTL Adjustments */
body.rtl #user-menu {
    right: auto;
    left: 0;
    min-width: 240px;
}

body.rtl #user-menu button,
body.rtl #user-menu a.settings-link {
    text-align: right;
    flex-direction: row-reverse;
    justify-content: flex-end;
    gap: 12px;
}

body.rtl #user-menu button svg,
body.rtl #user-menu a.settings-link svg {
    flex-shrink: 0;
    order: 1;
}

body.rtl #user-menu button span,
body.rtl #user-menu a.settings-link span {
    order: 0;
}

/* Language button with AR badge alignment */
body.rtl #user-menu #language-toggle-btn {
    justify-content: flex-end;
}

body.rtl #user-menu #language-toggle-btn .current-lang {
    margin-right: auto;
    margin-left: 0;
}

/* Filter Button RTL Adjustments */
body.rtl #toggle-filters-btn {
    left: auto;
    right: 0;
    border-radius: 8px 0 0 8px;
    border-right: none;
    border-left: 1px solid var(--border-color, #e2e8f0);
    padding: 4px 2px 4px 6px;
}

body.rtl.dark-mode #toggle-filters-btn {
    border-left-color: var(--dm-border-color);
}

/* Filter Panel RTL Adjustments */
body.rtl #filters-panel {
    left: auto;
    right: 0;
    border-right: 1px solid var(--border-color);
    border-left: none;
    box-shadow: -8px 0 32px rgba(0, 0, 0, 0.12), -4px 0 16px rgba(0, 0, 0, 0.08);
    transform: translateX(100%);
}

body.rtl #filters-panel.open {
    transform: translateX(0);
}

body.rtl #filters-panel::before {
    right: auto;
    left: 0;
}

body.rtl.dark-mode #filters-panel {
    border-right-color: var(--dm-border-color);
    border-left: none;
}

/* Notification Item RTL Adjustments */
body.rtl .notification-item.unread::before {
    left: auto;
    right: 0;
}

body.rtl.dark-mode .notification-item.unread::before {
    left: auto;
    right: 0;
}

/* Mention/Notification Inbox Item RTL Adjustments */
body.rtl .mention-inbox-item {
    padding: 16px 16px 16px 24px;
    flex-direction: row-reverse;
}

body.rtl .mention-item-indicator {
    order: 1;
}

body.rtl .mention-item-content {
    order: 0;
}

/* Lead Card Footer RTL Adjustments */
body.rtl .lead-card-footer {
    flex-direction: row-reverse;
    justify-content: space-between;
}

body.rtl .lead-card-footer .details-btn {
    order: 1;
}

body.rtl .lead-card-footer .action-group {
    order: 2;
    flex-direction: row-reverse;
}

body.rtl .lead-card-footer .action-group[style*="flex-direction"] {
    flex-direction: row-reverse !important;
}

body.rtl .lead-card-footer .days-since-action {
    order: 0;
    margin-left: 0;
    margin-right: auto;
}

/* Ensure proper spacing in RTL footer */
body.rtl .lead-card-footer > * {
    margin-left: 8px;
    margin-right: 0;
}

body.rtl .lead-card-footer > *:first-child {
    margin-left: 0;
}

body.rtl .lead-card-footer > *:last-child {
    margin-right: 0;
}

/* Action group buttons in RTL */
body.rtl .lead-card-footer .action-group .lead-action-btn,
body.rtl .lead-card-footer .action-group .assignment-icon-btn {
    margin-left: 4px;
    margin-right: 0;
}

body.rtl .lead-card-footer .action-group .lead-action-btn:first-child,
body.rtl .lead-card-footer .action-group .assignment-icon-btn:first-child {
    margin-left: 0;
}

/* ===================================
   REPORTS SECTION RTL SUPPORT
   =================================== */

/* Reports View Container RTL */
body.rtl #reports-view {
    direction: rtl;
    text-align: right;
}

/* Reports Dashboard Header RTL */
body.rtl #reports-view .dashboard-header {
    flex-direction: row-reverse;
    justify-content: flex-end;
}

body.rtl #reports-view .dashboard-header h1 {
    text-align: right;
}

/* Report Cards Grid RTL */
body.rtl #reports-view .report-cards-grid {
    direction: rtl;
}

body.rtl #reports-view .report-card {
    text-align: center;
    direction: rtl;
    align-items: center;
}

body.rtl #reports-view .report-card h3 {
    text-align: center !important;
    direction: rtl;
    justify-content: center;
}

body.rtl #reports-view .report-card-btn {
    direction: rtl;
    text-align: center;
    justify-content: center;
}

/* Reports Filter Toggle Button RTL */
body.rtl #reports-toggle-filters-btn {
    left: auto;
    right: 0;
    border-radius: 8px 0 0 8px;
    border-right: none;
    border-left: 1px solid var(--border-color, #e2e8f0);
    padding: 4px 2px 4px 6px;
}

body.rtl.dark-mode #reports-toggle-filters-btn {
    border-left-color: var(--dm-border-color);
}

/* Reports Filters Panel RTL */
body.rtl #reports-filters-panel {
    left: auto;
    right: 0;
    transform: translateX(100%);
    box-shadow: -4px 0 16px rgba(0, 0, 0, 0.1);
}

body.rtl #reports-filters-panel.open {
    transform: translateX(0);
}

body.rtl #reports-filters-panel .filters-header {
    flex-direction: row-reverse;
}

body.rtl #reports-filters-panel .filters-header h3 {
    text-align: right;
}

body.rtl #reports-filters-panel .close-filters-btn {
    order: -1;
}

/* Reports Filter Bar RTL */
body.rtl #reports-filter-bar {
    direction: rtl;
    text-align: right;
}

body.rtl #reports-filter-bar .filter-group label {
    text-align: right;
}

body.rtl #reports-filter-bar .filter-group input,
body.rtl #reports-filter-bar .filter-group select {
    text-align: right;
    direction: rtl;
}

body.rtl #reports-filter-bar .filter-actions {
    flex-direction: row-reverse;
}

body.rtl #reports-filter-bar .enhanced-multiselect {
    direction: rtl;
}

body.rtl #reports-filter-bar .select-toggle {
    text-align: right;
    flex-direction: row-reverse;
}

body.rtl #reports-filter-bar .select-dropdown {
    left: auto;
    right: 0;
    text-align: right;
}

body.rtl #reports-filter-bar .select-option {
    flex-direction: row-reverse;
    text-align: right;
}

body.rtl #reports-filter-bar .select-option .option-check {
    order: -1;
    margin-left: 8px;
    margin-right: 0;
}

/* Reports Content Header RTL */
body.rtl #reports-view .report-header {
    flex-direction: row-reverse;
    justify-content: flex-end;
}

body.rtl #reports-view .back-btn {
    flex-direction: row-reverse;
    direction: rtl;
}

body.rtl #reports-view .report-header h2 {
    text-align: right;
}

body.rtl #reports-view .report-header #reports-export-btn {
    margin-left: 0;
    margin-right: auto;
}

/* Reports Toggle Container RTL */
body.rtl #reports-view .report-toggle-container {
    flex-direction: row-reverse;
    direction: ltr; /* Keep buttons in LTR order for consistency */
}

body.rtl #reports-view .report-toggle-btn {
    direction: ltr;
}

/* Reports Broker Sub Navigation RTL */
body.rtl #reports-broker-sub-nav {
    flex-direction: row-reverse;
    direction: ltr; /* Keep buttons in LTR order */
}

/* Reports Summary Cards RTL */
body.rtl #reports-view .marketer-stat-item {
    text-align: right;
    direction: rtl;
}

body.rtl #reports-view .marketer-stat-item .stat-label {
    text-align: right;
}

body.rtl #reports-view .marketer-stat-item .stat-value {
    text-align: right;
}

/* Reports Table RTL */
body.rtl #reports-view .marketer-performance-table {
    direction: rtl;
}

body.rtl #reports-view .marketer-performance-table th {
    text-align: right;
}

body.rtl #reports-view .marketer-performance-table th:first-child {
    text-align: right;
}

body.rtl #reports-view .marketer-performance-table td {
    text-align: right;
}

body.rtl #reports-view .marketer-performance-table td:first-child {
    text-align: right;
}

body.rtl #reports-view .crm-table {
    direction: rtl;
}

body.rtl #reports-view .crm-table th {
    text-align: right;
}

body.rtl #reports-view .crm-table td {
    text-align: right;
}

/* Reports Chart Container RTL */
body.rtl #reports-view .chart-container h3 {
    text-align: right;
}

/* Reports Overall Activity Widgets RTL */
body.rtl #reports-view .overall-header-stats {
    direction: rtl;
}

body.rtl #reports-view .big-number-card,
body.rtl #reports-view .small-number-card {
    text-align: center;
    direction: rtl;
}

body.rtl #reports-view .progress-bar-item {
    direction: rtl;
    text-align: right;
}

body.rtl #reports-view .progress-bar-info {
    text-align: right;
}

body.rtl #reports-view .progress-bar-count {
    text-align: left;
}

body.rtl #reports-view .donut-chart-card h3 {
    text-align: right;
}

body.rtl #reports-view .chart-legend {
    text-align: right;
    direction: rtl;
}

body.rtl #reports-view .legend-item {
    flex-direction: row-reverse;
    text-align: right;
}

/* Reports Action Buttons RTL */
body.rtl #reports-view .action-btn {
    direction: rtl;
}

body.rtl #reports-view .details-btn {
    direction: rtl;
}

/* Reports Empty State RTL */
body.rtl #reports-view .marketer-empty-state {
    text-align: center;
    direction: rtl;
}

/* Reports Date Range Group RTL */
body.rtl #reports-view .date-range-group {
    direction: rtl;
}

body.rtl #reports-view .date-range-group label {
    text-align: right;
}

body.rtl #reports-view .date-range-group input {
    text-align: right;
    direction: rtl;
}

/* Dark Mode RTL Reports */
body.rtl.dark-mode #reports-toggle-filters-btn {
    border-left-color: var(--dm-border-color);
}

body.rtl.dark-mode #reports-filters-panel {
    border-right: 1px solid var(--dm-border-color);
    border-left: none;
}

/* ===================================
   INVENTORY SECTION RTL SUPPORT
   =================================== */

/* Inventory Filter Toggle Button RTL */
body.rtl #inventory-toggle-filters-btn {
    left: auto;
    right: 0;
    border-radius: 8px 0 0 8px;
    border-right: none;
    border-left: 1px solid var(--border-color, #e2e8f0);
    padding: 4px 2px 4px 6px;
}

body.rtl.dark-mode #inventory-toggle-filters-btn {
    border-left-color: var(--dm-border-color);
}

/* Inventory Filters Panel RTL */
body.rtl #inventory-filters-panel {
    left: auto;
    right: 0;
    transform: translateX(100%);
    box-shadow: -4px 0 16px rgba(0, 0, 0, 0.1);
}

body.rtl #inventory-filters-panel.open {
    transform: translateX(0);
}

body.rtl #inventory-filters-panel .filters-header {
    flex-direction: row-reverse;
}

body.rtl #inventory-filters-panel .filters-header h3 {
    text-align: right;
}

body.rtl #inventory-filters-panel .close-filters-btn {
    order: -1;
}

/* Inventory Filter Bar RTL */
body.rtl #inventory-filter-bar {
    direction: rtl;
    text-align: right;
}

body.rtl #inventory-filter-bar .filter-group label {
    text-align: right;
}

body.rtl #inventory-filter-bar .filter-group input,
body.rtl #inventory-filter-bar .filter-group select {
    text-align: right;
    direction: rtl;
}

body.rtl #inventory-filter-bar .filter-actions {
    flex-direction: row-reverse;
}

body.rtl #inventory-filter-bar .filter-section-header {
    text-align: right;
}

body.rtl #inventory-filter-bar .filter-card label {
    text-align: right;
}

body.rtl #inventory-filter-bar .pill-selector-group label {
    text-align: right;
}

body.rtl #inventory-filter-bar .pill-selector-container {
    justify-content: flex-end;
}

body.rtl #inventory-filter-bar .custom-multiselect {
    direction: rtl;
}

body.rtl #inventory-filter-bar .custom-select-toggle {
    text-align: right;
    flex-direction: row-reverse;
}

body.rtl #inventory-filter-bar .custom-select-options {
    left: auto;
    right: 0;
    text-align: right;
}

body.rtl #inventory-filter-bar .custom-option {
    flex-direction: row-reverse;
    text-align: right;
}

body.rtl #inventory-filter-bar .custom-option .checkmark {
    order: -1;
    margin-left: 8px;
    margin-right: 0;
}

body.rtl #inventory-filter-bar .custom-select-actions {
    flex-direction: row-reverse;
}

body.rtl #inventory-filter-bar .range-input-group label {
    text-align: right;
}

body.rtl #inventory-filter-bar .range-inputs {
    flex-direction: row-reverse;
}

/* Dark Mode RTL Inventory */
body.rtl.dark-mode #inventory-filters-panel {
    border-right: 1px solid var(--dm-border-color);
    border-left: none;
}