/**
 * Task Follow-Up Plugin - RTL (Right-to-Left) Styles
 * For Arabic, Hebrew, Persian, Urdu, and other RTL languages
 */

/* ========================================
   Task Follow-Up Plugin - RTL (Arabic) Styles
   ======================================== */

/* RTL Layout Adjustments */
[dir="rtl"] .tfu-container,
[dir="rtl"] .tfu-add-task-form,
[dir="rtl"] .tfu-all-tasks,
[dir="rtl"] .tfu-user-tasks,
[dir="rtl"] .tfu-notifications-container,
[dir="rtl"] .tfu-performance-report {
    direction: rtl;
    text-align: right;
}

/* Form Elements RTL */
[dir="rtl"] .tfu-form-group label {
    text-align: right;
}

[dir="rtl"] .tfu-datetime-group {
    direction: rtl;
}

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

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

[dir="rtl"] .tfu-form-actions .button:first-child {
    margin-left: 12px;
    margin-right: 0;
}

/* Header RTL */
[dir="rtl"] .tfu-tasks-header,
[dir="rtl"] .tfu-notifications-header,
[dir="rtl"] .tfu-report-header {
    text-align: right;
}

[dir="rtl"] .tfu-tasks-header h2:before,
[dir="rtl"] .tfu-notifications-header h2:before {
    margin-left: 12px;
    margin-right: 0;
}

/* Filter RTL */
[dir="rtl"] .tfu-filters {
    direction: rtl;
}

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

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

[dir="rtl"] .tfu-notifications-filters {
    direction: rtl;
}

[dir="rtl"] .tfu-mark-all-read-btn {
    margin-right: auto;
    margin-left: 0;
}

/* Table RTL */
[dir="rtl"] .tfu-tasks-table th,
[dir="rtl"] .tfu-instances-table th,
[dir="rtl"] .tfu-status-history-table th,
[dir="rtl"] .tfu-performance-table th {
    text-align: center;
}

/* Keep first column right-aligned in RTL */
[dir="rtl"] .tfu-tasks-table th:first-child,
[dir="rtl"] .tfu-instances-table th:first-child,
[dir="rtl"] .tfu-status-history-table th:first-child,
[dir="rtl"] .tfu-performance-table th:first-child {
    text-align: right;
}

[dir="rtl"] .tfu-tasks-table td,
[dir="rtl"] .tfu-instances-table td,
[dir="rtl"] .tfu-status-history-table td,
[dir="rtl"] .tfu-performance-table td {
    text-align: center;
    white-space: normal;
    word-wrap: break-word;
}

/* Keep first column right-aligned in RTL */
[dir="rtl"] .tfu-tasks-table td:first-child,
[dir="rtl"] .tfu-instances-table td:first-child,
[dir="rtl"] .tfu-status-history-table td:first-child,
[dir="rtl"] .tfu-performance-table td:first-child {
    text-align: right;
    font-weight: bold;
    font-size: 14px;
}

/* Allow text wrapping in dates column (3rd column) in RTL */
[dir="rtl"] .tfu-tasks-table td:nth-child(3),
[dir="rtl"] .tfu-instances-table td:nth-child(3),
[dir="rtl"] .tfu-status-history-table td:nth-child(3),
[dir="rtl"] .tfu-performance-table td:nth-child(3) {
    max-width: 150px;
    white-space: normal;
    word-wrap: break-word;
    line-height: 1.3;
    font-size: 13px;
    text-align: center;
}

/* Action buttons remain centered */
[dir="rtl"] .tfu-action-buttons {
    text-align: center;
}

[dir="rtl"] .tfu-action-buttons td {
    text-align: center;
}

/* Tab RTL */
[dir="rtl"] .tfu-edit-tab-nav {
    direction: rtl;
}

[dir="rtl"] .tfu-tabs {
    direction: rtl;
}

[dir="rtl"] .tfu-tab {
    direction: rtl;
}

[dir="rtl"] .tfu-tab-badge {
    margin-right: 8px;
    margin-left: 0;
}

/* Card RTL */
[dir="rtl"] .tfu-task-card-header {
    direction: rtl;
    text-align: right;
}

[dir="rtl"] .tfu-task-title {
    text-align: right;
}

[dir="rtl"] .tfu-task-card-dates {
    text-align: right;
}

