/* ═══════════════════════════════════════════════
   mini task ai — RTL (Right-to-Left) Styles
   Arabic & Hebrew language support
   ═══════════════════════════════════════════════ */

/* ── Global RTL ── */
body.rtl {
  direction: rtl;
  text-align: right;
}

body.rtl * {
  letter-spacing: 0 !important;
}

/* ── Font Override for Arabic ── */
body.rtl {
  font-family: 'Tajawal', 'Noto Sans Arabic', 'Segoe UI', system-ui, sans-serif;
}

body.rtl h1, body.rtl h2, body.rtl h3, body.rtl h4, body.rtl h5, body.rtl h6,
body.rtl .dashboard-greeting,
body.rtl .kpi-card-value,
body.rtl .focus-time-display,
body.rtl .sidebar-logo-text {
  font-family: 'Tajawal', 'Noto Sans Arabic', system-ui, sans-serif;
}

/* ── Sidebar RTL ── */
body.rtl .sidebar {
  left: auto;
  right: 0;
  border-right: none;
  border-left: 1px solid var(--border-subtle);
}

body.rtl .app-header {
  left: 0;
  right: var(--sidebar-width);
}

body.rtl .main-wrapper {
  margin-left: 0;
  margin-right: var(--sidebar-width);
}

body.rtl.sidebar-collapsed .app-header {
  right: var(--sidebar-width-collapsed);
}

body.rtl.sidebar-collapsed .main-wrapper {
  margin-right: var(--sidebar-width-collapsed);
}

/* Sidebar items */
body.rtl .nav-item {
  flex-direction: row;
}

body.rtl .nav-badge {
  margin-left: 0;
  margin-right: auto;
}

body.rtl .nav-pulse {
  margin-left: 0;
  margin-right: auto;
}

body.rtl .sidebar-section-title {
  text-align: right;
}

body.rtl .sidebar-collapse-btn {
  margin-left: 0;
  margin-right: auto;
}

body.rtl .sidebar-footer-btn {
  flex-direction: row;
}

body.rtl .workspace-item {
  flex-direction: row;
}

body.rtl .workspace-dot {
  margin-right: 0;
  margin-left: var(--space-2);
}

body.rtl .filter-count {
  margin-left: 0;
  margin-right: auto;
}

/* ── Header RTL ── */
body.rtl .header-left {
  flex-direction: row;
}

body.rtl .header-right {
  flex-direction: row;
}

body.rtl .search-trigger {
  flex-direction: row;
}

body.rtl .search-trigger kbd {
  margin-left: 0;
  margin-right: auto;
}

/* ── Task List RTL ── */
body.rtl .task-row {
  direction: rtl;
}

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

body.rtl .task-title {
  flex-direction: row;
}

body.rtl .task-checkbox {
  order: 0;
}

body.rtl .task-actions {
  order: 0;
}

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

body.rtl .priority-dot {
  margin-left: var(--space-2);
  margin-right: 0;
}

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

/* ── Kanban RTL ── */
body.rtl .kanban-board {
  flex-direction: row-reverse;
}

body.rtl .kanban-column-header {
  flex-direction: row;
}

body.rtl .kanban-card-header {
  flex-direction: row;
}

body.rtl .kanban-card-footer {
  flex-direction: row;
}

/* ── Task Detail Panel RTL ── */
body.rtl .task-detail-panel {
  left: 0;
  right: auto;
  transform: translateX(-100%);
  border-right: 1px solid var(--border-default);
  border-left: none;
}

body.rtl .task-detail-panel.open {
  transform: translateX(0);
}

body.rtl .detail-header {
  flex-direction: row;
}

body.rtl .detail-header-actions {
  flex-direction: row;
}

body.rtl .detail-properties {
  direction: rtl;
}

body.rtl .detail-prop-label {
  text-align: right;
}

body.rtl .detail-comment {
  flex-direction: row;
}

body.rtl .detail-comment-meta {
  text-align: right;
}

body.rtl .detail-subtask-item {
  flex-direction: row;
}

body.rtl .detail-priority-bar {
  left: auto;
  right: 0;
}

