/*
 * Davix H2I right-to-left support (Arabic, Persian, Urdu). Loaded after davix-h2i-rtl.generated.css, which mirrors every direction-dependent
 * rule of the existing stylesheets (scripts/i18n-rtl-build.js). This file holds only what cannot be generated: the language menu, the font
 * for Arabic-script text, and the pieces of a page that always read left to right.
 * The shared design-system stylesheet is not touched.
 */

/* The language menu in the top bar. */
.h2i-lang { max-width: 170px; }
[data-h2i-lang-switch] { display: flex; align-items: center; margin-inline-end: 8px; }

/* Arabic-script languages: a font made for the script. System fonts are used (no download): every platform ships one. */
html:lang(ar), html:lang(fa), html:lang(ur) {
  font-family: 'Segoe UI', Tahoma, 'Noto Naskh Arabic', 'Noto Sans Arabic', 'Geeza Pro', 'Arabic Typesetting', system-ui, sans-serif;
}
html:lang(ur) { line-height: 1.7; }

/* Code, addresses, keys and JSON stay left to right inside a right-to-left page, aligned to the reading start. */
html[dir="rtl"] pre,
html[dir="rtl"] code,
html[dir="rtl"] kbd,
html[dir="rtl"] samp,
html[dir="rtl"] .mono,
html[dir="rtl"] input[type="url"],
html[dir="rtl"] input[type="email"],
html[dir="rtl"] input[type="number"],
html[dir="rtl"] input[type="password"],
html[dir="rtl"] textarea.code,
html[dir="rtl"] .cm-editor,
html[dir="rtl"] [data-ltr] {
  direction: ltr;
  unicode-bidi: plaintext;
}
html[dir="rtl"] pre,
html[dir="rtl"] code { text-align: left; }

/* Numbers and units next to Arabic-script text keep their own order. */
html[dir="rtl"] .num,
html[dir="rtl"] .pill { unicode-bidi: isolate; }

/* Directional icons (arrows, chevrons) face the reading direction. */
html[dir="rtl"] .icon-flip,
html[dir="rtl"] [data-icon="chevron-right"],
html[dir="rtl"] [data-icon="arrow-right"] { transform: scaleX(-1); }

/* More-options badge sits next to the label, chevron stays at the far end */
html[dir="rtl"] .pf-morebtn .pf-count { margin: 0; }
html[dir="rtl"] .pf-morebtn > svg { margin-right: auto; margin-left: 0; }
html[dir="rtl"] .sidebar.open { transform: translateX(0); }


/* ---- Studio + Customer Portal only (the admin portal does not load this file) ---- */
/* Notifications: top-right on desktop in every language, under the header; across the top on phones (the phone rules stay as they are) */
@media (min-width:601px){
  .toast-stack,html[dir="rtl"] .toast-stack{left:auto;right:max(20px,var(--sar));align-items:flex-end;}
}
/* Hint pop-ups: exactly one scrollbar (the inner list), flush with the pop-up edge */
html .hint-pop{display:flex;flex-direction:column;padding:0;overflow:visible !important;}
html .hint-pop .hint-scroll{min-height:0;max-height:none !important;padding:14px 16px;border-radius:14px;box-sizing:border-box;}