[dir="rtl"] .tfu-task-card-desc {
    text-align: right;
}

[dir="rtl"] .tfu-task-card-meta {
    text-align: right;
}

[dir="rtl"] .tfu-task-card-actions {
    justify-content: flex-start;
    display: flex;
    gap: 8px;
}

/* Modal RTL */
[dir="rtl"] .tfu-modal-header {
    direction: rtl;
    text-align: right;
}

[dir="rtl"] .tfu-modal-header h3 {
    direction: rtl;
}

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

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

[dir="rtl"] .tfu-choice-option {
    direction: rtl;
    text-align: right;
}

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

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

/* Notification RTL */
[dir="rtl"] .tfu-notification-header {
    direction: rtl;
}

[dir="rtl"] .tfu-notification-title {
    direction: rtl;
    text-align: right;
}

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

[dir="rtl"] .tfu-notification-message {
    text-align: right;
}

[dir="rtl"] .tfu-notification-date {
    text-align: left; /* Keep date in LTR for readability */
}

/* Pagination RTL */
[dir="rtl"] .tfu-notifications-pagination {
    direction: rtl;
}

[dir="rtl"] .tfu-pagination-info {
    text-align: right;
}

[dir="rtl"] .tfu-pagination-links {
    direction: ltr; /* Keep pagination in LTR for logical order */
}

/* Status and Badge RTL */
[dir="rtl"] .tfu-status {
    direction: rtl;
}

[dir="rtl"] .tfu-type-badge {
    direction: rtl;
}

[dir="rtl"] .tfu-late-badge {
    direction: rtl;
}

/* Instance Status RTL */
[dir="rtl"] .tfu-instance-status-container {
    text-align: right;
}

[dir="rtl"] .tfu-instance-title {
    text-align: right;
}

[dir="rtl"] .tfu-instance-badge {
    text-align: right;
}

/* Performance Report RTL */
[dir="rtl"] .tfu-report-summary {
    direction: rtl;
}

[dir="rtl"] .tfu-summary-item {
    text-align: center; /* Keep centered for better appearance */
}

[dir="rtl"] .tfu-user-name {
    text-align: right !important;
}

[dir="rtl"] .tfu-progress-container {
    direction: ltr; /* Keep progress bars in LTR for consistency */
}

[dir="rtl"] .tfu-legend-item {
    direction: rtl;
    text-align: right;
}

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

[dir="rtl"] .tfu-legend-desc {
    text-align: right;
}

/* Loading States RTL */
[dir="rtl"] .tfu-loading-spinner,
[dir="rtl"] .tfu-loading-message {
    direction: rtl;
}

[dir="rtl"] .tfu-loading-spinner:before {
    margin-left: 12px;
    margin-right: 0;
}

[dir="rtl"] .tfu-no-tasks,
[dir="rtl"] .tfu-no-instances,
[dir="rtl"] .tfu-no-status-history,
[dir="rtl"] .tfu-no-notifications {
    text-align: center;
}

[dir="rtl"] .tfu-no-notifications h3,
[dir="rtl"] .tfu-no-notifications p {
    text-align: center;
}

/* Recurrence Section RTL */
[dir="rtl"] .tfu-recurrence-section {
    direction: rtl;
    text-align: right;
}

[dir="rtl"] .tfu-recurrence-section h3 {
    text-align: right;
}

[dir="rtl"] .tfu-recurrence-section h3:before {
    margin-left: 8px;
    margin-right: 0;
}

[dir="rtl"] .tfu-custom-recurrence {
    direction: rtl;
    text-align: right;
}

/* Active Instances List RTL */
[dir="rtl"] .tfu-active-instances-list {
    direction: rtl;
}

[dir="rtl"] .tfu-active-instances-list li {
    direction: rtl;
    text-align: right;
}

[dir="rtl"] .tfu-instance-name {
    text-align: right;
}

/* Arabic Font Optimization */
[dir="rtl"] .tfu-container,
[dir="rtl"] .tfu-add-task-form,
[dir="rtl"] .tfu-all-tasks,
[dir="rtl"] .tfu-user-tasks,
[dir="rtl"] .tfu-notifications-container,
[dir="rtl"] .tfu-performance-report {
    font-family: 'Segoe UI', Tahoma, Arial, 'Helvetica Neue', sans-serif;
}