body.rtl .detail-ai-bar {
  flex-direction: row;
}

/* ── Calendar RTL ── */
body.rtl .calendar-toolbar {
  flex-direction: row;
}

body.rtl .calendar-nav {
  flex-direction: row;
}

body.rtl .calendar-nav-btn:first-child {
  transform: scaleX(-1);
}

body.rtl .calendar-nav-btn:last-of-type {
  transform: scaleX(-1);
}

body.rtl .calendar-event {
  border-left: none;
  border-right: 3px solid var(--accent-violet);
  left: 2px;
  right: 2px;
}

body.rtl .calendar-event.event-purple { border-right-color: var(--accent-violet); border-left: none; }
body.rtl .calendar-event.event-cyan   { border-right-color: var(--accent-cyan); border-left: none; }
body.rtl .calendar-event.event-green  { border-right-color: var(--accent-emerald); border-left: none; }
body.rtl .calendar-event.event-amber  { border-right-color: var(--accent-amber); border-left: none; }
body.rtl .calendar-event.event-rose   { border-right-color: var(--accent-rose); border-left: none; }
body.rtl .calendar-event.event-indigo { border-right-color: var(--accent-indigo); border-left: none; }

body.rtl .calendar-time-slot {
  justify-content: flex-start;
  padding: 0 var(--space-2);
}

body.rtl .calendar-time-column {
  border-right: none;
  border-left: 1px solid var(--border-subtle);
}

body.rtl .calendar-day-column {
  border-right: none;
  border-left: 1px solid var(--border-subtle);
}

body.rtl .calendar-day-column:last-child {
  border-left: none;
}

body.rtl .calendar-now-line::before {
  left: auto;
  right: -4px;
}

body.rtl .calendar-month-day {
  border-right: none;
  border-left: 1px solid var(--border-subtle);
}

body.rtl .calendar-month-day:nth-child(7n) {
  border-left: none;
}

/* ── Dashboard RTL ── */
body.rtl .dashboard-hero-content {
  text-align: right;
}

body.rtl .dashboard-quick-add {
  flex-direction: row;
}

body.rtl .kpi-card-change {
  flex-direction: row;
}

body.rtl .kpi-sparkline {
  right: auto;
  left: 0;
}

body.rtl .dashboard-widget-header {
  flex-direction: row;
}

body.rtl .timeline-item {
  flex-direction: row;
}

body.rtl .timeline-time {
  text-align: left;
}

body.rtl .timeline-content {
  text-align: right;
}

body.rtl .heatmap-grid {
  flex-direction: row-reverse;
}

/* ── AI Panel RTL ── */
body.rtl .ai-message {
  flex-direction: row;
}

body.rtl .ai-message.user {
  flex-direction: row-reverse;
}

body.rtl .ai-message-bubble {
  text-align: right;
}

body.rtl .ai-input-wrapper {
  flex-direction: row;
}

body.rtl .ai-suggestion-chip {
  direction: rtl;
}

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

/* ── Focus Mode RTL ── */
body.rtl .focus-controls {
  flex-direction: row;
}

body.rtl .focus-sounds {
  flex-direction: row;
}

body.rtl .focus-exit-btn {
  right: auto;
  left: var(--space-6);
}

/* ── Analytics RTL ── */
body.rtl .analytics-filters {
  flex-direction: row;
}

body.rtl .analytics-card-header {
  flex-direction: row;
}

/* ── Settings RTL ── */
body.rtl .settings-layout {
  direction: rtl;
}

body.rtl .settings-nav-item {
  flex-direction: row;
}

body.rtl .settings-row {
  flex-direction: row;
}

body.rtl .settings-row-label {
  text-align: right;
}

body.rtl .settings-row-desc {
  text-align: right;
}

/* ── Automations RTL ── */
body.rtl .automation-rule {
  flex-direction: row;
}

body.rtl .automation-rule-keyword {
  text-align: right;
}

/* ── Toast RTL ── */
body.rtl .toast-container {
  left: var(--space-4);
  right: auto;
}

body.rtl .toast {
  flex-direction: row;
}

body.rtl .toast-close {
  margin-left: 0;
  margin-right: auto;
}

