/* ============================================================================
   Tharsol Connect: rail pinning, for both rails (Connect's own rail and the ticket screens' rail; loaded by
   Tharsol.Webmail.Web Components/App.razor and Components/Tickets/TicketsHost.razor). Tokens only (tms-tokens.css,
   which both pages load), so light and dark follow data-theme. Chips are tinted: tint fill, saturated text, 1px border.
     .rp-wrap        a tile's wrapper carrying data-rail-key (takes no room of its own)
     .rp-menu        a tile's menu: Pin to rail / Unpin from rail, Customize rail
     .rp-customize   the "Customize rail" entry at the bottom of Connect's rail
     .rp-dialog      the Customize rail dialog
   ========================================================================== */

.rp-wrap { display: contents; }

/* Icons (TmsIcon) drawn outside the portal's .tms root too (Connect's pages): outline glyphs in the text colour. */
:where(.rp-menu, .rp-dialog, .rp-customize, .rp-inline) svg.tms-i {
  fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round;
}

/* ---- the tile's menu ------------------------------------------------------------------------------------------ */
.rp-menu-scrim {
  position: fixed; inset: 0; z-index: 1000;
  background: transparent;
}
.rp-menu {
  position: fixed; z-index: 1001;
  min-width: 210px; padding: 5px;
  display: flex; flex-direction: column; gap: 1px;
  border-radius: var(--tms-r-lg);
  background: var(--tms-surface);
  border: 1px solid var(--tms-border);
  box-shadow: var(--tms-shadow-3);
  font: 13px/1.3 var(--tms-font);
}
.rp-menu .rp-mi {
  display: flex; align-items: center; gap: 10px;
  width: 100%; padding: 8px 10px; border: 0; border-radius: var(--tms-r);
  background: transparent; color: var(--tms-text); text-align: left; cursor: pointer;
  font: inherit;
}
.rp-menu .rp-mi svg.tms-i { width: 16px; height: 16px; flex: none; color: var(--tms-text-2); }
.rp-menu .rp-mi:hover, .rp-menu .rp-mi:focus-visible { background: var(--tms-surface-2); outline: none; }
.rp-menu .rp-mi:focus-visible { box-shadow: inset 0 0 0 2px var(--tms-accent-line); }
.rp-menu-h {
  padding: 6px 10px 4px; font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
  color: var(--tms-text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 260px;
}

/* ---- "Customize rail" at the bottom of Connect's rail -------------------------------------------------------- */
.rail .rp-customize {
  width: 42px; height: 38px; flex: none;
  display: flex; align-items: center; justify-content: center;
  border: 0; border-radius: var(--tms-r); padding: 0; cursor: pointer;
  background: transparent; color: var(--tms-rail-text);
  transition: background-color var(--tms-fast), color var(--tms-fast);
}
.rail .rp-customize svg.tms-i { width: 18px; height: 18px; }
.rail .rp-customize:hover, .rail .rp-customize:focus-visible { background: var(--tms-rail-hover); color: var(--tms-rail-ink, #fff); }
:root[data-look="classic"] .rail .rp-customize { height: 42px; border-radius: 10px; color: var(--muted, var(--tms-text-3)); }
:root[data-look="classic"] .rail .rp-customize:hover { background: var(--hover, var(--tms-surface-2)); color: var(--text, var(--tms-text)); }

/* ---- the Customize rail dialog -------------------------------------------------------------------------------- */
.rp-dialog {
  width: min(480px, calc(100vw - 32px)); max-height: min(86vh, 760px);
  padding: 0; border: 1px solid var(--tms-border); border-radius: var(--tms-r-lg);
  background: var(--tms-surface); color: var(--tms-text);
  box-shadow: var(--tms-shadow-3);
  font: 14px/1.4 var(--tms-font);
  overflow: hidden;
}
.rp-dialog[open] { display: flex; flex-direction: column; }
.rp-dialog::backdrop { background: rgba(16, 15, 21, .45); }
.rp-head {
  display: flex; align-items: center; gap: 8px;
  padding: 14px 16px 10px; border-bottom: 1px solid var(--tms-border);
}
.rp-head h2 { margin: 0; flex: 1; font-size: 16px; font-weight: 650; }
.rp-body { padding: 12px 16px 6px; overflow-y: auto; }
.rp-hint { margin: 0 0 12px; color: var(--tms-text-2); font-size: 13px; }
.rp-body h3 {
  margin: 14px 0 6px; font-size: 11px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase;
  color: var(--tms-text-3);
}
.rp-body h3:first-of-type { margin-top: 0; }
.rp-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.rp-item {
  display: flex; align-items: center; gap: 10px; min-height: 40px;
  padding: 4px 6px 4px 8px; border-radius: var(--tms-r);
  border: 1px solid transparent;
}
.rp-item > svg.tms-i { width: 18px; height: 18px; flex: none; color: var(--tms-text-2); }
.rp-item .rp-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rp-pinned .rp-item { background: var(--tms-surface-2); border-color: var(--tms-border); cursor: grab; }
.rp-pinned .rp-item.is-dragging { opacity: .5; }
.rp-pinned .rp-item.is-over { border-color: var(--tms-accent-line); box-shadow: inset 0 2px 0 var(--tms-accent); }
.rp-handle { flex: none; width: 12px; color: var(--tms-text-3); letter-spacing: -2px; font-size: 13px; user-select: none; }
.rp-drop-end { min-height: 14px; border-radius: var(--tms-r); }
.rp-drop-end.is-over { box-shadow: inset 0 2px 0 var(--tms-accent); }
.rp-empty { margin: 0; padding: 8px; color: var(--tms-text-3); font-size: 13px; border: 1px dashed var(--tms-border-strong); border-radius: var(--tms-r); }

.rp-iconbtn {
  width: 30px; height: 30px; flex: none; padding: 0;
  display: grid; place-items: center;
  border: 1px solid transparent; border-radius: var(--tms-r);
  background: transparent; color: var(--tms-text-2); cursor: pointer;
}
.rp-iconbtn svg.tms-i { width: 15px; height: 15px; }
.rp-iconbtn:hover:not(:disabled) { background: var(--tms-surface-3); color: var(--tms-text); }
.rp-iconbtn:disabled { opacity: .35; cursor: default; }
/* The "chev" glyph points down. */
.rp-iconbtn.rp-up svg.tms-i { transform: rotate(180deg); }

/* Pin toggles: tinted chips (tint fill, saturated text, 1px border). */
.rp-chip {
  flex: none; display: inline-flex; align-items: center; gap: 5px;
  height: 26px; padding: 0 10px; border-radius: 999px; cursor: pointer;
  font: 600 12px/1 var(--tms-font);
  background: var(--tms-surface); color: var(--tms-text-2); border: 1px solid var(--tms-border-strong);
}
.rp-chip svg.tms-i { width: 13px; height: 13px; }
.rp-chip:hover { background: var(--tms-surface-2); color: var(--tms-text); }
.rp-chip[aria-pressed="true"] {
  background: var(--tms-accent-tint); color: var(--tms-accent-ink-2); border-color: var(--tms-accent-line);
}
.rp-chip[aria-pressed="true"]:hover { border-color: var(--tms-accent); }

/* "New tab" (Connect's staff rail): the item always opens in a workspace tab of its own. A tick in a tinted chip. */
.rp-tab {
  flex: none; display: inline-flex; align-items: center; gap: 6px;
  height: 26px; padding: 0 10px 0 8px; border-radius: 999px; cursor: pointer; white-space: nowrap;
  font: 600 12px/1 var(--tms-font);
  background: var(--tms-surface); color: var(--tms-text-2); border: 1px solid var(--tms-border-strong);
}
.rp-tab input { width: 14px; height: 14px; margin: 0; flex: none; accent-color: var(--tms-accent); cursor: pointer; }
.rp-tab:hover { background: var(--tms-surface-2); color: var(--tms-text); }
.rp-tab.is-on { background: var(--tms-accent-tint); color: var(--tms-accent-ink-2); border-color: var(--tms-accent-line); }
.rp-tab:focus-within { outline: 2px solid var(--tms-accent); outline-offset: 1px; }
.rp-hint-tab { margin-top: -4px; }

.rp-dialog button:focus-visible, .rp-inline button:focus-visible { outline: 2px solid var(--tms-accent); outline-offset: 1px; }

/* ---- the same, in the page (Tharsol Connect Settings -> Rail) ------------------------------------------------ */
.rp-inline { position: relative; max-width: 560px; color: var(--tms-text); font: 14px/1.4 var(--tms-font); }
.rp-inline .rp-body { padding: 0 0 6px; overflow: visible; }
.rp-inline .rp-foot { padding: 12px 0 0; }

.rp-foot {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 16px 14px; border-top: 1px solid var(--tms-border);
}
.rp-foot .rp-grow { flex: 1; }
.rp-btn {
  height: 34px; padding: 0 14px; border-radius: var(--tms-r); cursor: pointer;
  font: 600 13px/1 var(--tms-font);
  background: var(--tms-surface); color: var(--tms-text); border: 1px solid var(--tms-border-strong);
}
.rp-btn:hover { background: var(--tms-surface-2); }
.rp-btn.rp-primary { background: var(--tms-accent); color: var(--tms-on-accent); border-color: var(--tms-accent); }
.rp-btn.rp-primary:hover { background: var(--tms-accent-dark); }
.rp-live { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

@media (max-width: 720px) {
  .rp-dialog { width: 100vw; max-width: 100vw; max-height: 92dvh; margin: auto 0 0; border-radius: var(--tms-r-lg) var(--tms-r-lg) 0 0; }
  .rp-item { min-height: 44px; }
  .rp-iconbtn { width: 36px; height: 36px; }
}