/* Improve Arabic text rendering */
[dir="rtl"] .tfu-notification-title,
[dir="rtl"] .tfu-task-title,
[dir="rtl"] h1, [dir="rtl"] h2, [dir="rtl"] h3, [dir="rtl"] h4, [dir="rtl"] h5, [dir="rtl"] h6 {
    font-weight: 600;
    line-height: 1.4;
}

[dir="rtl"] .tfu-notification-message,
[dir="rtl"] .tfu-task-card-desc,
[dir="rtl"] p, [dir="rtl"] span, [dir="rtl"] div {
    line-height: 1.6;
}

/* Fix button text alignment in RTL */
[dir="rtl"] .button,
[dir="rtl"] .tfu-edit-btn,
[dir="rtl"] .tfu-delete-btn,
[dir="rtl"] .tfu-status-btn,
[dir="rtl"] .tfu-mark-read-btn,
[dir="rtl"] .tfu-mark-all-read-btn {
    text-align: center;
}

/* Responsive RTL adjustments */
@media (max-width: 768px) {
    [dir="rtl"] .tfu-tasks-header,
    [dir="rtl"] .tfu-notifications-header,
    [dir="rtl"] .tfu-report-header {
        text-align: center;
    }
    
    [dir="rtl"] .tfu-form-actions {
        justify-content: center;
    }
    
    [dir="rtl"] .tfu-filter-actions {
        justify-content: center;
    }
    
    [dir="rtl"] .tfu-mark-all-read-btn {
        margin: 0;
        width: 100%;
    }
    
    [dir="rtl"] .tfu-notification-actions {
        justify-content: space-between;
    }
}

@media (max-width: 480px) {
    [dir="rtl"] .tfu-modal-footer {
        flex-direction: column;
    }
    
    [dir="rtl"] .tfu-choice-option {
        margin-bottom: 12px;
    }
    
    [dir="rtl"] .tfu-task-card-actions {
        display: flex;
        gap: 8px;
        justify-content: center;
    }
}

/* Fix for mixed content (Arabic + English) */
[dir="rtl"] .tfu-mixed-content {
    unicode-bidi: embed;
}

/* Ensure proper spacing for Arabic text */
[dir="rtl"] .tfu-arabic-text {
    letter-spacing: 0;
    word-spacing: 0.1em;
}

/* Status badges in RTL */
[dir="rtl"] .tfu-status,
[dir="rtl"] .tfu-type-badge,
[dir="rtl"] .tfu-late-badge {
    text-align: center;
    direction: rtl;
}

/* Ensure icons remain in correct position */
[dir="rtl"] .tfu-edit-tab span:before,
[dir="rtl"] .tfu-notifications-header h2:before,
[dir="rtl"] .tfu-recurrence-section h3:before {
    display: inline-block;
    margin-left: 8px;
    margin-right: 0;
}

/* Fix for date/time inputs in RTL */
[dir="rtl"] input[type="date"],
[dir="rtl"] input[type="time"] {
    direction: ltr; /* Keep date/time inputs in LTR for consistency */
    text-align: left;
}

/* Fix for number inputs in RTL */
[dir="rtl"] input[type="number"] {
    direction: ltr; /* Keep number inputs in LTR */
    text-align: left;
}

/* Main Layout Adjustments */
body.rtl .tfu-add-task-form,
body.rtl .tfu-all-tasks,
body.rtl .tfu-user-tasks,
body.rtl .tfu-notifications-container,
body.rtl .tfu-admin-dashboard {
    direction: rtl;
    text-align: right;
}

/* Form Elements */
body.rtl .tfu-form-group label {
    text-align: right;
}

body.rtl .tfu-form-group input,
body.rtl .tfu-form-group textarea,
body.rtl .tfu-form-group select {
    text-align: right;
}

body.rtl .tfu-field-description {
    text-align: right;
}

/* Tab Navigation */
body.rtl .tfu-tabs {
    direction: rtl;
    justify-content: flex-start;
}

body.rtl .tfu-tab {
    margin-left: 0;
    margin-right: 5px;
}

body.rtl .tfu-edit-tab-nav {
    direction: rtl;
}

body.rtl .tfu-edit-tab {
    margin-left: 0;
    margin-right: 10px;
}