/* ── Modal RTL ── */
body.rtl .modal-header {
  flex-direction: row;
}

body.rtl .modal-footer {
  flex-direction: row;
}

/* ── Command Palette RTL ── */
body.rtl .command-palette-input {
  flex-direction: row;
}

body.rtl .command-palette-item {
  flex-direction: row;
}

body.rtl .command-palette-item-shortcut {
  margin-left: 0;
  margin-right: auto;
}

body.rtl .command-palette-footer {
  flex-direction: row;
}

/* ── Context Menu RTL ── */
body.rtl .context-menu {
  text-align: right;
}

body.rtl .dropdown-item {
  flex-direction: row;
}

/* ── Inputs RTL ── */
body.rtl input,
body.rtl textarea,
body.rtl select {
  text-align: right;
}

body.rtl input[type="date"],
body.rtl input[type="number"],
body.rtl input[type="range"] {
  direction: ltr;
}

/* ── Checkbox/Toggle RTL ── */
body.rtl .checkbox-wrapper {
  flex-direction: row;
}

body.rtl .toggle {
  direction: ltr;
}

/* ── Badges & Chips RTL ── */
body.rtl .badge,
body.rtl .chip,
body.rtl .task-tag {
  direction: rtl;
}

body.rtl .chip-remove {
  margin-left: 0;
  margin-right: var(--space-1);
}

/* ── Progress bar RTL ── */
body.rtl .progress-bar-fill {
  /* Progress still fills left-to-right for readability */
}

body.rtl .task-progress-mini-fill {
  /* Progress still fills left-to-right for readability */
}

/* ── Page Header RTL ── */
body.rtl .page-header {
  flex-direction: row;
  text-align: right;
}

body.rtl .page-actions {
  flex-direction: row;
}

/* ── Empty States RTL ── */
body.rtl .empty-state {
  text-align: center;
}

/* ── Bulk Actions RTL ── */
body.rtl .bulk-actions-bar {
  flex-direction: row;
}

/* ── Charts — keep LTR inside SVGs ── */
body.rtl svg text {
  direction: ltr;
}

/* ── Calendar Day View RTL ── */
body.rtl .calendar-day-view {
  direction: rtl;
}

body.rtl .calendar-day-sidebar {
  text-align: right;
}

body.rtl .unscheduled-task {
  flex-direction: row;
}

/* ── Notification Panel RTL ── */
body.rtl .notification-panel {
  right: auto;
  left: 0;
}

body.rtl .notification-panel-header {
  flex-direction: row;
}

/* ── Tasks Toolbar RTL ── */
body.rtl .tasks-toolbar {
  flex-direction: row;
}

body.rtl .tasks-toolbar-left {
  flex-direction: row;
}

body.rtl .tasks-toolbar-right {
  flex-direction: row;
}

body.rtl .task-search {
  flex-direction: row;
}

/* ── Mini Calendar RTL ── */
body.rtl .mini-calendar-header {
  flex-direction: row;
}

/* ── Mobile RTL ── */
@media (max-width: 640px) {
  body.rtl .sidebar {
    transform: translateX(100%);
    right: auto;
    left: auto;
    right: 0;
  }

  body.rtl .sidebar.mobile-open {
    transform: translateX(0);
  }

  body.rtl .app-header {
    right: 0 !important;
  }

  body.rtl .main-wrapper {
    margin-right: 0 !important;
  }

  body.rtl .bulk-actions-bar {
    left: var(--space-3);
    right: var(--space-3);
  }
}

/* ── Language Toggle Button ── */
.lang-toggle {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-pill);
  background: rgba(124, 58, 237, 0.1);
  border: 1px solid rgba(124, 58, 237, 0.2);
  color: var(--purple-300);
  font-size: var(--text-xs);
  font-weight: 600;
  cursor: pointer;
  transition: all var(--duration-fast) var(--ease-smooth);
  user-select: none;
}

.lang-toggle:hover {
  background: rgba(124, 58, 237, 0.2);
  border-color: var(--accent-violet);
}

.lang-toggle .lang-icon {
  font-size: 14px;
}