/* ---- Language menu: a button with the language's mini flag, and a list with a flag beside every language ---- */
.h2i-lang-btn{display:inline-flex;align-items:center;gap:8px;height:34px;min-height:34px;padding:0 10px;box-sizing:border-box;border:1px solid var(--border);border-radius:10px;background:var(--surface-2);color:var(--text);font:600 13px/1 inherit;font-family:inherit;cursor:pointer;max-width:100%;}
.h2i-lang-btn:hover,.h2i-lang-btn[aria-expanded="true"]{border-color:var(--accent);}
.h2i-lang-btn:focus-visible,.h2i-lang-menu [role="option"]:focus-visible{outline:2px solid var(--accent);outline-offset:1px;}
.h2i-lang-name{min-width:0;max-width:130px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;}
.h2i-lang-chev{flex:none;opacity:.7;}
.h2i-flag{display:inline-flex;flex:none;width:22px;height:15px;border-radius:3px;overflow:hidden;box-shadow:0 0 0 1px rgba(255,255,255,.16);}
.h2i-flag svg{display:block;}
.h2i-lang-menu{position:fixed;z-index:800;min-width:210px;max-width:calc(100vw - 16px);box-sizing:border-box;overflow-y:auto;padding:6px;border-radius:12px;background:var(--surface);border:1px solid var(--border-strong);box-shadow:0 18px 48px rgba(0,0,0,.55);}
.h2i-lang-menu [role="option"]{display:flex;align-items:center;gap:10px;width:100%;padding:8px 10px;border:0;border-radius:8px;background:transparent;color:var(--text);font:500 13.5px/1.3 inherit;font-family:inherit;text-align:start;cursor:pointer;}
.h2i-lang-menu [role="option"]:hover,.h2i-lang-menu [role="option"]:focus{background:var(--surface-3);}
.h2i-lang-menu [role="option"][aria-selected="true"]{color:var(--accent);font-weight:700;}
.h2i-lang-opt{flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;}
/* phones: the button shrinks to the flag and the arrow so the top bar always fits (the list still names every language) */
@media (max-width:600px){
  .h2i-lang-btn{padding:0 8px;gap:6px;}
  .h2i-lang-name{display:none;}
  [data-h2i-lang-switch]{margin-inline-end:0;}
}

select.h2i-lang[data-h2i-lang]{display:none !important;}

/* ---- Small phones: tighter top bar, and tab-bar labels wrap to two lines instead of being cut off ---- */
@media (max-width:420px){
  html .topbar{gap:8px;}
  html .pwa-tab{font-size:10px;}
  html .pwa-tab span{white-space:normal;text-align:center;line-height:1.15;display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden;word-break:normal;overflow-wrap:break-word;hyphens:auto;-webkit-hyphens:auto;text-overflow:clip;}
}

/* top bar titles (Customer Portal and Studio): wrap to two lines, break long words with a hyphen instead of cutting them */
.topbar h1{white-space:normal;overflow-wrap:break-word;hyphens:auto;-webkit-hyphens:auto;line-height:1.2;display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;}
@media (max-width:420px){ html .pwa-tab{min-width:0;} }

/* phones: lists in the Customer Portal fit the screen without sideways scrolling */
@media (max-width:420px){
  html .rc-table .rc-go{display:none;}
  html .rc-table th,html .rc-table .rc-muted{white-space:normal;}
  html .rc-table th,html .rc-table td{padding-left:6px;padding-right:6px;}
}

/* Drop-down lists: wide enough for their values and never break a short value (50, 100 ...) into two lines. */
.pl-menu{min-width:120px;}
.pl-menu-text{overflow-wrap:break-word;word-break:normal;}

/* Usage page, small screens: the two lists and the Export button line up as one tidy block, all the same width (two lists side by side, Export full width below; a single column on very narrow pages). */
@container (max-width:640px){
  .uv-head .uv-filters{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:8px;width:100%;align-items:stretch;margin-inline:0;}
  .uv-head .uv-filters .pl-select,.uv-head .uv-filters > select{width:100%;min-width:0;max-width:none;}
  .uv-head .uv-filters .btn.uv-export{grid-column:1 / -1;width:100%;justify-content:center;}
}
@container (max-width:380px){
  .uv-head .uv-filters{grid-template-columns:minmax(0,1fr);}
}

/* The rows-per-page menu sits at the start edge of its footer (right in right-to-left, left otherwise), never centred in a stacked footer. */
.pg-size { align-self: flex-start; }

/* The big usage figures read the same in every language: "2 / 1,000 units ? 0%" in the order of the English page, kept against the right edge. */
html[dir="rtl"] .uv-big { direction: ltr; justify-content: flex-end; }
html[dir="rtl"] .uv-big .uv-pct { direction: ltr; unicode-bidi: isolate; }