/* Task Cards */
body.rtl .tfu-task-card {
    text-align: right;
}

body.rtl .tfu-task-card-header {
    direction: rtl;
}

body.rtl .tfu-task-title {
    text-align: right;
}

body.rtl .tfu-task-card-actions {
    direction: rtl;
    display: flex;
    gap: 8px;
}

body.rtl .tfu-task-card-actions button {
    margin-left: 10px;
    margin-right: 0;
}

/* Tables */
body.rtl .tfu-tasks-table,
body.rtl .tfu-instances-table,
body.rtl .tfu-status-history-table,
body.rtl .tfu-performance-table {
    direction: rtl;
}

body.rtl .tfu-tasks-table th,
body.rtl .tfu-tasks-table td,
body.rtl .tfu-instances-table th,
body.rtl .tfu-instances-table td,
body.rtl .tfu-status-history-table th,
body.rtl .tfu-status-history-table td,
body.rtl .tfu-performance-table th,
body.rtl .tfu-performance-table td {
    text-align: center;
    white-space: normal;
    word-wrap: break-word;
}

/* Keep first column right-aligned in RTL for body.rtl */
body.rtl .tfu-tasks-table th:first-child,
body.rtl .tfu-tasks-table td:first-child,
body.rtl .tfu-instances-table th:first-child,
body.rtl .tfu-instances-table td:first-child,
body.rtl .tfu-status-history-table th:first-child,
body.rtl .tfu-status-history-table td:first-child,
body.rtl .tfu-performance-table th:first-child,
body.rtl .tfu-performance-table td:first-child {
    text-align: right;
}

/* Make first column data (task titles) bold and consistent font size for body.rtl */
body.rtl .tfu-tasks-table td:first-child,
body.rtl .tfu-instances-table td:first-child,
body.rtl .tfu-status-history-table td:first-child,
body.rtl .tfu-performance-table td:first-child {
    font-weight: bold;
    font-size: 14px;
}

/* Filters */
body.rtl .tfu-filters {
    direction: rtl;
}

body.rtl .tfu-filter-group {
    margin-left: 0;
    margin-right: 15px;
}

body.rtl .tfu-filter-group label {
    text-align: right;
}

/* Notifications */
body.rtl .tfu-notifications-filters {
    direction: rtl;
}

body.rtl .tfu-filter-tab {
    margin-left: 0;
    margin-right: 10px;
}

body.rtl .tfu-notification-item {
    text-align: right;
}

body.rtl .tfu-notification-header {
    direction: rtl;
}

body.rtl .tfu-notification-title {
    text-align: right;
}

body.rtl .tfu-notification-actions {
    direction: rtl;
}

body.rtl .tfu-mark-read-btn {
    margin-left: 0;
    margin-right: 10px;
}

/* Dashboard Admin */
body.rtl .tfu-dashboard-grid {
    direction: rtl;
}

body.rtl .tfu-card-header h2 {
    direction: rtl;
}

body.rtl .tfu-card-body {
    text-align: right;
}

body.rtl .tfu-feature-list,
body.rtl .tfu-role-item ul,
body.rtl .tfu-setup-item ul {
    padding-left: 0;
    padding-right: 20px;
}

body.rtl .tfu-shortcode-item {
    text-align: right;
}

body.rtl .tfu-quick-actions {
    direction: rtl;
}

/* Toolbar */
body.rtl .tfu-toolbar-inner {
    direction: rtl;
}

body.rtl .tfu-toolbar-left {
    float: right;
}

body.rtl .tfu-toolbar-right {
    float: left;
}

body.rtl .tfu-toolbar-menu {
    direction: rtl;
}

body.rtl .tfu-toolbar-item {
    margin-left: 0;
    margin-right: 20px;
}

body.rtl .tfu-dropdown {
    left: auto;
    right: 0;
}

/* Performance Report */
body.rtl .tfu-report-summary {
    direction: rtl;
}

body.rtl .tfu-legend-items {
    direction: rtl;
}

body.rtl .tfu-legend-item {
    direction: rtl;
}

body.rtl .tfu-legend-label {
    margin-left: 10px;
    margin-right: 0;
}

/* Pagination */
body.rtl .tfu-pagination-links {
    direction: rtl;
}

