/*
 * Arabic public-site RTL overrides.
 *
 * Loaded only when the visitor selected Arabic. It deliberately does not set
 * font-family: the site's existing font choice remains unchanged.
 */
html[dir="rtl"] body {
  direction: rtl;
  text-align: right;
}

/* Form text follows Arabic reading order. Values which must remain easy to
 * compare with payment/order records retain LTR entry and display. */
html[dir="rtl"] label,
html[dir="rtl"] input:not([type="email"]):not([type="tel"]):not([type="number"]),
html[dir="rtl"] textarea,
html[dir="rtl"] select {
  text-align: right;
}

html[dir="rtl"] input[type="email"],
html[dir="rtl"] input[type="tel"],
html[dir="rtl"] input[type="number"],
html[dir="rtl"] input[name*="card" i],
html[dir="rtl"] input[name*="postal" i],
html[dir="rtl"] input[name*="zip" i],
html[dir="rtl"] .ck-order-number,
html[dir="rtl"] .ticket-code,
html[dir="rtl"] .qr-code {
  direction: ltr;
  text-align: left;
}

/* Auth modal fields have icons on the right in Arabic. The base component
 * positions its floating label from the left, which makes Arabic labels look
 * detached from their field. Keep email characters LTR, but start values and
 * labels from the right just like the other Arabic form fields. */
html[dir="rtl"] .auth-modal-overlay .auth-input-wrapper label {
  left: auto;
  right: 50px;
  text-align: right;
}

html[dir="rtl"] .auth-modal-overlay .auth-email-input {
  direction: ltr;
  text-align: right;
}

/* Checkout Step 3: buyer email and telephone values are Latin/numeric, but
 * in Arabic they must begin at the form's right edge like the other buyer
 * fields. Move their adornments there too, while retaining LTR character
 * ordering so email addresses and international phone numbers stay valid. */
html[dir="rtl"] .ck-step3 #ck-email,
html[dir="rtl"] .ck-step3 #ck-phone {
  direction: ltr;
  text-align: right;
}

html[dir="rtl"] .ck-step3 .ck-input-icon {
  left: auto;
  right: 12px;
}

html[dir="rtl"] .ck-step3 #ck-email {
  padding-left: 14px !important;
  padding-right: 42px !important;
}

html[dir="rtl"] .ck-step3 .iti .iti__country-container {
  left: auto;
  right: 12px;
}

/* Country flags and dialling codes are technical LTR data. Isolate this
 * compact control from the Arabic page direction so the flag, +code and
 * chevron retain their expected sequence beside the right-aligned number. */
html[dir="rtl"] .ck-step3 .iti__selected-country,
html[dir="rtl"] .ck-step3 .iti__selected-country-primary {
  direction: ltr;
  unicode-bidi: isolate;
}

html[dir="rtl"] .ck-step3 .iti input#ck-phone {
  padding-left: 14px !important;
  padding-right: 82px !important;
  unicode-bidi: plaintext;
}

/* The public theme uses flex/grid extensively. `direction` reverses their
 * inline start edge while retaining DOM and keyboard order. */
html[dir="rtl"] .ck-modal-chrome,
html[dir="rtl"] .ck-modal-body,
html[dir="rtl"] .ck-modal-left,
html[dir="rtl"] .ck-modal-aside,
html[dir="rtl"] .tmv2,
html[dir="rtl"] .tmv2-cart__line,
html[dir="rtl"] .ticket-row,
html[dir="rtl"] .event_view_table_td_ticket_name {
  direction: rtl;
  text-align: right;
}

/* Decorative left-edge indicators become right-edge indicators in Arabic. */
html[dir="rtl"] .tmv2 .tmv2-cart__line::before,
html[dir="rtl"] .tmv2 .ticket-row:not(.group-tr)::before {
  left: auto;
  right: 0;
}

/* Keep ticket prices, quantities, dates and totals visually stable. */
html[dir="rtl"] .event_view_table_td_price,
html[dir="rtl"] .event_view_table_td_quantity,
html[dir="rtl"] .event_view_table_td_available,
html[dir="rtl"] .event_view_table_td_sales_ends,
html[dir="rtl"] .tmv2-cart__line-price,
html[dir="rtl"] .ck-price,
html[dir="rtl"] .ck-total,
html[dir="rtl"] .ck-amount {
  direction: ltr;
  unicode-bidi: plaintext;
}

/* Close controls and alert padding use the logical opposite side. */
html[dir="rtl"] .flash {
  padding-left: 2.5rem;
  padding-right: 0;
}

html[dir="rtl"] .flash__close {
  left: 0.75rem;
  right: auto;
}

html[dir="rtl"] .ck-modal-close,
html[dir="rtl"] .modal-close,
html[dir="rtl"] [data-dismiss="modal"] {
  left: 1rem;
  right: auto;
}

/* Directional icons convey the correct navigation direction in RTL. */
html[dir="rtl"] .back-btn svg,
html[dir="rtl"] .ck-back svg,
html[dir="rtl"] .btn-back svg,
html[dir="rtl"] .pagination .previous svg,
html[dir="rtl"] .pagination .next svg {
  transform: scaleX(-1);
}

html[dir="rtl"] table th,
html[dir="rtl"] table td {
  text-align: right;
}

/* Keep the compact footer language selector visually centred. Its icon and
 * chevron use a fixed LTR arrangement in every locale; only its label needs
 * Arabic text direction. */
html[dir="rtl"] .footer-lang-btn {
  direction: ltr;
}

html[dir="rtl"] .footer-lang-label {
  direction: rtl;
  text-align: center;
}

/* Calendar: FullCalendar provides Arabic text and RTL dates; mirror the
 * custom toolbar and filter panel too, which otherwise retain their LTR
 * positioning rules. */
html[dir="rtl"] .calendar-page-layout {
  direction: rtl;
}

@media (min-width: 540px) {
  /* The calendar's custom LTR toolbar uses absolute positioning. In RTL that
   * let the date title sit beneath the view selector. Give each toolbar area
   * its own column, keeping the title genuinely centred. */
  html[dir="rtl"] #calendar .fc-toolbar {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
    align-items: center;
    direction: rtl;
  }

  html[dir="rtl"] #calendar .fc-toolbar .fc-left {
    position: static !important;
    grid-column: 1;
    justify-self: start;
    margin: 0 !important;
    flex-direction: row !important;
  }

  html[dir="rtl"] #calendar .fc-toolbar .fc-center {
    grid-column: 2;
    justify-self: center;
    min-width: 0;
  }

  html[dir="rtl"] #calendar .fc-toolbar .fc-center h2 {
    margin: 0 !important;
    white-space: nowrap;
  }

  html[dir="rtl"] #calendar .fc-toolbar .fc-right {
    position: static !important;
    grid-column: 3;
    justify-self: end;
  }
}

@media (min-width: 1024px) {
  html[dir="rtl"] .calendar-page-layout {
    flex-direction: row-reverse !important;
  }
}

@media (max-width: 1023px) {
  html[dir="rtl"] .ck-modal-body,
  html[dir="rtl"] .tmv2 {
    text-align: right;
  }
}
