/* Shared language-direction and mixed-bidi safeguards for localized CRM surfaces. */
html[dir="rtl"] body {
  direction: rtl;
}

/* The product shell keeps physical topology and scrollbar placement stable.
   Restore RTL only inside the surfaces that render localized content. */
html[dir="rtl"] #mobile-sidebar > .mobile-sidebar-header,
html[dir="rtl"] #mobile-sidebar > .sidebar-fixed-header,
html[dir="rtl"] #mobile-sidebar > .sidebar-nav,
html[dir="rtl"] #breadcrumbs,
html[dir="rtl"] #main-content {
  direction: rtl;
}

html[dir="rtl"] .rtl-mirror {
  transform: scaleX(-1);
}

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

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

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

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

html[dir="rtl"] :is(.ml-1, .ml-2, .ml-3, .ml-4, .ml-6, .ml-8) {
  margin-left: 0 !important;
}

html[dir="rtl"] .ml-1 { margin-right: 0.25rem !important; }
html[dir="rtl"] .ml-2 { margin-right: 0.5rem !important; }
html[dir="rtl"] .ml-3 { margin-right: 0.75rem !important; }
html[dir="rtl"] .ml-4 { margin-right: 1rem !important; }
html[dir="rtl"] .ml-6 { margin-right: 1.5rem !important; }
html[dir="rtl"] .ml-8 { margin-right: 2rem !important; }

html[dir="rtl"] :is(.mr-1, .mr-2, .mr-3, .mr-4, .mr-6, .mr-8) {
  margin-right: 0 !important;
}

html[dir="rtl"] .mr-1 { margin-left: 0.25rem !important; }
html[dir="rtl"] .mr-2 { margin-left: 0.5rem !important; }
html[dir="rtl"] .mr-3 { margin-left: 0.75rem !important; }
html[dir="rtl"] .mr-4 { margin-left: 1rem !important; }
html[dir="rtl"] .mr-6 { margin-left: 1.5rem !important; }
html[dir="rtl"] .mr-8 { margin-left: 2rem !important; }

html[dir="rtl"] :is(.pl-2, .pl-3, .pl-4, .pl-6, .pl-8) {
  padding-left: 0 !important;
}

html[dir="rtl"] .pl-2 { padding-right: 0.5rem !important; }
html[dir="rtl"] .pl-3 { padding-right: 0.75rem !important; }
html[dir="rtl"] .pl-4 { padding-right: 1rem !important; }
html[dir="rtl"] .pl-6 { padding-right: 1.5rem !important; }
html[dir="rtl"] .pl-8 { padding-right: 2rem !important; }

html[dir="rtl"] :is(.pr-2, .pr-3, .pr-4, .pr-6, .pr-8) {
  padding-right: 0 !important;
}

html[dir="rtl"] .pr-2 { padding-left: 0.5rem !important; }
html[dir="rtl"] .pr-3 { padding-left: 0.75rem !important; }
html[dir="rtl"] .pr-4 { padding-left: 1rem !important; }
html[dir="rtl"] .pr-6 { padding-left: 1.5rem !important; }
html[dir="rtl"] .pr-8 { padding-left: 2rem !important; }

html[dir="rtl"] [class*="space-x-"] {
  --tw-space-x-reverse: 1;
}

.activities-page .activity-dropdown {
  inset-inline-end: 0;
}

:is(input[type="email"], input[type="url"], input[type="tel"], [data-bidi="ltr"], code, pre) {
  direction: ltr;
  unicode-bidi: isolate;
  text-align: start;
}

:is(bdi, [dir="auto"], [data-bidi="auto"]) {
  unicode-bidi: isolate;
}

.crm-record-value,
.report-cell-truncate,
.calendar-event-title,
.notification-message {
  unicode-bidi: plaintext;
}

html[dir="rtl"] :is(.report-table-group-header, .report-field-label, .activity-field-group label) {
  text-align: start;
}

html[dir="rtl"] .custom-select {
  background-position: left 0.5rem center !important;
  padding-inline: 0.75rem 2.5rem;
}

@media (max-width: 767px) {
  .record-details-tabs {
    width: 100%;
    min-width: 0;
    max-width: 100%;
    overflow: visible;
  }

  .record-tabs-nav {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.25rem;
    width: 100% !important;
    min-width: 0 !important;
    max-width: 100%;
    box-sizing: border-box;
    overflow: visible !important;
  }

  .record-tab {
    width: 100% !important;
    min-width: 0 !important;
    max-width: 100%;
    box-sizing: border-box;
    justify-content: center;
  }

  .record-tab-label {
    min-width: 0;
    max-width: 100%;
    flex: 1 1 auto;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
}