body.rtl .tfu-page-link {
    margin-left: 0;
    margin-right: 5px;
}

/* Status Badges */
body.rtl .tfu-status,
body.rtl .tfu-role-badge,
body.rtl .tfu-type-badge {
    direction: rtl;
}

/* Progress Bars */
body.rtl .tfu-progress-container {
    direction: rtl;
}

body.rtl .tfu-progress-text {
    margin-left: 8px;
    margin-right: 0;
}

/* Buttons and Actions */
body.rtl .tfu-form-actions {
    direction: rtl;
}

body.rtl .tfu-form-actions button {
    margin-left: 10px;
    margin-right: 0;
}

body.rtl .tfu-action-btn {
    direction: rtl;
}

/* Icons and Dashicons */
body.rtl .dashicons {
    transform: scaleX(-1);
}

/* Specific icons that should not be flipped */
body.rtl .dashicons-clipboard,
body.rtl .dashicons-bell,
body.rtl .dashicons-yes,
body.rtl .dashicons-no,
body.rtl .dashicons-info,
body.rtl .dashicons-warning {
    transform: none;
}

/* Date and Time Inputs */
body.rtl .tfu-datetime-group {
    direction: rtl;
}

body.rtl .tfu-input-group {
    margin-left: 0;
    margin-right: 10px;
}

/* Recurrence Settings */
body.rtl .tfu-recurrence-section {
    text-align: right;
}

body.rtl .tfu-custom-recurrence {
    direction: rtl;
}

body.rtl .tfu-custom-recurrence input,
body.rtl .tfu-custom-recurrence select {
    margin-left: 5px;
    margin-right: 0;
}

/* Loading Messages */
body.rtl .tfu-loading-message,
body.rtl .tfu-loading-spinner {
    text-align: center;
}

/* No Data Messages */
body.rtl .tfu-no-notifications,
body.rtl .tfu-no-instances,
body.rtl .tfu-no-status-history {
    text-align: center;
}

/* Allow text wrapping in dates column (3rd column) in RTL for body.rtl */
body.rtl .tfu-tasks-table td:nth-child(3),
body.rtl .tfu-instances-table td:nth-child(3),
body.rtl .tfu-status-history-table td:nth-child(3),
body.rtl .tfu-performance-table td:nth-child(3) {
    max-width: 150px;
    white-space: normal;
    word-wrap: break-word;
    line-height: 1.3;
    font-size: 13px;
    text-align: center;
}

/* Mobile Responsive RTL */
@media (max-width: 768px) {
    body.rtl .tfu-dashboard-title {
        direction: rtl;
    }
    
    body.rtl .tfu-quick-actions {
        direction: rtl;
    }
    
    body.rtl .tfu-notification-header {
        direction: rtl;
    }
    
    body.rtl .tfu-task-card-actions {
        direction: rtl;
        justify-content: flex-end;
    }
    
    /* Full-width containers in RTL mobile */
    body.rtl .tfu-notifications-container.tfu-full-width,
    body.rtl .tfu-add-task-form.tfu-full-width,
    body.rtl .tfu-all-tasks.tfu-full-width,
    body.rtl .tfu-user-tasks.tfu-full-width,
    body.rtl .tfu-performance-report.tfu-full-width {
        margin: 0;
        width: 100%;
        max-width: none;
        direction: rtl;
    }
}

/* Full-width container variants in RTL */
[dir="rtl"] .tfu-notifications-container.tfu-full-width,
[dir="rtl"] .tfu-add-task-form.tfu-full-width,
[dir="rtl"] .tfu-all-tasks.tfu-full-width,
[dir="rtl"] .tfu-user-tasks.tfu-full-width,
[dir="rtl"] .tfu-performance-report.tfu-full-width {
    max-width: none;
    width: 100%;
    margin: 0;
    direction: rtl;
    text-align: right;
}

/* Full-width containers in RTL */
body.rtl .tfu-notifications-container.tfu-full-width,
body.rtl .tfu-add-task-form.tfu-full-width,
body.rtl .tfu-all-tasks.tfu-full-width,
body.rtl .tfu-user-tasks.tfu-full-width,
body.rtl .tfu-performance-report.tfu-full-width {
    max-width: none;
    width: 100%;
    margin: 0;
    direction: rtl;
    text-align: right;
} 