
/* T2 Falcon Admin — Templates module */

/* ==================== TEMPLATES PAGE LAYOUT ==================== */
/* Mirrors the .page grid used on Hierarchy: clients tree (left rail) + content
   panel. When wizard or details are open, a fixed-width preview rail is
   appended on the right.                                                       */

.templates-page {
  flex: 1;
  padding: 20px 16px;
  display: grid;
  grid-template-columns: var(--clients-w) minmax(0, 1fr);
  gap: 16px;
  min-height: 0;
  min-width: 0;
}
.templates-page.with-preview {
  grid-template-columns: var(--clients-w) minmax(0, 1fr) var(--tpl-preview-w, 300px);
}
/* Responsive fallback: collapse the org tree below 1100px so the main column
   keeps a usable width; drop the preview rail below 960px.                    */
@media (max-width: 1099px) {
  .templates-page,
  .templates-page.with-preview {
    grid-template-columns: minmax(0, 1fr) var(--tpl-preview-w, 300px);
  }
  .templates-page .clients-panel { display: none; }
}
@media (max-width: 959px) {
  .templates-page,
  .templates-page.with-preview {
    grid-template-columns: minmax(0, 1fr);
  }
  .templates-page .clients-panel,
  .templates-page .tpl-preview { display: none; }
}

/* ==================== MAIN PANEL (center) ==================== */
/* Reuses .content-panel chrome from styles.css (white card with border + radius,
   no padding). The inner .tpl-main-body adds padding like Hierarchy's .content-body. */
.tpl-main { min-width: 0; }
.tpl-main-body { /* inherits all from .content-body (flex: 1, padding: 20px 24px 24px) */ }

/* Inline toolbar (Search · Filter · Create) inside the templates list head bar */
.tpl-head-bar-toolbar { gap: 16px; }
.tpl-list-toolbar {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}
/* Legacy .tpl-main-head shell kept for any non-list modes (create/details).
   The list page now reuses Hierarchy's .node-header / .table-panel chrome
   via .tpl-node-header. */
.tpl-main-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border-2);
  min-width: 0;
}
.tpl-main-head .scope {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 17px;
  font-weight: 600;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.tpl-main-head > .btn,
.tpl-main-head > button { flex-shrink: 0; }

.tpl-head-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
.tpl-head-actions .btn {
  height: 32px;
  padding: 0 14px;
  font-size: 12.5px;
  font-weight: 500;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: white;
  color: var(--text);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.12s, border-color 0.12s, opacity 0.12s;
}
.tpl-head-actions .btn:hover:not(:disabled) {
  background: var(--bg-hover);
  border-color: #d1d5db;
}
.tpl-head-actions .btn:disabled {
  color: var(--text-faint);
  background: white;
  cursor: not-allowed;
  opacity: 0.7;
}
.tpl-head-actions .btn-primary-sm {
  background: var(--teal);
  border-color: var(--teal);
  color: white;
  font-weight: 600;
}
.tpl-head-actions .btn-primary-sm:hover:not(:disabled) {
  background: var(--teal-hover);
  border-color: var(--teal-hover);
}
.tpl-head-actions .btn-primary-sm:disabled {
  background: #c9d6d4;
  border-color: #c9d6d4;
  color: white;
  opacity: 1;
}

/* Create Template button — inherits .btn defaults (38px / 13px / 600 / 10px radius)
   to match Hierarchy's primary buttons (e.g. "Add User"). No size overrides. */
.tpl-scope-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: conic-gradient(from 0deg, #0891b2, #059669, #065f46, #0891b2);
}
.tpl-scope-avatar.node {
  background: #D9E6DD;
  color: #0d3f44;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 11px;
}

/* Search field — mirrors Hierarchy's .search-input (absolute icon, 220×36 input) */
.tpl-search {
  position: relative;
  display: flex;
  align-items: center;
}
.tpl-search svg {
  position: absolute;
  inset-inline-start: 12px;
  color: var(--text-faint);
  pointer-events: none;
}
.tpl-search input {
  width: 220px;
  height: 36px;
  padding: 0 14px 0 38px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
  background: white;
  color: var(--text);
  outline: none;
}
body[dir="rtl"] .tpl-search input { padding: 0 38px 0 14px; }
.tpl-search input::placeholder { color: var(--text-faint); }
.tpl-search input:focus { border-color: var(--teal); box-shadow: 0 0 0 3px rgba(13,63,68,0.08); }

/* Filter dropdown trigger — sized like Hierarchy's .filter-btn (36×8px 14px) */
.tpl-filter {
  position: relative;
  width: 170px;
}
.tpl-filter-btn {
  width: 100%;
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  background: white;
  border: 1px solid var(--border);
  border-radius: 8px;
  height: 36px;
  padding: 0 14px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-2);
  cursor: pointer;
}
.tpl-filter-btn:hover { background: var(--bg-hover); border-color: #d1d5db; }
.tpl-filter-btn .chev { color: var(--text-faint); }
.tpl-filter-menu {
  position: absolute;
  top: calc(100% + 6px);
  inset-inline-start: 0;
  inset-inline-end: 0;
  background: white;
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.10);
  z-index: 10;
  padding: 6px;
}
.tpl-filter-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
}
.tpl-filter-item:hover { background: var(--bg-hover); }
.tpl-filter-item.selected {
  background: var(--teal);
  color: white;
}

/* Legacy .tpl-tabs (inline tabs) — list page now uses page-level .tabs-bar.
   Keep the rule shell in case any non-list mode references it. */
.tpl-tabs {
  display: flex;
  gap: 28px;
}
.tpl-tab {
  padding: 10px 2px 12px;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text-muted);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  background: none;
  cursor: pointer;
}
.tpl-tab:hover { color: var(--text); }
.tpl-tab.active {
  color: var(--teal);
  font-weight: 600;
  border-bottom-color: var(--teal);
}

/* Create button (top-right) */
.btn-create-tpl {
  position: relative;
}
.btn-create-tpl .ch-menu {
  position: absolute;
  top: calc(100% + 6px);
  inset-inline-end: 0;
  background: white;
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 12px 32px rgba(0,0,0,0.12);
  padding: 6px;
  z-index: 20;
  min-width: 200px;
}
.btn-create-tpl .ch-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text);
  white-space: nowrap;
}
.btn-create-tpl .ch-item:hover { background: var(--bg-hover); }
.btn-create-tpl .ch-item.first {
  background: var(--teal);
  color: white;
}
.btn-create-tpl .ch-item .icw {
  width: 22px; height: 22px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.btn-create-tpl .ch-item.first .icw { border-color: rgba(255,255,255,0.7); }

/* ==================== TEMPLATES TABLE ==================== */
.tpl-table-wrap {
  overflow-x: auto;
  background: transparent;
  min-width: 0;
  width: 100%;
}
.tpl-table {
  width: 100%;
  min-width: 720px;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 12px;
}
.tpl-table thead th {
  text-align: start;
  padding: 14px 14px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  background: #F5F5F5;
  border-bottom: 1px solid var(--border-2);
  white-space: nowrap;
  user-select: none;
  vertical-align: middle;
  line-height: 1.4;
  letter-spacing: 0;
  height: 60px;
}
.tpl-table thead th:first-child { padding-inline-start: 18px; }
.tpl-table thead th:last-child  { padding-inline-end: 18px; }
.tpl-table tbody tr {
  background: white;
}
.tpl-table tbody tr.selected { background: #f0f5f5; }
.tpl-table tbody td {
  padding: 16px 14px;
  border-bottom: 1px solid var(--border-2);
  color: var(--text);
  vertical-align: middle;
  font-size: 13px;
  line-height: 1.5;
}
.tpl-table tbody td:first-child { padding-inline-start: 18px; }
.tpl-table tbody td:last-child  { padding-inline-end: 18px; }
.tpl-table tbody tr:last-child td { border-bottom: none; }

/* Templates table-panel: reuses .table-panel chrome (border + radius) */
.tpl-table-panel { margin-top: 0; }
.tpl-table-panel .tpl-table-wrap { border: 0; border-radius: 0; }
/* Pagination footer inside panel: own bottom corners only */
.tpl-table-panel .table-footer { border-radius: 0; border-bottom-left-radius: 12px; border-bottom-right-radius: 12px; }

/* Page-level tabs — inherits .tabs-bar (padding: 0 24px, bottom border).
   No negative-margin hack needed: .content-panel has no padding, so the tabs
   sit naturally flush at the top with their bottom border running full-width. */
.tpl-page-tabs .tabs-bar-left { display: inline-flex; align-items: center; gap: 28px; }

/* Tight node-header (logo + name + controls on one row) — margin matches Hierarchy's .node-header */
.tpl-node-header {
  margin-bottom: 18px;
  padding-bottom: 0;
  border-bottom: 0;
  gap: 16px;
  flex-wrap: wrap;
  /* Reserve room for the Create button height so the table doesn't shift between tabs */
  min-height: 38px;
}
.tpl-node-actions {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

/* Header parity with Organization Hierarchy */
.tpl-node-header { flex-wrap: nowrap; }
.tpl-node-header .node-title {
  flex: 1 1 auto;
  min-width: 0;
}
.tpl-node-header .node-title > span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.tpl-table .col-id { width: 32px; color: var(--text); }
.tpl-table .col-name { font-weight: 500; }
.tpl-table .col-name .name-text { display: inline-block; max-width: 160px; line-height: 1.3; white-space: normal; }

/* Date cell with two lines */
.tpl-date {
  display: flex;
  flex-direction: column;
  font-size: 11.5px;
  line-height: 1.3;
}
.tpl-date .d { color: var(--text); }
.tpl-date .t { color: var(--text); }

/* Checker cell */
.tpl-checker {
  display: flex;
  flex-direction: column;
  font-size: 11.5px;
  line-height: 1.3;
  white-space: nowrap;
}
.tpl-checker .name { color: var(--text); }
.tpl-checker .stat { font-style: italic; font-size: 10.5px; }
.tpl-checker.approved .stat { color: var(--green); }
.tpl-checker.pending  .stat { color: var(--orange); }
.tpl-checker.rejected .stat { color: var(--red); }
.tpl-checker.muted .stat { color: var(--text-faint); font-style: normal; }

/* Shared with chip + +N badge */
/* Shared-with chip + hover tooltip */
.tpl-shared-wrap {
  position: relative;
  display: inline-block;
}
.tpl-shared-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #f5f5f5;
  border-radius: 999px;
  padding: 3px 4px 3px 10px;
  font-size: 11px;
  white-space: nowrap;
}
.tpl-shared-tooltip {
  /* position: fixed + top/right set inline via React on hover */
  background: white;
  border-radius: 12px;
  box-shadow: 0 12px 32px rgba(0,0,0,0.14), 0 0 0 1px var(--border);
  padding: 14px 18px 12px;
  z-index: 1000;
  min-width: 260px;
  max-width: 320px;
}
.tpl-shared-tooltip-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--teal);
  padding-bottom: 10px;
  margin-bottom: 10px;
  border-bottom: 1px solid var(--border-2);
}
.tpl-shared-tooltip-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-height: 240px;
  overflow-y: auto;
  padding-inline-end: 4px;
}
.tpl-shared-tooltip-item {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 13px;
  color: var(--text);
}
.tpl-shared-tooltip-item .check {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--teal);
  color: white;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.tpl-shared-pill.no-extra {
  padding: 7px 12px;
}
.tpl-shared-pill .more {
  background: #104c54;
  color: #ffffff;
  font-weight: 600;
  font-size: 11px !important;
  border-radius: 999px;
  padding: 0;
  height: 28px;
  width: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-inline-start: 2px;
}

/* Status pills */
.tpl-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
}
.tpl-pill .dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}
.tpl-pill.approved { background: #D9F2E4; color: #0f7a3a; }
.tpl-pill.approved .dot { background: #15803d; }
.tpl-pill.pending  { background: #FFEDC9; color: #9A6700; }
.tpl-pill.pending .dot { background: #c98e10; }
.tpl-pill.rejected { background: #FDD8DC; color: #B91C1C; }
.tpl-pill.rejected .dot { background: #d92d20; }
.tpl-pill.review   { background: #FFEDC9; color: #9A6700; }
.tpl-pill.review .dot { background: #c98e10; }
.tpl-pill.deleted  { background: #FDD8DC; color: #B91C1C; }
.tpl-pill.deleted .dot { background: #d92d20; }
/* "NA" checker cell — single muted line, no italic stat */
.tpl-checker.na .name { color: var(--text-faint); font-weight: 400; }
/* Make .tpl-actions-cell position the .row-menu reliably */
.tpl-actions-cell { position: relative; }
/* Override .tpl-row-menu absolute position to match .row-menu (Hierarchy) */
.tpl-row-menu { top: 30px; inset-inline-end: 40px; margin-top: 0; }
/* Click affordance for the shared-with chip when it has more */
.tpl-shared-pill.clickable { cursor: pointer; }

/* Status by Meta — small two-line text */
.tpl-meta-status {
  font-size: 11.5px;
  line-height: 1.35;
  white-space: normal;
  max-width: 150px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.tpl-meta-status.rejected { color: var(--red); }

/* Actions cell */
.tpl-actions-cell {
  width: 56px;
  text-align: center;
  position: relative;
}
.tpl-action-btn {
  width: 28px; height: 28px;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  background: transparent;
}
.tpl-action-btn:hover { background: var(--bg-hover); color: var(--text); }
.tpl-action-btn.open {
  background: var(--teal);
  color: white;
}
/* Mirrors Hierarchy's .row-menu — same anchor (top: 30px, inset-inline-end: 40px)
   so the dropdown opens in the same on-screen position relative to the action button. */
.tpl-row-menu {
  position: absolute;
  top: 30px;
  inset-inline-end: 40px;
  z-index: 100;
  background: white;
  border-radius: 10px;
  box-shadow: 0 12px 32px rgba(0,0,0,0.14), 0 0 0 1px var(--border);
  padding: 4px;
  min-width: 160px;
  text-align: start;
}
.tpl-row-menu .item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text);
  width: 100%;
  text-align: start;
}
.tpl-row-menu .item svg { color: var(--text-muted); }
.tpl-row-menu .item:hover { background: #104C54; color: #ffffff; }
.tpl-row-menu .item:hover svg { color: #ffffff; }
.tpl-row-menu .item.danger { color: var(--red); }

/* Pagination / "More Details" floater shown in some refs */
.tpl-list-foot {
  display: flex;
  justify-content: flex-end;
  margin-top: 16px;
}

/* ==================== WIZARD ==================== */
/* The wizard now uses the shared .ac-card chrome from addclient.css.
   When .tpl-wizard is combined with .ac-card, the ac-card flat-fill rules win
   (no border, no radius, full bleed inside ac-page). Legacy .tpl-wizard rules
   only apply if .tpl-wizard is used standalone. */
.tpl-wizard {
  background: white;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 22px 24px 26px;
}
.tpl-wizard.ac-card {
  border: none;
  border-radius: 0;
  padding: 0;
  background: white;
}
.tpl-wizard-body {
  /* Body padding mirrors .ac-card-body (already supplied via that class) */
}
/* Edit / Share screens have no stepper under the title, so the head-bottom (22px) + body-top
   (20px) leaves ~42px of empty space. Tighten the title→content gap to match the rest of the
   pages. Scoped to these screens so the shared .ac-card-head padding stays untouched. */
.tpl-edit-card .ac-card-head { padding-bottom: 4px; }
.tpl-edit-card .ac-card-body { padding-top: 12px; }
.tpl-wizard-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.tpl-wizard-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
}
.tpl-wizard-step-num {
  font-size: 12px;
  color: var(--text-muted);
}
/* Stepper */
.tpl-stepper {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  align-items: center;
  position: relative;
  margin: 0 8px 26px;
  padding: 0 4px;
}
.tpl-stepper-track {
  position: absolute;
  inset-inline-start: 8%;
  inset-inline-end: 8%;
  top: 14px;
  height: 2px;
  background: #E5E7EB;
  z-index: 0;
}
.tpl-stepper-track .fill {
  position: absolute;
  top: 0; left: 0; height: 100%;
  background: var(--teal);
  transition: width 0.3s;
}
.tpl-step {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-muted);
}
.tpl-step .dot {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: white;
  border: 2px solid #D5D9DD;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-weight: 600;
  font-size: 11px;
}
.tpl-step.done .dot { background: var(--teal); border-color: var(--teal); color: white; }
.tpl-step.current .dot { background: var(--teal); border-color: var(--teal); color: white; }
.tpl-step.current { color: var(--text); font-weight: 500; }
.tpl-step .lbl { font-size: 12px; }

/* Wizard fields */
.tpl-grid-1 {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 16px;
}
.tpl-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px 18px;
}
/* 3-column grid used by Step 1.
   Row 1: Template Name (spans cols 1-2) · Select language (col 3)
   Row 2: Reference ID (col 1) · (cols 2-3 empty) */
.tpl-grid-3 {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px 20px;
  align-items: start;
}
.tpl-grid-3 .tpl-col-waba { grid-column: 1 / span 1; grid-row: 1; }
.tpl-grid-3 .tpl-col-name { grid-column: 2 / span 2; grid-row: 1; }
.tpl-grid-3 .tpl-col-lang { grid-column: 1 / span 1; grid-row: 2; }
.tpl-grid-3 .tpl-col-ref  { grid-column: 2 / span 1; grid-row: 2; }
/* Step 2 variant: both fields stack inside column 1 (each = 1/3 row width) */
.tpl-grid-3.tpl-grid-3-stack > .tpl-field { grid-column: 1; }
.tpl-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.tpl-field-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text);
}
.tpl-field-label .opt {
  color: var(--text-faint);
  font-weight: 400;
  font-style: italic;
  font-size: 11px;
  margin-inline-start: 4px;
}
.tpl-field-input,
.tpl-field-select {
  height: 38px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0 12px;
  font-size: 13px;
  background: white;
  outline: none;
  color: var(--text);
  width: 100%;
  box-sizing: border-box;
  font-family: inherit;
}
.tpl-field-select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-inline-end: 32px; }
body[dir="rtl"] .tpl-field-select { background-position: left 12px center; }
.tpl-field-input:focus, .tpl-field-select:focus { border-color: var(--teal); }
.tpl-field-textarea {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 13px;
  background: white;
  outline: none;
  resize: vertical;
  min-height: 88px;
  font-family: inherit;
  color: var(--text);
  width: 100%;
  box-sizing: border-box;
}
.tpl-field-input.readonly, .tpl-field-select:disabled { background: #FAFBFC; color: var(--text-muted); cursor: not-allowed; }

/* Inline counter (e.g. 0/512) */
.tpl-input-with-counter {
  position: relative;
}
.tpl-input-counter {
  position: absolute;
  bottom: 10px;
  inset-inline-end: 12px;
  font-size: 10.5px;
  color: var(--text-faint);
  pointer-events: none;
}

/* Category tabs (Marketing / Utility / Authentication) */
.tpl-cat-tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  background: white;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  margin-top: 18px;
  margin-bottom: 18px;
}
.tpl-cat-tab {
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-muted);
  background: white;
  cursor: pointer;
  border: none;
  border-inline-end: 1px solid var(--border);
  transition: color 0.15s, background 0.15s;
}
.tpl-cat-tab:last-child { border-inline-end: none; }
.tpl-cat-tab:hover { color: var(--text); }
.tpl-cat-tab-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  transition: color 0.15s;
}
.tpl-cat-tab-label { letter-spacing: -0.005em; }
.tpl-cat-tab.active {
  color: var(--teal);
  font-weight: 600;
  background: #F3F8F5;
}
.tpl-cat-tab.active .tpl-cat-tab-icon { color: var(--teal); }

/* Sub-category radio cards */
.tpl-sub-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.tpl-sub-card {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px 12px 14px;
  display: flex;
  gap: 12px;
  align-items: flex-start;
  cursor: pointer;
  background: white;
  transition: border-color 0.15s, background 0.15s;
}
.tpl-sub-card:hover { border-color: #d1d5db; }
.tpl-sub-card.selected {
  border-color: var(--teal);
  background: #F3F8F5;
}
.tpl-sub-card.disabled {
  cursor: not-allowed;
  opacity: 0.55;
}
.tpl-sub-radio {
  width: 18px; height: 18px;
  border-radius: 50%;
  border: 1.5px solid #B6BDC4;
  flex-shrink: 0;
  margin-top: 2px;
  position: relative;
  background: white;
}
.tpl-sub-card.selected .tpl-sub-radio {
  border-color: var(--teal);
  border-width: 5px;
}
.tpl-sub-text .title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}
.tpl-sub-text .title .coming {
  color: var(--text-faint);
  font-weight: 400;
  font-style: italic;
  margin-inline-start: 2px;
}
.tpl-sub-text .desc {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 3px;
  line-height: 1.45;
}

/* "Add variable" link inline with input label */
.tpl-add-var {
  position: absolute;
  bottom: -22px;
  inset-inline-end: 0;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11.5px;
  color: var(--teal);
  font-weight: 500;
  cursor: pointer;
}
.tpl-add-var-row {
  display: flex;
  justify-content: flex-end;
  margin-top: 6px;
  gap: 6px;
  align-items: center;
}
.tpl-add-var-link {
  font-size: 12px;
  color: var(--teal);
  font-weight: 500;
  cursor: pointer;
}
.tpl-add-var-info {
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
  cursor: help;
}

/* Body toolbar (B / I / S / </> / + Add variable / info) */
.tpl-body-toolbar { justify-content: flex-end; gap: 4px; }
.tpl-body-toolbar .tpl-toolbar-spacer { flex: 1; }
.tpl-toolbar-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 26px; height: 26px;
  border-radius: 6px;
  color: var(--text-muted);
  cursor: pointer;
  user-select: none;
  transition: background-color 0.12s ease, color 0.12s ease;
}
.tpl-toolbar-btn:hover { background: #eef2f4; color: var(--text); }
.tpl-toolbar-glyph { font-size: 13px; line-height: 1; }

/* Inline error message under the Body textarea */
.tpl-msg-field .tpl-field-error {
  color: #d4351c;
  font-size: 12px;
  line-height: 1.4;
  margin-top: 6px;
}
/* Red border + red counter when body is in error */
.tpl-field-textarea.has-error { border-color: #d4351c; }
.tpl-field-textarea.has-error:focus { border-color: #d4351c; box-shadow: 0 0 0 3px rgba(212, 53, 28, 0.10); }
.tpl-body-counter { display: inline-flex; align-items: center; gap: 6px; }
.tpl-body-counter-err { color: #d4351c; display: inline-flex; align-items: center; cursor: help; }

/* ===== Validation state: GREEN when valid, RED when invalid =====
   Applies to text inputs and textareas across the wizard. */
.tpl-field-input.is-valid,
.tpl-field-textarea.is-valid {
  border-color: #16a34a;
}
.tpl-field-input.is-valid:focus,
.tpl-field-textarea.is-valid:focus {
  border-color: #16a34a;
  box-shadow: 0 0 0 3px rgba(22, 163, 74, 0.10);
}
/* RED — keep existing has-error / is-invalid in sync (some fields use either) */
.tpl-field-input.has-error,
.tpl-field-input.is-invalid {
  border-color: #d4351c;
}
.tpl-field-input.has-error:focus,
.tpl-field-input.is-invalid:focus {
  border-color: #d4351c;
  box-shadow: 0 0 0 3px rgba(212, 53, 28, 0.10);
}
/* Green check icon (inline counter slot, mirrors the ⊘ error icon) */
.tpl-input-counter-ok {
  color: #16a34a;
  display: inline-flex;
  align-items: center;
}

/* Disabled header input (used when Media sample = Location) */
.tpl-field-input:disabled,
.tpl-field-input[readonly] {
  background: #F2F4F6;
  color: var(--text-muted);
  cursor: not-allowed;
  border-color: var(--border);
}

/* ===== Variable Samples panel (under Header/Body/Footer) ===== */
.tpl-var-samples {
  background: #F7F7F7;
  border-radius: 12px;
  padding: 18px 20px 22px;
  margin-top: 18px;
}
.tpl-var-samples-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 6px;
}
.tpl-var-samples-desc {
  font-size: 12px;
  color: var(--text-2);
  line-height: 1.5;
  margin-bottom: 14px;
}
.tpl-var-samples-section { margin-top: 12px; }
.tpl-var-samples-section-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 8px;
}
.tpl-var-sample-row {
  display: grid;
  grid-template-columns: 110px 1fr;
  gap: 10px;
  align-items: start;
  margin-top: 8px;
}
.tpl-var-sample-chip {
  height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  padding: 0 12px;
  background: #EDEFF1;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
  color: var(--text-muted);
  font-family: inherit;
  box-sizing: border-box;
}
.tpl-var-sample-input-col { display: flex; flex-direction: column; gap: 4px; }
.tpl-field-input.has-error { border-color: #d4351c; }
.tpl-field-input.has-error:focus { border-color: #d4351c; box-shadow: 0 0 0 3px rgba(212, 53, 28, 0.10); }
.tpl-var-sample-err {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: #d4351c;
  display: inline-flex;
  align-items: center;
}
body[dir="rtl"] .tpl-var-sample-err { right: auto; left: 12px; }
.tpl-var-sample-add {
  font-size: 12px;
  color: #d4351c;
  cursor: pointer;
}
.tpl-var-sample-add:hover { text-decoration: underline; }

/* Step 2: grouped Header / Body / Footer panel with light grey background */
.tpl-msg-panel {
  background: #F7F7F7;
  border-radius: 12px;
  padding: 18px 20px 22px;
  margin-top: 18px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.tpl-msg-field .tpl-field-label strong {
  font-weight: 600;
  color: var(--text);
}
.tpl-msg-field .tpl-field-input,
.tpl-msg-field .tpl-field-textarea {
  background: white;
}

/* Buttons block (step 2) */
.tpl-buttons-help {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 0;
  margin-bottom: 0px;
  line-height: 1.4;
  max-width: 100%;
}
.tpl-add-btn-wrap {
  position: relative;
  display: inline-block;
}
.tpl-add-btn {
  background: var(--teal);
  color: white;
  border-radius: 10px;
  padding: 8px 14px 8px 14px;
  margin-top: 10px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.1px;
  box-shadow: 0 1px 0 rgba(0,0,0,0.04);
  transition: background 0.15s;
}
.tpl-add-btn:hover { background: var(--teal-hover); }
.tpl-add-btn-menu {
  position: absolute;
  top: calc(100% + 6px);
  inset-inline-start: 0;
  background: white;
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 12px 30px rgba(0,0,0,0.12);
  padding: 6px;
  min-width: 220px;
  z-index: 20;
}
.tpl-add-btn-menu .row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 12.5px;
  white-space: nowrap;
  color: var(--text);
}
.tpl-add-btn-menu .row .lbl { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; }
.tpl-add-btn-menu .row .lbl .ic { width: 18px; display: inline-flex; justify-content: center; color: var(--text-faint); }
.tpl-add-btn-menu .row .lbl-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.tpl-add-btn-menu .row .lbl-text .nm { line-height: 1.2; }
.tpl-add-btn-menu .row .hint {
  color: var(--text-faint);
  font-size: 10.5px;
  font-style: italic;
}
.tpl-add-btn-menu .row.disabled .row-blocked {
  display: inline-flex;
  align-items: center;
  color: #ef4444;
  margin-inline-start: 8px;
  flex-shrink: 0;
}
.tpl-add-btn-menu .row:hover:not(.disabled) {
  background: #0d3f44;
  color: #fff;
}
.tpl-add-btn-menu .row:hover:not(.disabled) .lbl .ic { color: rgba(255,255,255,0.85); }
.tpl-add-btn-menu .row:hover:not(.disabled) .hint { color: rgba(255,255,255,0.7); }
.tpl-add-btn-menu .row.first {
  background: var(--teal);
  color: white;
}
.tpl-add-btn-menu .row.first .lbl .ic { color: rgba(255,255,255,0.85); }
.tpl-add-btn-menu .row.first .hint { color: rgba(255,255,255,0.7); }
.tpl-add-btn-menu .row.first:hover:not(.disabled) { background: var(--teal-hover); }
.tpl-add-btn-menu .row.disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* Button card (added button) — header on light grey, body on white */
.tpl-flow-card {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: white;
  margin-top: 14px;
  overflow: hidden;
}
.tpl-flow-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #F7F7F7;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border-2);
}
.tpl-flow-card-head .title {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
}
.tpl-flow-card-head .title .ic {
  display: inline-flex;
  align-items: center;
  color: var(--text);
}
.tpl-flow-card-head .remove {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-muted);
  cursor: pointer;
}
.tpl-flow-card-head .remove:hover { color: var(--red); }
.tpl-flow-card-body {
  padding: 18px 18px 20px;
  background: white;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.tpl-flow-card .row-1 {
  display: block;
}
.tpl-flow-card .row-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px 18px;
}
.tpl-flow-card .row-2.row-wide-narrow { grid-template-columns: 2fr 1fr; }
.tpl-flow-card .row-2.row-narrow-wide { grid-template-columns: 1fr 2fr; }

/* ==================== TEMPLATE MANAGEMENT PAGE ==================== */
.tm-page.with-tree { grid-template-columns: var(--clients-w) minmax(0, 1fr); }
.tm-page.no-tree   { grid-template-columns: minmax(0, 1fr); }

.tm-clients-panel { padding: 18px 14px; }
/* When the panel includes the Falcon root header, the root + section label
   handle their own padding (matching Hierarchy's .clients-panel layout) so we
   drop the outer padding and re-apply it to the list/sublabel. */
.tm-clients-panel.with-falcon-head { padding: 0; }
.tm-clients-panel.with-falcon-head .clients-section-label { padding: 10px 20px; }
.tm-clients-panel.with-falcon-head .tm-clients-list { padding: 0 14px 18px; margin-top: 0; }
.tm-clients-list { display: flex; flex-direction: column; gap: 4px; margin-top: 8px; }
.tm-client-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 10px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13.5px;
  color: var(--text);
  border: 1px solid transparent;
}
.tm-client-row:hover { background: #ffffff; }
.tm-client-row.selected {
  background: #e8f0f1;
  /* border-color: rgba(13, 63, 68, 0.18); */
  color: var(--teal);
  font-weight: 600;
}
.tm-client-row .nm { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* TM panel reuses Hierarchy's .tabs-bar / .content-body / .node-header chrome
   (spacing, padding, gap all inherited). The only TM-specific tweak is the
   right-side "Change view" link alignment inside the tabs bar. */
.tm-back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-muted);
}

.tm-channel-card {
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 22px 26px;
  background: white;
}
.tm-channel-section { display: flex; flex-direction: column; gap: 12px; }
.tm-channel-section-title {
  font-size: 13px;
  color: var(--text-muted);
  font-weight: 500;
  margin-bottom: 4px;
}
.tm-channel-section-title.with-icon {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text-muted);
}
.tm-channel-divider {
  height: 1px;
  background: var(--border-2);
  margin: 18px 0;
}
.tm-unrestricted-notice {
  margin-top: 14px;
  background: #F4F5F6;
  border-radius: 10px;
  padding: 14px 18px;
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.55;
}
.tm-readonly-value { font-size: 14px; color: var(--text); font-weight: 600; }
.tm-readonly-value.bold { font-weight: 700; }

/* Radio rows */
.tm-radio-row {
  display: flex;
  gap: 36px;
  margin-bottom: 4px;
}
.tm-radio-opt {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  font-size: 14px;
  color: var(--text);
}
.tm-radio {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 1.5px solid #C5CBD2;
  position: relative;
  background: white;
  flex-shrink: 0;
}
.tm-radio-opt.on .tm-radio {
  border-color: var(--teal);
  border-width: 2px;
}
.tm-radio-opt.on .tm-radio::after {
  content: '';
  position: absolute;
  inset: 3px;
  border-radius: 50%;
  background: var(--teal);
}
.tm-radio-opt.on { color: var(--teal); font-weight: 600; }

/* Checker pickers (One-level and Two-levels grid) */
.tm-checker-block { display: flex; flex-direction: column; gap: 8px; margin-top: 6px; }
.tm-checker-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px 22px;
  margin-top: 6px;
}
.tm-checker-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}
.tm-checker-label .opt {
  color: var(--text-muted);
  font-weight: 400;
  font-style: italic;
  margin-inline-start: 4px;
  font-size: 12px;
}

.tm-checker-select {
  position: relative;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: white;
}
.tm-checker-select.open,
.tm-checker-select.has-values { border-color: var(--teal); }
.tm-checker-select.has-error { border-color: #d92d20; box-shadow: 0 0 0 3px rgba(217, 45, 32, 0.10); }
.tm-checker-error {
  display: block;
  margin-top: 6px;
  color: #d92d20;
  font-size: 12px;
  font-weight: 500;
}
.tm-checker-control {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  cursor: pointer;
  min-height: 46px;
}
.tm-checker-chips {
  flex: 1;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}
.tm-checker-chips .placeholder {
  color: var(--text-faint);
  font-size: 13px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.tm-checker-chips .placeholder::before {
  content: '+';
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  font-weight: 600;
}
.tm-checker-chev { color: var(--text-muted); display: inline-flex; }
.tm-checker-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #F1F2F4;
  border-radius: 999px;
  padding: 5px 10px 5px 12px;
  font-size: 13px;
  color: var(--text);
}
.tm-checker-chip .x { cursor: pointer; color: var(--text-muted); display: inline-flex; }
.tm-checker-chip .x:hover { color: var(--red); }

.tm-checker-menu {
  position: absolute;
  z-index: 30;
  top: calc(100% + 6px);
  inset-inline-start: 0;
  inset-inline-end: 0;
  background: white;
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.12);
  padding: 10px;
  max-height: 320px;
  display: flex;
  flex-direction: column;
}
.tm-checker-search {
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--border);
  border-radius: 10px;
  height: 40px;
  padding: 0px 12px;
  margin-bottom: 8px;
  color: var(--text-muted);
}
.tm-checker-search input {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  font-size: 13px;
  height: 100%;
  color: var(--text);
}
.tm-checker-list {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}
.tm-checker-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 8px;
  cursor: pointer;
}
.tm-checker-row:hover { background: #FAFAFA; }
.tm-checker-row.checked { background: #F3F8F5; }
.tm-checker-cb {
  width: 18px;
  height: 18px;
  border: 1.5px solid #C5CBD2;
  border-radius: 4px;
  background: white;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.tm-checker-row.checked .tm-checker-cb {
  background: var(--teal);
  border-color: var(--teal);
  color: white;
}
.tm-checker-row .meta { flex: 1; line-height: 1.3; }
.tm-checker-row .meta .name { font-size: 13.5px; font-weight: 500; color: var(--text); }
.tm-checker-row .meta .un { font-size: 11.5px; color: var(--text-muted); }

/* Read-only chips for the View mode */
.tm-checker-readonly {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 4px 0;
}
.tm-readonly-chip {
  display: inline-flex;
  align-items: center;
  background: #F1F2F4;
  border-radius: 999px;
  padding: 7px 14px;
  font-size: 13px;
  color: var(--text);
}
.tm-checker-readonly .empty { color: var(--text-faint); font-style: italic; }

/* ============== Step 2 — Authentication variant ============== */
.tpl-auth-step {
  display: flex;
  flex-direction: column;
  gap: 22px;
  margin-top: 6px;
}
.tpl-auth-section {
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 22px 24px;
  background: white;
}
.tpl-auth-section-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 16px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.tpl-auth-section-title .info { color: var(--text-faint); }
.tpl-auth-section-help {
  font-size: 13px;
  color: var(--text-muted);
  margin: -8px 0 14px;
  line-height: 1.55;
}
/* Code-delivery radio list */
.tpl-auth-radio-list {
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.tpl-auth-radio-row {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  cursor: pointer;
}
.tpl-auth-radio-row.disabled { cursor: not-allowed; }
.tpl-auth-radio-row.disabled .tpl-auth-radio-meta .name,
.tpl-auth-radio-row.disabled .tpl-auth-radio-meta .desc { color: var(--text-faint); }
.tpl-auth-radio-row .tpl-flow-type-radio { margin-top: 2px; }
.tpl-auth-radio-meta { min-width: 0; }
.tpl-auth-radio-meta .name {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.35;
}
.tpl-auth-radio-row.selected .tpl-auth-radio-meta .name { color: var(--teal); }
.tpl-auth-radio-meta .name .info { color: var(--text-faint); }
.tpl-auth-radio-meta .name .coming {
  color: var(--text-faint);
  font-weight: 500;
  font-style: normal;
}
.tpl-auth-radio-meta .desc {
  font-size: 12.5px;
  color: var(--text-muted);
  margin-top: 4px;
  line-height: 1.5;
}

/* Content section: checkboxes + expires panel */
.tpl-auth-check {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: var(--text);
  font-weight: 600;
  cursor: pointer;
  padding: 4px 0;
}
.tpl-auth-check + .tpl-auth-check { margin-top: 2px; }
.tpl-auth-check-box {
  width: 18px;
  height: 18px;
  border-radius: 4px;
  border: 1.5px solid #B6BDC4;
  background: white;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: white;
  flex-shrink: 0;
  cursor: pointer;
}
.tpl-auth-check-box.on {
  background: var(--teal);
  border-color: var(--teal);
}
.tpl-auth-expires-panel {
  background: #F2F3F4;
  border-radius: 10px;
  padding: 14px 16px;
  margin-top: 12px;
}
.tpl-auth-expires-panel .tpl-field-label {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 6px;
  display: block;
}
.tpl-auth-expires-row {
  position: relative;
  display: inline-flex;
  align-items: center;
  background: white;
  border: 1px solid var(--border);
  border-radius: 8px;
  height: 38px;
  padding: 0 36px 0 12px;
  width: 160px;
}
.tpl-auth-expires-num {
  border: none;
  outline: none;
  height: 100%;
  width: 50px;
  background: transparent;
  font-size: 13px;
  padding: 0;
  -moz-appearance: textfield;
}
.tpl-auth-expires-num::-webkit-outer-spin-button,
.tpl-auth-expires-num::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.tpl-auth-expires-unit {
  font-size: 13px;
  color: var(--text);
  margin-inline-start: 6px;
}
.tpl-auth-expires-spin {
  position: absolute;
  inset-inline-end: 8px;
  top: 50%;
  transform: translateY(-50%);
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  color: var(--text-muted);
}
.tpl-auth-expires-spin button {
  width: 16px; height: 12px;
  background: transparent;
  border: none;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: inherit;
}
.tpl-auth-expires-spin button:hover { color: var(--text); }

/* Error state for the expires field */
.tpl-auth-expires-panel.has-error {
  background: #fef2f2;
}
.tpl-auth-expires-row:has(.tpl-auth-expires-num.has-error),
.tpl-auth-expires-panel.has-error .tpl-auth-expires-row {
  border-color: #d4351c;
}
.tpl-auth-expires-err-ic {
  position: absolute;
  inset-inline-end: 32px;
  top: 50%;
  transform: translateY(-50%);
  color: #d4351c;
  display: inline-flex;
}
.tpl-auth-expires-err {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
  font-size: 12px;
  color: #d4351c;
}

/* Validity period: toggle + dropdown */
.tpl-auth-toggle-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  cursor: pointer;
}
.tpl-auth-toggle {
  flex-shrink: 0;
  width: 38px;
  height: 22px;
  border-radius: 999px;
  background: #C5CBD2;
  position: relative;
  transition: background 0.18s;
  cursor: pointer;
  margin-top: 2px;
}
.tpl-auth-toggle .thumb {
  position: absolute;
  top: 2px;
  inset-inline-start: 2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: white;
  transition: transform 0.18s, inset-inline-start 0.18s;
}
.tpl-auth-toggle.on { background: var(--teal); }
.tpl-auth-toggle.on .thumb { inset-inline-start: 18px; }
body[dir="rtl"] .tpl-auth-toggle.on .thumb { inset-inline-start: 18px; }
.tpl-auth-toggle-meta { min-width: 0; }
.tpl-auth-toggle-meta .lbl {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.35;
}
.tpl-auth-toggle-meta .desc {
  display: block;
  font-size: 12.5px;
  color: var(--text-muted);
  margin-top: 3px;
  line-height: 1.5;
}
.tpl-auth-validity-field {
  margin-top: 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-width: 200px;
}
.tpl-auth-validity-field .tpl-field-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text);
  font-weight: 500;
}
.tpl-auth-validity-field .tpl-field-label .info { color: var(--text-faint); }
.tpl-flow-card .tpl-input-with-counter input {
  width: 100%;
  box-sizing: border-box;
}
.tpl-flow-card-body .tpl-field-label { font-size: 13px; font-weight: 500; color: var(--text); }
.tpl-flow-create-row {
  display: flex;
  gap: 10px;
  margin-top: 10px;
}
.tpl-flow-create-row .btn {
  flex: 1;
  height: 38px;
  border-radius: 8px;
  border: 1px dashed var(--border);
  background: white;
  color: var(--text);
  font-weight: 500;
}
.tpl-flow-create-row .btn:hover { border-color: var(--teal); color: var(--teal); }
.tpl-flow-saved-row {
  display: flex;
  gap: 10px;
  margin-top: 0;
}

/* Section headers above grouped button cards (Quick Reply / Call to Action) */
.tpl-btn-section-head {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  margin: 16px 0 4px;
}
.tpl-btn-section-head strong { font-weight: 700; }
.tpl-btn-section-head .opt {
  color: var(--text-faint);
  font-weight: 400;
  font-style: italic;
  font-size: 12px;
  margin-inline-start: 6px;
}

/* Validation states inside button cards */
.tpl-flow-card .tpl-field-input.is-invalid,
.tpl-flow-card .tpl-input-with-counter.has-error .tpl-field-input {
  border-color: var(--red);
  color: var(--red);
}
.tpl-flow-card .tpl-input-with-counter.has-error .tpl-input-counter { color: var(--red); }
.tpl-flow-card .tpl-input-err-icon {
  position: absolute;
  top: 50%;
  inset-inline-end: 38px;
  transform: translateY(-50%);
  color: var(--red);
  display: inline-flex;
  pointer-events: none;
}
.tpl-flow-card .tpl-field-error {
  font-size: 11.5px;
  font-style: italic;
  color: var(--red);
  margin-top: 4px;
  line-height: 1.45;
}
.tpl-flow-card .tpl-field-input.is-locked,
.tpl-flow-card .tpl-field-input:disabled {
  background: #F1F2F4;
  color: var(--text-muted);
  cursor: not-allowed;
}

/* Complete Flow source picker (Create new / Use existing) — auto-width buttons */
.tpl-flow-pickers {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
}
.tpl-flow-picker {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 42px;
  min-width: 150px;
  padding: 0 22px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: white;
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.tpl-flow-picker:hover { background: #FAFAFA; }
.tpl-flow-picker.selected {
  border-color: var(--teal);
  color: var(--teal);
  background: white;
}
.tpl-flow-picker svg { color: var(--teal); }
.tpl-flow-saved-row .saved-pill {
  flex: 1;
  height: 38px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: white;
  padding: 0 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
}
.tpl-flow-saved-row .saved-pill:hover { border-color: var(--teal); }
.tpl-flow-saved-row .saved-pill .chev { color: var(--text-muted); }
.tpl-flow-saved-row .ed-btn {
  height: 38px;
  border-radius: 8px;
  border: 1px solid var(--border);
  padding: 0 14px;
  background: white;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
}
.tpl-flow-saved-row .ed-btn:hover { background: var(--bg-hover); }

/* Wizard footer */
.tpl-wizard-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  align-items: center;
}

/* ==================== STEP 3: Shared With multi-select ==================== */
.tpl-share-wrap {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 28px;
  align-items: start;
}
.tpl-share-col h4 {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  margin: 0 0 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.tpl-share-col h4 strong { font-weight: 600; color: var(--text); }
.tpl-share-col h4 .sub {
  font-weight: 400;
  font-size: 13px;
  color: var(--text-muted);
  margin-inline-start: 6px;
}
.tpl-share-col h4 .clear {
  font-size: 13px;
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
}
.tpl-share-col h4 .clear:hover { color: var(--red); }

/* Chip-display multi-select control (top of left column) */
.tpl-share-multi {
  border: 1px solid var(--teal);
  border-radius: 10px;
  background: white;
  padding: 10px 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 48px;
  cursor: pointer;
}
.tpl-share-multi .tpl-share-multi-chips {
  flex: 1;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}
.tpl-share-multi .placeholder {
  color: var(--text-faint);
  font-size: 13px;
}
.tpl-share-multi .tpl-share-multi-chev {
  color: var(--text-muted);
  display: inline-flex;
}
.tpl-share-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #F1F2F4;
  border-radius: 999px;
  padding: 5px 10px 5px 12px;
  font-size: 13px;
  color: var(--text);
}
.tpl-share-chip .x {
  cursor: pointer;
  color: var(--text-muted);
  display: inline-flex;
}
.tpl-share-chip .x:hover { color: var(--red); }

/* Search + list card */
.tpl-share-list-card {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: white;
  padding: 8px;
  margin-top: 12px;
  display: flex;
  flex-direction: column;
}
.tpl-share-search {
  display: flex;
  align-items: center;
  gap: 8px;
  background: white;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0 12px;
  height: 40px;
}
.tpl-share-search input {
  flex: 1;
  border: none;
  background: transparent;
  font-size: 13px;
  height: 100%;
  outline: none;
}

.tpl-share-list {
  margin-top: 6px;
  display: flex;
  flex-direction: column;
  max-height: 320px;
  overflow-y: auto;
}
.tpl-share-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 6px;
  cursor: pointer;
}
.tpl-share-row:hover { background: #FAFAFA; }
.tpl-share-row.checked { background: #F3F8F5; }
/* "Select all" row — pinned at the top of the scrollable user list. */
.tpl-share-row-all { position: sticky; top: 0; z-index: 1; background: #fff; border-radius: 0; border-bottom: 1px solid var(--border-2, #e3e9ea); }
.tpl-share-row-all:hover { background: #f3f8f5; }
.tpl-share-row-all .name { color: var(--teal); font-weight: 600; }
.tpl-share-cb {
  width: 20px; height: 20px;
  border: 1.5px solid #B6BDC4;
  border-radius: 4px;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: white;
}
.tpl-share-row.checked .tpl-share-cb {
  background: var(--teal);
  border-color: var(--teal);
  color: white;
}
.tpl-share-row .meta { flex: 1; line-height: 1.35; }
.tpl-share-row .meta .name { font-size: 14px; font-weight: 500; color: var(--text); }
.tpl-share-row .meta .un { font-size: 12px; color: var(--text-muted); }

/* Selected Users (right column) */
.tpl-share-selected {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.tpl-share-selected-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: #F3F8F5;
}
.tpl-share-selected-row .tpl-share-cb {
  border-color: var(--teal);
  background: var(--teal);
  color: white;
}
.tpl-share-selected-row .meta { flex: 1; line-height: 1.35; }
.tpl-share-selected-row .meta .name { font-size: 14px; font-weight: 500; color: var(--text); }
.tpl-share-selected-row .meta .un { font-size: 12px; color: var(--text-muted); }
.tpl-share-selected-row .x { color: var(--text-muted); cursor: pointer; display: inline-flex; }
.tpl-share-selected-row .x:hover { color: var(--red); }
.tpl-share-empty {
  padding: 24px;
  font-size: 13px;
  color: var(--text-muted);
  border: 1px dashed var(--border);
  border-radius: 12px;
  text-align: center;
}

/* ==================== TEMPLATE PREVIEW (right rail) ==================== */
.tpl-preview {
  position: relative;
  padding: 18px 16px;
  background: white;
  border: 1px solid var(--border);
  border-radius: 14px;
  /* overflow:visible (not auto) so the resizer grip in the left gap is never clipped —
     the body scroll lives in .tpl-preview-scroll (WhatsApp) / .ivr-levels-scroll (IVR). */
  overflow: visible;
  display: flex;
  flex-direction: column;
}
/* Inner scroll for the WhatsApp preview body; the head stays pinned (like the IVR details). */
.tpl-preview-scroll {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
}
/* Read-only IVR canvas inside the preview rail — fills the rail below the pinned head. */
.tpl-preview-ivr-canvas { display: flex; flex: 1 1 auto; min-height: 0; margin-top: 6px; }
.tpl-preview-ivr-canvas .ivr-canvas-step { flex: 1; min-height: 360px; }
/* Drag handle on the panel's left edge — resize the rail; double-click resets. */
/* Identical to the IVR "add node" canvas resizer (.ivr-split-resizer): a full teal pill
   centered in the 16px gap to the left of the panel (used for both WhatsApp & IVR details). */
.tpl-preview-resizer {
  position: absolute; inset-block: 0; inset-inline-start: -16px; width: 16px; z-index: 6;
  display: flex; align-items: center; justify-content: center;
  cursor: col-resize; background: none; border: none;
}
/* Same grip + draggable-handle "nudge" movement as the Wallet & Balance resizer. */
.tpl-preview-grip {
  width: 8px; height: 54px; border-radius: 6px;
  background: var(--teal); opacity: 0.45;
  box-shadow: 0 1px 5px rgba(0, 0, 0, 0.2);
  transition: opacity .15s ease, height .15s ease, width .15s ease;
  animation: tpl-grip-nudge 1.7s ease-in-out 3;   /* nudge for the first ~5s, then rests */
}
.tpl-preview-resizer:hover .tpl-preview-grip,
.tpl-preview-resizer:focus-visible .tpl-preview-grip,
.tpl-preview-resizer:active .tpl-preview-grip {
  opacity: 1; width: 10px; height: 66px; animation: none;
}
@keyframes tpl-grip-nudge {
  0%, 100% { transform: scaleX(1); }
  50%      { transform: scaleX(1.85); }
}
/* (The resizer is now identical for WhatsApp & IVR — see .tpl-preview-resizer above.) */
/* Tooltip comes from the native title attribute only (matches the Wallet & Balance resizer) —
   no custom ::after bubble, so the hint shows once, not twice. */
.tpl-preview-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 14px;
  font-weight: 700;
  margin-bottom: 14px;
}
.tpl-preview-head .toggle {
  width: 26px; height: 26px;
  border-radius: 6px;
  background: var(--teal);
  color: white;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* WhatsApp bubble look — richer doodle pattern (phones, hearts, smileys,
   stars, books, food, etc.) tiled on a cream background. */
.tpl-wa-frame {
  border: 1px solid #E5E1D6;
  border-radius: 14px;
  background-color: #EFE8DD;
  background-image: url("../uploads/wa-chat-bg.svg");
  background-size: 480px 480px;
  background-repeat: repeat;
  padding: 18px;
  min-height: 300px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  position: relative;
  overflow: hidden;
}

/* "All Options" sheet that slides up over the chat preview */
.tpl-wa-allopts-scrim {
  position: absolute;
  inset: 0;
  background: rgba(20, 30, 36, 0.18);
  border-radius: 14px;
  pointer-events: none;
  animation: tplWaScrim 0.18s ease;
}
@keyframes tplWaScrim { from { opacity: 0; } to { opacity: 1; } }
.tpl-wa-allopts-sheet {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  background: white;
  border-top-left-radius: 14px;
  border-top-right-radius: 14px;
  box-shadow: 0 -6px 20px rgba(0,0,0,0.10);
  padding: 8px 0 14px;
  display: flex;
  flex-direction: column;
  animation: tplWaSheetUp 0.22s cubic-bezier(.2,.7,.2,1);
}
@keyframes tplWaSheetUp { from { transform: translateY(100%); } to { transform: translateY(0); } }
.tpl-wa-allopts-sheet .grip {
  width: 36px; height: 4px;
  background: #cfd6dc;
  border-radius: 2px;
  margin: 0 auto 6px;
}
.tpl-wa-allopts-sheet .head {
  display: grid;
  grid-template-columns: 36px 1fr 36px;
  align-items: center;
  padding: 6px 12px 10px;
}
.tpl-wa-allopts-sheet .head .x {
  color: var(--text-muted);
  cursor: pointer;
  display: inline-flex;
  justify-content: center;
  align-items: center;
  width: 28px; height: 28px;
  border-radius: 6px;
}
.tpl-wa-allopts-sheet .head .x:hover { background: #f1f3f4; color: var(--text); }
.tpl-wa-allopts-sheet .head .title {
  text-align: center;
  font-weight: 700;
  font-size: 13px;
  color: var(--text);
}
.tpl-wa-allopts-sheet .list { padding: 0 8px; max-height: 220px; overflow-y: auto; }
.tpl-wa-allopts-sheet .row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 13px;
  color: #128c7e; /* WhatsApp-ish green */
  cursor: pointer;
}
.tpl-wa-allopts-sheet .row:hover { background: #f3f8f5; }
.tpl-wa-allopts-sheet .row .row-ic { display: inline-flex; }
.tpl-wa-allopts-sheet .divider {
  height: 1px;
  background: var(--border);
  margin: 4px 12px;
}

/* Header toggle: highlight when sheet open */
.tpl-preview-head .toggle.is-open {
  background: #0a3338;
}

/* ===== Emoji picker (Body toolbar) ===== */
.tpl-toolbar-btn.is-active { background: #eef2f4; color: var(--text); }
.tpl-emoji-picker {
  position: absolute;
  right: 0;
  bottom: calc(100% + 6px);
  width: 340px;
  max-height: 360px;
  background: white;
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.14), 0 2px 6px rgba(0,0,0,0.05);
  z-index: 1500;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
body[dir="rtl"] .tpl-emoji-picker { right: auto; left: 0; }
.tpl-emoji-picker-body {
  flex: 1;
  overflow-y: auto;
  padding: 10px 10px 6px;
}
.tpl-emoji-section-title {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  margin: 6px 4px 4px;
  text-transform: none;
}
.tpl-emoji-grid {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 2px;
}
.tpl-emoji-btn {
  background: transparent;
  border: 0;
  cursor: pointer;
  font-size: 20px;
  line-height: 1;
  padding: 6px 4px;
  border-radius: 6px;
  transition: background-color 0.12s ease;
  font-family: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", system-ui, sans-serif;
}
.tpl-emoji-btn:hover { background: #f1f3f4; }
.tpl-emoji-tabs {
  display: flex;
  border-top: 1px solid var(--border);
  background: #fafbfc;
  padding: 4px 6px;
  gap: 2px;
  overflow-x: auto;
}
.tpl-emoji-tab {
  background: transparent;
  border: 0;
  cursor: pointer;
  padding: 6px 8px;
  color: var(--text-muted);
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 1;
  min-width: 28px;
}
.tpl-emoji-tab:hover { background: #eef2f4; color: var(--text); }
.tpl-emoji-tab.is-active {
  background: #e8eef0;
  color: var(--teal);
  position: relative;
}
.tpl-emoji-tab.is-active::after {
  content: '';
  position: absolute;
  left: 12%;
  right: 12%;
  bottom: 2px;
  height: 2px;
  background: var(--teal);
  border-radius: 1px;
}
.tpl-wa-frame__legacy_inline_pattern_unused {
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='480' height='480' viewBox='0 0 480 480'><g fill='none' stroke='%23d2c8b3' stroke-width='1.2' stroke-linecap='round' stroke-linejoin='round' opacity='0.55'><circle cx='30' cy='30' r='8'/><path d='M26 30h8M30 26v8'/><path d='M58 18c0-3 3-6 6-6s6 3 6 6c0 5-6 11-6 11s-6-6-6-11z'/><circle cx='100' cy='28' r='9'/><path d='M96 26a2 2 0 1 1 4 0M104 26a2 2 0 1 1-4 0M96 32c2 2 6 2 8 0'/><path d='M132 18l4 8 9 1-7 6 2 9-8-5-8 5 2-9-7-6 9-1z'/><rect x='170' y='14' width='14' height='22' rx='2.5'/><line x1='173' y1='32' x2='181' y2='32'/><path d='M210 18l8-8M218 18l-8-8M214 14v8'/><circle cx='250' cy='28' r='7'/><path d='M250 21v4M255 28h-4M250 35v-4M245 28h4'/><rect x='280' y='14' width='22' height='14' rx='2'/><path d='M280 18h22'/><path d='M324 30c-3-3-3-8 0-11s8-3 11 0c2 2 2 5 0 7l-6 6-5-2z'/><path d='M360 16c4-4 10-4 14 0s4 10 0 14l-7 7-7-7c-4-4-4-10 0-14z'/><path d='M400 18l5 6h-3v6h-4v-6h-3z'/><circle cx='434' cy='28' r='8'/><path d='M430 28l4 4 6-8'/><path d='M460 14v22M455 18l5-4 5 4M455 32l5 4 5-4'/><path d='M14 70c0-4 4-7 8-7s8 3 8 7c0 6-8 12-8 12s-8-6-8-12z'/><rect x='52' y='62' width='18' height='24' rx='3'/><line x1='58' y1='82' x2='64' y2='82'/><path d='M94 64a6 6 0 1 1 12 0c0 4-6 4-6 7M100 78h.01'/><path d='M130 70c0-3 3-6 6-6h12M148 76l-4-4-4 4'/><circle cx='180' cy='76' r='9'/><path d='M174 76h12M180 70v12'/><rect x='208' y='66' width='20' height='14' rx='1.5'/><line x1='208' y1='72' x2='228' y2='72'/><path d='M260 64v18M254 66l6-4 6 4'/><path d='M290 62a6 6 0 0 1 12 0v6h-12z'/><line x1='290' y1='68' x2='302' y2='68'/><line x1='292' y1='72' x2='300' y2='72'/><path d='M328 64l3 6h6l-5 4 2 6-6-4-6 4 2-6-5-4h6z'/><path d='M360 70a4 4 0 1 1 8 0c0 3-4 6-4 6s-4-3-4-6zM364 80h.01'/><circle cx='400' cy='72' r='8'/><path d='M396 72a2 2 0 1 1 4 0M404 72a2 2 0 1 1-4 0M396 76h8'/><path d='M435 64l9 6-9 6M444 64v12'/><path d='M14 118l8-8 8 8M22 110v18'/><rect x='52' y='110' width='22' height='18' rx='3'/><line x1='52' y1='116' x2='74' y2='116'/><circle cx='100' cy='120' r='8'/><path d='M96 120h8M100 116v8'/><path d='M130 112c4-4 12-4 16 0M134 124l4-4 4 4'/><path d='M168 110c0-4 4-7 8-7s8 3 8 7c0 7-8 16-8 16s-8-9-8-16z'/><circle cx='176' cy='110' r='2'/><path d='M210 122a6 6 0 1 1 12 0M212 116c0-4 3-6 4-6s4 2 4 6'/><rect x='248' y='108' width='22' height='14' rx='2'/><path d='M248 114h22M260 122v6'/><circle cx='298' cy='118' r='7'/><path d='M298 113v5l3 2'/><path d='M328 118c0-4 4-7 8-7s8 3 8 7-8 12-8 12-8-8-8-12z'/><line x1='370' y1='110' x2='370' y2='128'/><line x1='362' y1='118' x2='378' y2='118'/><circle cx='370' cy='112' r='2'/><path d='M402 118a4 4 0 1 1 8 0c0 3-4 5-4 5s-4-2-4-5z'/><rect x='434' y='106' width='14' height='22' rx='3'/><path d='M438 110h6M438 124h6M438 117h6'/><path d='M14 160l9 6-9 6M14 160v12'/><circle cx='50' cy='168' r='9'/><path d='M46 168a2 2 0 1 1 4 0M54 168a2 2 0 1 1-4 0M48 172c1 2 5 2 6 0'/><path d='M84 158l4 8 9 1-7 6 2 9-8-5-8 5 2-9-7-6 9-1z'/><rect x='124' y='158' width='18' height='22' rx='3'/><line x1='128' y1='176' x2='138' y2='176'/><path d='M170 162c4-4 10-4 14 0M174 174l3-3 3 3'/><circle cx='210' cy='168' r='9'/><path d='M210 161v14M203 168h14'/><path d='M242 160l3 7h7l-6 5 3 8-7-5-7 5 3-8-6-5h7z'/><rect x='284' y='154' width='14' height='22' rx='2'/><path d='M284 158h14'/><path d='M328 168a6 6 0 1 1 12 0c0 5-12 12-12 12s-12-7-12-12'/><path d='M360 158v22M354 162l6-4 6 4'/><path d='M390 158l8 22'/><circle cx='430' cy='168' r='8'/><path d='M425 168h10M430 163v10'/><path d='M14 210c4-4 12-4 16 0'/><circle cx='48' cy='208' r='8'/><path d='M48 200v8l5 3'/><path d='M82 204a4 4 0 0 1 8 0c0 3-4 4-4 7M86 220h.01'/><rect x='118' y='198' width='20' height='14' rx='2'/><line x1='118' y1='204' x2='138' y2='204'/><path d='M170 198l8 16-16 0z'/><circle cx='208' cy='208' r='8'/><path d='M204 208a2 2 0 1 1 4 0M212 208a2 2 0 1 1-4 0M204 212c1 2 5 2 6 0'/><path d='M240 200v18M232 206l8-4 8 4M232 214l8 4 8-4'/><rect x='282' y='196' width='14' height='22' rx='3'/><path d='M286 200h6M286 214h6'/><path d='M324 198c4-4 12-4 16 0s4 12 0 16l-8 8-8-8c-4-4-4-12 0-16z'/><circle cx='370' cy='208' r='8'/><path d='M366 208l4 4 6-8'/><path d='M410 198l3 6h6l-5 4 2 6-6-4-6 4 2-6-5-4h6z'/><circle cx='450' cy='208' r='6'/><path d='M450 204v4l2 2'/><path d='M14 252c0-4 4-7 8-7s8 3 8 7M14 256h16'/><rect x='50' y='244' width='18' height='22' rx='3'/><line x1='52' y1='262' x2='66' y2='262'/><circle cx='100' cy='254' r='9'/><path d='M96 254a2 2 0 1 1 4 0M104 254a2 2 0 1 1-4 0M96 258c2 2 6 2 8 0'/><path d='M134 244l4 8 9 1-7 6 2 9-8-5-8 5 2-9-7-6 9-1z'/><path d='M172 244l8 22M168 254l16-4'/><circle cx='208' cy='254' r='8'/><path d='M208 247v14M201 254h14'/><path d='M240 248c4-4 12-4 16 0s4 12 0 16M242 260l4 4 4-4'/><rect x='278' y='244' width='22' height='14' rx='2'/><line x1='278' y1='250' x2='300' y2='250'/><path d='M322 254a4 4 0 1 1 8 0c0 3-4 5-4 5s-4-2-4-5z'/><circle cx='358' cy='254' r='9'/><path d='M358 248v6l4 4'/><path d='M390 244v22M384 248l6-4 6 4M384 262l6 4 6-4'/><path d='M422 246l8 14-16 0z'/><circle cx='456' cy='254' r='6'/><path d='M14 296c0-3 3-6 6-6h12M18 304l-4-4 4-4'/><path d='M50 290l3 6h6l-5 4 2 6-6-4-6 4 2-6-5-4h6z'/><rect x='86' y='284' width='22' height='14' rx='2'/><line x1='86' y1='290' x2='108' y2='290'/><circle cx='138' cy='294' r='8'/><path d='M134 294a2 2 0 1 1 4 0M142 294a2 2 0 1 1-4 0M134 298c2 2 6 2 8 0'/><path d='M170 286c0-4 4-7 8-7s8 3 8 7c0 6-8 14-8 14s-8-8-8-14z'/><path d='M208 284v22M202 288l6-4 6 4'/><rect x='240' y='282' width='14' height='22' rx='2'/><path d='M244 286h6M244 300h6'/><path d='M278 286a6 6 0 1 1 12 0c0 5-12 12-12 12s-12-7-12-12'/><circle cx='320' cy='294' r='9'/><path d='M316 294l4 4 6-8'/><path d='M354 286l3 6h6l-5 4 2 6-6-4-6 4 2-6-5-4h6z'/><rect x='388' y='280' width='18' height='22' rx='3'/><line x1='392' y1='298' x2='402' y2='298'/><circle cx='430' cy='294' r='7'/><path d='M14 346c4-4 10-4 14 0M18 358l4-4 4 4'/><circle cx='50' cy='344' r='8'/><path d='M50 336v8l4 4'/><path d='M86 336l3 7h7l-6 5 3 8-7-5-7 5 3-8-6-5h7z'/><rect x='124' y='332' width='14' height='22' rx='2'/><line x1='128' y1='350' x2='134' y2='350'/><path d='M168 336l8-8 8 8M176 328v18'/><circle cx='208' cy='344' r='9'/><path d='M204 344a2 2 0 1 1 4 0M212 344a2 2 0 1 1-4 0M204 348c2 2 6 2 8 0'/><path d='M240 336c4-4 10-4 14 0s4 10 0 14M242 350l4 4 4-4'/><path d='M280 336v22M272 340l8-4 8 4M272 354l8 4 8-4'/><rect x='306' y='332' width='22' height='14' rx='2'/><path d='M306 336h22M318 346v6'/><circle cx='358' cy='344' r='7'/><path d='M358 339v5l3 2'/><path d='M390 336v22M384 340l6-4 6 4M384 354l6 4 6-4'/><path d='M428 336a4 4 0 1 1 8 0c0 3-4 5-4 5s-4-2-4-5z'/><path d='M14 386l8 22'/><circle cx='48' cy='394' r='9'/><path d='M48 387v14M41 394h14'/><path d='M84 386l4 8 9 1-7 6 2 9-8-5-8 5 2-9-7-6 9-1z'/><rect x='124' y='380' width='22' height='18' rx='3'/><line x1='124' y1='386' x2='146' y2='386'/><path d='M170 388a6 6 0 1 1 12 0c0 5-12 12-12 12s-12-7-12-12'/><circle cx='210' cy='394' r='8'/><path d='M206 394a2 2 0 1 1 4 0M214 394a2 2 0 1 1-4 0M206 398c1 2 5 2 6 0'/><path d='M240 380v22M234 384l6-4 6 4'/><path d='M276 388c4-4 10-4 14 0M280 400l3-3 3 3'/><rect x='304' y='382' width='14' height='22' rx='2'/><path d='M308 386h6M308 400h6'/><circle cx='340' cy='394' r='8'/><path d='M340 386v8l5 3'/><path d='M374 386l3 7h7l-6 5 3 8-7-5-7 5 3-8-6-5h7z'/><path d='M410 386l8 22M414 396l-2 8'/><circle cx='446' cy='394' r='8'/><path d='M450 386l-4 8 4 4'/><path d='M14 436l5 6h-3v6h-4v-6h-3z'/><rect x='44' y='426' width='18' height='22' rx='3'/><line x1='48' y1='444' x2='58' y2='444'/><path d='M84 430a4 4 0 1 1 8 0c0 3-4 5-4 5s-4-2-4-5zM88 442h.01'/><circle cx='126' cy='436' r='8'/><path d='M122 436a2 2 0 1 1 4 0M130 436a2 2 0 1 1-4 0M122 440c1 2 5 2 6 0'/><path d='M158 428l3 6h6l-5 4 2 6-6-4-6 4 2-6-5-4h6z'/><path d='M196 426c0-4 4-7 8-7s8 3 8 7c0 7-8 16-8 16s-8-9-8-16z'/><rect x='232' y='424' width='14' height='22' rx='2'/><path d='M232 428h14'/><circle cx='276' cy='436' r='9'/><path d='M276 429v14M269 436h14'/><path d='M310 426c4-4 12-4 16 0s4 12 0 16M312 438l4 4 4-4'/><path d='M348 426l8 22M348 436l16-2'/><circle cx='386' cy='436' r='8'/><path d='M382 436l4 4 6-8'/><path d='M416 428l5 8h-3v6h-4v-6h-3z'/><path d='M450 426v22M444 430l6-4 6 4M444 444l6 4 6-4'/></g></svg>");
  background-size: 380px 380px;
  background-repeat: repeat;
  padding: 18px;
  min-height: 300px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
/* Wrapper that contains the bubble + its actions so they share a common
   width — the column sizes to the wider child (typically the action label),
   capped at the frame's max-width. Both children stretch to that width. */
.tpl-wa-bubble-group {
  display: inline-flex;
  flex-direction: column;
  align-self: flex-start;
  max-width: 88%;
  min-width: 0;
}
.tpl-wa-bubble {
  background: white;
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--text);
  align-self: stretch;
  box-shadow: 0 1px 2px rgba(0,0,0,0.06);
  position: relative;
  min-width: 0;
}
.tpl-wa-bubble.with-media {
  padding: 4px 4px 8px;
}
.tpl-wa-bubble.has-actions {
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
}
.tpl-wa-bubble .media {
  width: 100%;
  height: 110px;
  border-radius: 8px;
  background-size: cover;
  background-position: center;
  margin-bottom: 6px;
  position: relative;
}
.tpl-wa-bubble .body { padding: 0 8px; }
.tpl-wa-bubble .ts { font-size: 9.5px; color: var(--text-muted); text-align: end; margin-top: 6px; }
.tpl-wa-bubble strong { font-weight: 700; }

.tpl-wa-actions {
  display: flex;
  flex-direction: column;
  gap: 0;
  /* Actions live INSIDE .tpl-wa-bubble-group, so they auto-stretch to the
     group width. No fixed % needed. */
  align-self: stretch;
  width: 100%;
  min-width: 0;
}
.tpl-wa-action {
  background: white;
  padding: 11px 14px;
  font-size: 13px;
  font-weight: 600;
  color: #137A8A;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  cursor: pointer;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  border-top: 1px solid #EFEFEF;
  box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}
.tpl-wa-action:first-child { border-radius: 0; border-top: 1px solid #EFEFEF; }
.tpl-wa-action:last-child  { border-radius: 0 0 12px 12px; }
.tpl-wa-action:only-child  { border-radius: 0 0 12px 12px; }
.tpl-wa-action-ic {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #137A8A;
  flex-shrink: 0;
}

/* Sign-up modal sheet inside the preview */
.tpl-wa-sheet {
  background: white;
  border-radius: 14px;
  margin-top: auto;
  padding: 14px 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  position: relative;
}
.tpl-wa-sheet .head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12.5px;
  font-weight: 600;
}
.tpl-wa-sheet .head .x { color: var(--text-muted); cursor: pointer; }
.tpl-wa-sheet .grip {
  position: absolute;
  top: 6px;
  inset-inline-start: 50%;
  transform: translateX(-50%);
  width: 32px; height: 4px;
  background: #D1D5DB;
  border-radius: 2px;
}
.tpl-wa-sheet .field {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 11.5px;
  color: var(--text-faint);
}
.tpl-wa-sheet .submit {
  background: #ECF0F1;
  color: var(--text-faint);
  border-radius: 999px;
  padding: 8px;
  font-size: 12px;
  font-weight: 600;
  text-align: center;
  margin-top: 4px;
}

/* ==================== TEMPLATE DETAILS PAGE ==================== */
/* Template Details page — mirrors User Profile (.ud-wrap / .ud-top-bar / .ud-card) */
.td-wrap {
  background: #fff;
  width: 100%;
  display: flex;
  flex-direction: column;
}
.td-top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: white;
  border-bottom: 1px solid var(--border);
  padding: 0 28px;
  height: 56px;
  flex-shrink: 0;
  margin: -20px -24px 0;  /* extend to .content-body edges */
}
.td-top-left { display: flex; align-items: center; gap: 10px; }
.td-top-name { font-size: 15px; font-weight: 700; color: var(--teal); }
.td-top-actions { display: flex; gap: 10px; }
.td-top-actions .btn {
  height: 34px;
  padding: 0 18px;
  font-size: 13px;
  font-weight: 500;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
/* Cards use the same chrome as .ud-card */
.td-wrap .tpl-details-card,
.td-wrap .tpl-decision-card {
  margin: 24px 0 0;
  border: 1px solid var(--border-2);
  border-radius: 10px;
}
.td-wrap .tpl-details-card:last-child { margin-bottom: 24px; }
/* Share view: balanced, tighter spacing around the read-only note so the gap
   between the Aramco top bar and the Template Details card isn't lopsided. */
.td-wrap .tpl-share-note { margin-top: 16px; margin-bottom: 0; }
.td-wrap .tpl-share-note + .tpl-details-card { margin-top: 16px; }

.tpl-details-card {
  background: white;
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
  margin-bottom: 18px;
}
.tpl-details-card .hd {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  font-weight: 700;
}
.tpl-details-grid {
  padding: 18px 22px;
  display: grid;
  grid-template-columns: 1fr 1fr 1fr 1fr;
  gap: 18px 24px;
}
.tpl-details-grid.cols-3 { grid-template-columns: 1fr 1fr 1fr; }
.tpl-d-field { display: flex; flex-direction: column; gap: 3px; }
.tpl-d-field .lab { font-size: 13px; color: var(--text-muted); }
.tpl-d-field .val { font-size: 13px; font-weight: 600; color: var(--text); }
.tpl-d-field.full { grid-column: 1 / -1; }
.tpl-d-field .pill-row { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
/* Editable "Shared With" inside the details grid (IVR Share view) — spans 2 cols
   so the multi-select has room, and the optional hint sits next to the label. */
.tpl-d-field.tpl-d-share-edit { grid-column: span 2; gap: 6px; }
.tpl-d-field.tpl-d-share-edit .opt { color: var(--text-muted); font-weight: 400; font-size: 11px; }

.tpl-history-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}
.tpl-history-table thead {
  background: #f6f6f6;
}
.tpl-history-table thead th {
  text-align: start;
  padding: 10px 18px;
  font-size: 11px;
  font-weight: 500;
  color: var(--text-muted);
  background: #f6f6f6;
  border-bottom: 1px solid var(--border-2);
}
.tpl-history-table tbody td {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border-2);
}
.tpl-history-table tbody tr:last-child td { border-bottom: none; }
.tpl-history-action {
  font-style: italic;
  font-size: 12px;
}
.tpl-history-action.approved { color: var(--green); }
.tpl-history-action.pending  { color: var(--orange); }
.tpl-history-action.rejected { color: var(--red); }
/* Not-yet-reviewed (pending) level → plain muted "---", not a status pill. */
.tpl-history-na { color: var(--text-muted); }
/* "Pending" label shown beneath the "---" checker dash in a pending action-history row. */
.tpl-history-sub { display: block; margin-top: 2px; font-size: 11px; font-style: italic; font-weight: 500; color: var(--orange); }

/* Review decision card */
.tpl-decision-card {
  background: #F8F9FA;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 18px 22px;
  margin-bottom: 18px;
}
.tpl-decision-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.tpl-decision-head .ttl {
  font-size: 13px;
  font-weight: 600;
}
.tpl-decision-head .acts {
  display: flex; gap: 10px;
}
.btn-approve, .btn-reject {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: 999px;
  padding: 7px 16px;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
}
.btn-approve { background: var(--teal); color: white; }
.btn-approve.outline { background: white; color: var(--teal); border: 1px solid var(--teal); }
.btn-reject  { background: #DC2626; color: white; }
.btn-reject.outline { background: white; color: #DC2626; border: 1px solid #DC2626; }
.tpl-decision-foot {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 10px;
}
.tpl-decision-foot .save { background: #D1D5DB; color: white; border-radius: 8px; padding: 7px 18px; font-weight: 600; font-size: 12px; }
.tpl-decision-foot .save.active { background: var(--teal); color: white; }
.tpl-decision-foot .cancel { color: var(--text-muted); padding: 7px 14px; font-size: 12px; }

/* ==================== MODAL OVERLAYS ==================== */
.tpl-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  animation: fadeIn 0.15s;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.tpl-modal {
  background: white;
  border-radius: 14px;
  box-shadow: 0 24px 60px rgba(0,0,0,0.30);
  display: flex;
  flex-direction: column;
  max-width: calc(100vw - 32px);
  max-height: calc(100vh - 32px);
}
.tpl-modal-head {
  padding: 16px 22px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-2);
}
.tpl-modal-title { font-size: 15px; font-weight: 700; }
.tpl-modal-close {
  width: 28px; height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  color: var(--text-muted);
}
.tpl-modal-close:hover { background: var(--bg-hover); color: var(--text); }
.tpl-modal-body { padding: 18px 22px; overflow-y: auto; flex: 1; }
.tpl-modal-foot {
  padding: 14px 22px;
  border-top: 1px solid var(--border-2);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  align-items: center;
}
.tpl-modal-foot.with-note {
  justify-content: space-between;
}
.tpl-modal-note {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  color: var(--text-muted);
  font-style: italic;
}

/* Flow type modal — split layout (v2: matches "Flow type" design) */
.tpl-flow-type-modal {
  width: 860px;
  display: flex;
  flex-direction: column;
}
.tpl-flow-type-modal .tpl-modal-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
}
.tpl-flow-type-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  padding: 22px 26px;
}
/* Tab bar under the modal head */
.tpl-flow-type-tabs {
  display: flex;
  gap: 24px;
  padding: 0 26px;
  border-bottom: 1px solid var(--border-2);
}
.tpl-flow-type-tab {
  background: transparent;
  border: none;
  padding: 14px 4px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  margin-bottom: -1px;
  border-bottom: 2px solid transparent;
  letter-spacing: -0.005em;
}
.tpl-flow-type-tab:hover { color: var(--text); }
.tpl-flow-type-tab.active {
  color: var(--teal);
  font-weight: 700;
  border-bottom-color: var(--teal);
}
/* "Use existing" — search input + empty state inside the left list */
.tpl-flow-type-existing-search {
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0 14px;
  height: 40px;
  background: white;
  margin-bottom: 14px;
  color: var(--text-muted);
}
.tpl-flow-type-existing-search input {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  font-size: 13px;
  height: 100%;
  color: var(--text);
}
.tpl-flow-type-existing-search input::placeholder { color: var(--text-faint); }
.tpl-flow-type-empty {
  font-size: 13px;
  color: var(--text-muted);
  padding: 14px 16px;
  text-align: center;
  border: 1px dashed var(--border);
  border-radius: 10px;
}
.tpl-flow-type-list .tpl-flow-type-h {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  margin: 0 0 14px;
}
.tpl-flow-type-card {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  padding: 14px 16px;
  border: 1px solid transparent;
  border-radius: 12px;
  margin-bottom: 10px;
  cursor: pointer;
  background: transparent;
  transition: background 0.15s, border-color 0.15s;
}
.tpl-flow-type-card:hover:not(.disabled):not(.selected) { background: #FAFAFA; }
.tpl-flow-type-card.selected {
  background: #F3F8F5;
}
.tpl-flow-type-card.disabled {
  cursor: not-allowed;
}
.tpl-flow-type-card.disabled .tpl-flow-type-meta .name,
.tpl-flow-type-card.disabled .tpl-flow-type-meta .desc { color: var(--text-faint); }
.tpl-flow-type-radio {
  width: 20px; height: 20px;
  border-radius: 50%;
  border: 1.5px solid #C5CBD2;
  flex-shrink: 0;
  margin-top: 2px;
  background: white;
  position: relative;
  transition: all 0.15s;
}
.tpl-flow-type-card.selected .tpl-flow-type-radio,
.tpl-flow-type-radio.on {
  border-color: var(--teal);
  border-width: 2px;
}
.tpl-flow-type-radio.on::after,
.tpl-flow-type-card.selected .tpl-flow-type-radio::after {
  content: '';
  position: absolute;
  inset: 3px;
  border-radius: 50%;
  background: var(--teal);
}
.tpl-flow-type-meta { min-width: 0; }
.tpl-flow-type-card .name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.35;
}
.tpl-flow-type-card .desc {
  font-size: 12.5px;
  color: var(--text-muted);
  margin-top: 4px;
  line-height: 1.5;
}
.tpl-flow-type-card .name .coming {
  color: var(--text-faint);
  font-weight: 500;
  font-style: normal;
  margin-inline-start: 6px;
}

/* Preview side — grey wrapper + white question card + nav arrows */
.tpl-flow-type-preview {
  background: #F2F3F4;
  border-radius: 14px;
  padding: 22px 22px 18px;
  display: flex;
  flex-direction: column;
  position: relative;
  min-height: 460px;
}
.tpl-flow-type-preview .tpl-flow-type-preview-bar {
  height: 50px;
  background: #6F7882;
  border-radius: 12px;
  margin: 0;
  position: relative;
  z-index: 0;
}
.tpl-flow-type-preview .qcard {
  background: white;
  border-radius: 12px;
  padding: 18px 18px 22px;
  width: 100%;
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
  position: relative;
  z-index: 1;
  margin-top: -26px;
}
.tpl-flow-type-preview .qhead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}
.tpl-flow-type-preview .qhead-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}
.tpl-flow-type-preview .qhead .acts {
  display: flex;
  gap: 8px;
  color: var(--text-muted);
  align-items: center;
}
.tpl-flow-type-preview .qhead .act {
  display: inline-flex;
  align-items: center;
  cursor: pointer;
}
.tpl-flow-type-preview .qbig {
  font-size: 14px;
  font-weight: 600;
  color: var(--teal);
  margin-bottom: 10px;
  line-height: 1.4;
}
.tpl-flow-type-preview .qsmall {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 10px;
}
/* Small heading + comment/dropdown boxes in the phone preview (Get feedback flow). */
.tpl-flow-type-preview .qhsm,
.tpl-flow-edit-preview .qhsm {
  font-size: 14px; font-weight: 600; color: var(--teal);
  margin: 14px 0 8px; line-height: 1.4;
}
.tpl-flow-type-preview .qpara {
  font-size: 12.5px; color: var(--text-muted); margin-bottom: 10px; line-height: 1.5;
}
.tpl-flow-type-preview .qdrop {
  border: 1px solid var(--border); border-radius: 8px;
  padding: 11px 12px; font-size: 13px; color: var(--text); margin-bottom: 10px;
}
.tpl-flow-type-preview .qdrop.placeholder { color: var(--text-faint); }
.tpl-flow-type-preview .qopt {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 0;
  font-size: 13px;
  color: var(--text);
}
.tpl-flow-type-preview .qopt .cb {
  width: 16px; height: 16px;
  border: 1.5px solid #C5CBD2;
  border-radius: 4px;
  flex-shrink: 0;
}
.tpl-flow-type-preview .qfoot {
  margin-top: 16px;
  background: #ECEEF0;
  color: var(--text-faint);
  border-radius: 999px;
  padding: 10px;
  font-size: 13px;
  font-weight: 500;
  text-align: center;
}
/* Bottom arrow navigation (replaces the numeric pager) */
.tpl-flow-type-nav {
  margin-top: 22px;
  display: flex;
  gap: 10px;
  justify-content: center;
}
.tpl-flow-type-nav .nav-arrow {
  width: 38px; height: 38px;
  border-radius: 10px;
  background: white;
  border: 1px solid var(--border);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s;
}
.tpl-flow-type-nav .nav-arrow:hover { color: var(--text); }
.tpl-flow-type-nav .nav-arrow.active {
  background: var(--teal);
  border-color: var(--teal);
  color: white;
}
.tpl-flow-type-nav .nav-arrow.is-disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.tpl-flow-type-nav .nav-arrow.is-disabled:hover { color: inherit; }
body[dir="rtl"] .tpl-flow-type-nav .nav-arrow svg { transform: scaleX(-1); }
.tpl-flow-type-modal .tpl-modal-foot .btn-ghost-sm {
  background: transparent;
  color: var(--text-muted);
  border: none;
  padding: 8px 14px;
  font-size: 14px;
  font-weight: 500;
}
.tpl-flow-type-modal .tpl-modal-foot .btn-ghost-sm:hover { color: var(--text); }

/* Existing-flow picker (single radio list) */
.tpl-existing-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.tpl-existing-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  cursor: pointer;
}
.tpl-existing-row:hover { border-color: #d1d5db; }
.tpl-existing-row.selected { border-color: var(--teal); background: #F1F6F6; }
.tpl-existing-row .meta .name { font-size: 12.5px; font-weight: 600; color: var(--teal); }
.tpl-existing-row .meta .pub { font-size: 10.5px; color: var(--text-muted); margin-top: 2px; }

/* Flow editor — full modal (v2: matches "Flow type" design) */
.tpl-flow-editor {
  width: 1100px;
  height: 620px;
  display: flex;
  flex-direction: column;
}
.tpl-flow-editor .tpl-modal-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
}
.tpl-flow-editor-body {
  display: grid;
  grid-template-columns: 240px 1fr 360px;
  gap: 0;
  flex: 1;
  min-height: 0;
}
.tpl-flow-screens {
  border-inline-end: 1px solid var(--border-2);
  padding: 20px 18px;
  overflow-y: auto;
}
.tpl-flow-screens h5 {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  margin: 0 0 12px;
}
.tpl-flow-screen-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 14px;
  cursor: pointer;
  margin-bottom: 6px;
  border: 1px solid transparent;
  color: var(--text);
  transition: background 0.15s, border-color 0.15s;
}
.tpl-flow-screen-row:hover { background: #FAFAFA; }
.tpl-flow-screen-row.active {
  background: #F3F8F5;
  border-color: rgba(13, 63, 68, 0.18);
  color: var(--teal);
  font-weight: 600;
}
.tpl-flow-screen-row .grip {
  color: #B6BDC4;
  cursor: grab;
  font-size: 14px;
  line-height: 1;
  letter-spacing: -1px;
}
.tpl-flow-screen-row .lbl {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.tpl-flow-screen-row .x {
  color: var(--text-faint);
  cursor: pointer;
  display: inline-flex;
}
.tpl-flow-screen-row .x:hover { color: var(--red); }
.tpl-flow-add-new {
  display: flex; align-items: center; gap: 8px;
  font-size: 14px; color: var(--teal); font-weight: 500;
  padding: 10px 12px; cursor: pointer;
  margin-top: 4px;
}

/* Flow editor center — content sections + blocks */
.tpl-flow-edit {
  padding: 20px 22px;
  overflow-y: auto;
}
.tpl-flow-edit h5 {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  margin: 0 0 16px;
}

/* Collapsible section (Screen title, Button) */
.tpl-flow-section {
  border-radius: 12px;
  background: #F3F8F5;
  margin-bottom: 10px;
  overflow: hidden;
}
.tpl-flow-section-head {
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
}
.tpl-flow-section-head .ttl {
  font-size: 14px;
  font-weight: 600;
  color: var(--teal);
}
.tpl-flow-section-head .chev { color: var(--teal); display: inline-flex; }
.tpl-flow-section.open .tpl-flow-section-head { padding-bottom: 8px; }
.tpl-flow-section-body {
  padding: 0 16px 14px;
  background: #F3F8F5;
}
.tpl-flow-section-body .tpl-flow-mini-input {
  background: white;
  width: 100%;
  box-sizing: border-box;
}
/* (Required toggle styled as a Meta-style switch further below — see .tpl-flow-required-switch) */

/* Block (collapsible, with " . preview" subtitle when collapsed) */
.tpl-flow-block {
  border: 1px solid var(--border);
  border-radius: 12px;
  margin-bottom: 10px;
  overflow: hidden;
  background: white;
}
.tpl-flow-block-head {
  padding: 12px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  background: white;
  cursor: pointer;
}
.tpl-flow-block-head .grip {
  color: #B6BDC4;
  cursor: grab;
  font-size: 14px;
  line-height: 1;
  letter-spacing: -1px;
}
.tpl-flow-block-head .ttl {
  flex: 1;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--teal);
  display: inline-flex;
  align-items: center;
  min-width: 0;
}
.tpl-flow-block-head .ttl .ic {
  display: inline-flex;
  align-items: center;
  margin-inline-end: 6px;
  color: var(--teal);
}
.tpl-flow-block-head .ttl .nm { color: var(--teal); font-weight: 600; }
.tpl-flow-block-head .ttl .sub {
  color: var(--text-muted);
  font-weight: 400;
  margin-inline-start: 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.tpl-flow-block-head .acts {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--text-faint);
}
.tpl-flow-block-head .acts .chev { color: var(--text-muted); cursor: pointer; display: inline-flex; }
.tpl-flow-block-head .acts .icon-btn {
  width: 24px; height: 24px;
  background: transparent;
  border: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: 6px;
}
.tpl-flow-block-head .acts .icon-btn:hover { background: var(--bg-hover); color: var(--text); }
.tpl-flow-block-head .acts .icon-btn.danger:hover { color: var(--red); }
.tpl-flow-block-head .acts .icon-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.tpl-flow-block-body {
  padding: 12px 14px 14px;
  border-top: 1px solid var(--border-2);
  background: white;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.tpl-flow-mini-input {
  height: 38px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0 12px;
  font-size: 13px;
  background: white;
  outline: none;
  width: 100%;
  box-sizing: border-box;
}
.tpl-flow-mini-input:focus { border-color: var(--teal); }
.tpl-flow-mini-textarea {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 13px;
  background: white;
  resize: vertical;
  min-height: 72px;
  font-family: inherit;
  outline: none;
  width: 100%;
  box-sizing: border-box;
}

/* Add Content button (pill with chevron) */
.tpl-flow-add-content-wrap {
  position: relative;
  margin-top: 14px;
  display: inline-block;
}
.tpl-flow-add-content {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  background: white;
  color: var(--teal);
  border: 1px solid var(--teal);
  border-radius: 10px;
  padding: 12px;
  font-size: 12px;
  font-weight: 500;
  line-height: 1;
  cursor: pointer;
  letter-spacing: -0.005em;
  transition: background 0.15s, box-shadow 0.15s;
}
.tpl-flow-add-content:hover { background: #F3F8F5; }
.tpl-flow-add-content svg { color: var(--teal); flex-shrink: 0; }
.tpl-flow-add-content > span { line-height: 1; }

/* 2-level cascading Add Content menu (replaces flat menu in v2) */
.tpl-flow-add-content-menu.cascade {
  position: absolute;
  top: auto;
  bottom: calc(100% + 8px);
  inset-inline-start: 0;
  background: white;
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.12);
  padding: 6px;
  z-index: 50;
  min-width: 170px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.tpl-flow-add-content-menu.cascade .cat {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 8px;
  font-size: 12px;
  color: var(--text-muted);
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
}
.tpl-flow-add-content-menu.cascade .cat:hover,
.tpl-flow-add-content-menu.cascade .cat.active {
  background: var(--teal);
  color: white;
}
.tpl-flow-add-content-menu.cascade .cat .ic {
  display: inline-flex;
  align-items: center;
  color: inherit;
  width: 18px;
  justify-content: center;
}
.tpl-flow-add-content-menu.cascade .cat .lbl { flex: 1; }
.tpl-flow-add-content-menu.cascade .cat .chev { color: inherit; display: inline-flex; }

.tpl-flow-add-content-submenu {
  position: absolute;
  inset-inline-start: calc(100% + 4px);
  top: -6px;
  min-width: 170px;
  background: white;
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.12);
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
body[dir="rtl"] .tpl-flow-add-content-submenu { inset-inline-start: auto; inset-inline-end: calc(100% + 4px); }
.tpl-flow-add-content-submenu .sub-item {
  padding: 12px 14px;
  border-radius: 8px;
  font-size: 12px;
  color: var(--text);
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
}
.tpl-flow-add-content-submenu .sub-item:hover {
  background: var(--teal);
  color: white;
}

/* Image block: dashed drop zone with validation */
.tpl-flow-image {
  display: flex;
  flex-direction: column;
  gap: 0;
}
.tpl-flow-image-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 14px;
  background: white;
  border-radius: 10px;
}
.tpl-flow-image-head .lbl {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  color: var(--text);
  min-width: 0;
}
.tpl-flow-image-head .lbl .ic { color: var(--teal); display: inline-flex; }
.tpl-flow-image-head .lbl strong { color: var(--teal); font-weight: 600; }
.tpl-flow-image-head .lbl .dot { color: var(--text-muted); }
.tpl-flow-image-head .lbl em { font-style: italic; color: var(--text-muted); font-weight: 400; }
.tpl-flow-image-head .icon-btn {
  width: 28px; height: 28px;
  background: transparent; border: none;
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--text-muted); cursor: pointer; border-radius: 6px;
}
.tpl-flow-image-head .icon-btn:hover { background: var(--bg-hover); color: var(--red); }

.tpl-flow-image-drop {
  margin-top: 10px;
  border: 1.5px dashed #C5CBD2;
  border-radius: 10px;
  padding: 28px 20px;
  background: white;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}
.tpl-flow-image-drop .title {
  font-size: 12px;
  color: var(--text);
  line-height: 1.6;
}
.tpl-flow-image-drop .title .link {
  color: var(--teal);
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
  font-weight: 500;
}
.tpl-flow-image-drop .err {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--red);
  font-size: 12px;
  font-style: italic;
  font-weight: 500;
}
.tpl-flow-image-drop .err svg { color: var(--red); }
.tpl-flow-image-drop .hints {
  font-size: 11px;
  font-style: italic;
  color: var(--text-muted);
  line-height: 1.2;
}

/* Right preview pane (mirrors Flow Type preview look) */
.tpl-flow-edit-preview {
  background: #F2F3F4;
  padding: 22px 22px 22px;
  display: flex;
  flex-direction: column;
  border-inline-start: 1px solid var(--border-2);
  overflow-y: auto;
}
.tpl-flow-edit-preview-bar {
  height: 50px;
  background: #6F7882;
  border-radius: 12px;
  margin: 0;
  position: relative;
  z-index: 0;
}
.tpl-flow-edit-preview .qcard {
  background: white;
  border-radius: 12px;
  position: relative;
  z-index: 1;
  margin-top: -26px;
  padding: 18px 18px 22px;
  display: flex;
  flex-direction: column;
}
.tpl-flow-edit-preview .qhead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}
.tpl-flow-edit-preview .qhead-title { font-size: 14px; font-weight: 600; color: var(--text); }
.tpl-flow-edit-preview .qhead .acts { display: flex; gap: 8px; color: var(--text-muted); align-items: center; }
.tpl-flow-edit-preview .qhead .act { display: inline-flex; align-items: center; cursor: pointer; }
.tpl-flow-edit-preview .qbig {
  font-size: 14px; font-weight: 600; color: var(--teal);
  margin-bottom: 10px; line-height: 1.4;
}
.tpl-flow-edit-preview .qpara {
  font-size: 12.5px; color: var(--text-muted);
  margin-bottom: 10px; line-height: 1.5;
}
.tpl-flow-edit-preview .qsmall {
  font-size: 12px; color: var(--text-muted);
  margin: 4px 0 8px;
}
.tpl-flow-edit-preview .qopt {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 0; font-size: 13px; color: var(--text);
}
.tpl-flow-edit-preview .qopt .cb {
  width: 16px; height: 16px;
  border: 1.5px solid #C5CBD2;
  border-radius: 4px;
  flex-shrink: 0;
}
.tpl-flow-edit-preview .qdrop {
  font-size: 12.5px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  margin-bottom: 8px;
}
.tpl-flow-edit-preview .qdrop.placeholder { color: var(--text-faint); }
.tpl-flow-edit-preview .qimg {
  height: 80px;
  background: linear-gradient(135deg,#cbd5e1,#94a3b8);
  border-radius: 6px;
  margin-bottom: 10px;
}
.tpl-flow-edit-preview .qfoot {
  margin-top: 16px;
  background: #ECEEF0;
  color: var(--text-faint);
  border-radius: 999px;
  padding: 10px;
  font-size: 13px;
  font-weight: 500;
  text-align: center;
}

/* Footer note ghost-style Cancel button */
.tpl-flow-editor .tpl-modal-foot .btn-ghost-sm {
  background: transparent;
  color: var(--text-muted);
  border: none;
  padding: 8px 14px;
  font-size: 14px;
  font-weight: 500;
}
.tpl-flow-editor .tpl-modal-foot .btn-ghost-sm:hover { color: var(--text); }
.tpl-flow-editor .tpl-modal-note {
  font-size: 13px;
  color: var(--text-muted);
  font-style: normal;
}

/* Variable type popover */
.tpl-pop {
  position: absolute;
  background: white;
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 12px 30px rgba(0,0,0,0.12);
  padding: 4px;
  z-index: 30;
  min-width: 160px;
}
.tpl-pop .item {
  padding: 8px 12px;
  font-size: 12.5px;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.tpl-pop .item:hover { background: var(--bg-hover); }
.tpl-pop .item.selected { background: var(--teal); color: white; }
.tpl-pop .item .check { color: var(--green); }
.tpl-pop .item.selected .check { color: white; }

/* Submenu chevron arrow */
.tpl-submenu {
  position: absolute;
  inset-inline-start: 100%;
  top: 0;
  margin-inline-start: 6px;
  background: white;
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 12px 30px rgba(0,0,0,0.12);
  padding: 4px;
  min-width: 160px;
}

/* RTL chevron flips */
body[dir="rtl"] .tpl-submenu {
  inset-inline-start: auto;
  inset-inline-end: 100%;
  margin-inline-end: 6px;
}

/* Catch-all cursor pointer for clickable spans/divs that aren't <button> */
.tpl-row-menu .menu-item,
.tpl-tab,
.tpl-flow-card-head .remove,
.tpl-flow-card-head .title,
.tpl-add-btn,
.tpl-add-btn-menu .row,
.btn-create-tpl .ch-item,
.tpl-share-chip,
.tpl-share-row,
.tpl-share-selected-row .x,
.tpl-flow-saved-row .ed-btn,
.tpl-add-var,
.tpl-back,
.tpl-flow-screen-row,
.tpl-flow-block-head,
.tpl-flow-add-content,
.tpl-flow-add-new,
.tpl-flow-type-card,
.tpl-existing-row,
.tpl-input-counter,
.tpl-flow-saved-row .saved-pill,
.tpl-modal-close,
.tpl-modal-overlay {
  cursor: pointer;
}
.tpl-add-btn-menu .row.disabled { cursor: not-allowed; }
.tpl-modal { cursor: default; }

/* ============== Falcon / Client perspective picker ============== */
.tpl-picker-page {
  flex: 1;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 60px 32px 80px;
  background:
    radial-gradient(circle at 18% 18%, rgba(13, 63, 68, 0.06), transparent 55%),
    radial-gradient(circle at 82% 82%, rgba(0, 181, 167, 0.05), transparent 55%),
    var(--bg);
  min-height: 100%;
}
.tpl-picker-card {
  width: 100%;
  max-width: 880px;
  background: white;
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 36px 40px 40px;
  box-shadow: 0 12px 32px rgba(13, 63, 68, 0.06);
}
.tpl-picker-head h2 {
  font-size: 19px;
  font-weight: 600;
  margin: 0 0 6px 0;
  color: var(--text);
}
.tpl-picker-head p {
  font-size: 13px;
  color: var(--text-muted);
  margin: 0 0 28px 0;
  line-height: 1.5;
  max-width: 540px;
}
.tpl-picker-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.tpl-picker-tile {
  text-align: start;
  background: white;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 22px 22px 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  cursor: pointer;
  transition: all 0.18s ease;
  position: relative;
  overflow: hidden;
  min-height: 200px;
  font-family: inherit;
}
.tpl-picker-tile::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(0, 181, 167, 0), rgba(0, 181, 167, 0));
  transition: background 0.18s ease;
  pointer-events: none;
}
.tpl-picker-tile:hover {
  border-color: var(--teal);
  transform: translateY(-2px);
  box-shadow: 0 10px 24px rgba(0, 130, 122, 0.12);
}
.tpl-picker-tile .ic-wrap {
  width: 52px;
  height: 52px;
  border-radius: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-bottom: 4px;
}
.tpl-picker-tile.falcon .ic-wrap {
  background: linear-gradient(135deg, #0d3f44, #00827A);
  color: white;
}
.tpl-picker-tile.client .ic-wrap {
  background: #F1F6F6;
  color: #00827A;
}
.tpl-picker-tile .ttl {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}
.tpl-picker-tile .dsc {
  font-size: 12.5px;
  color: var(--text-muted);
  line-height: 1.5;
  flex: 1;
}
.tpl-picker-tile .cta {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--teal);
  margin-top: 6px;
}

/* ============== View badge + back-to-picker pill ============== */
.tpl-view-badge {
  display: inline-flex;
  align-items: center;
  font-size: 10.5px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 999px;
  letter-spacing: 0.02em;
  white-space: nowrap;
  margin-inline-start: 4px;
}
.tpl-view-badge.falcon {
  background: linear-gradient(135deg, #0d3f44, #00827A);
  color: white;
}
.tpl-view-badge.client {
  background: #F1F6F6;
  color: #00827A;
  border: 1px solid #C8DFDD;
}
.tpl-back-to-picker {
  margin-inline-start: auto;
  background: white;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 5px 11px;
  font-size: 11.5px;
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
  gap: 5px;
  cursor: pointer;
  transition: all 0.15s ease;
  font-family: inherit;
}
.tpl-back-to-picker:hover { border-color: var(--teal); color: var(--teal); }
.tpl-main-head .scope { gap: 10px; }

/* ============== Flow editor: block picker, contact group multi-select ============== */
.tpl-flow-block-picker {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  padding: 10px;
  background: #F8FAFA;
  border: 1px solid var(--border-2);
  border-radius: 10px;
  margin-top: 8px;
}
.tpl-flow-block-picker-tile {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: white;
  cursor: pointer;
  font-size: 12px;
  color: var(--text);
  font-family: inherit;
  text-align: start;
  transition: all 0.15s ease;
}
.tpl-flow-block-picker-tile:hover {
  border-color: var(--teal);
  color: var(--teal);
}
.tpl-flow-block-picker-tile .ic {
  width: 26px;
  height: 26px;
  border-radius: 7px;
  background: #F1F6F6;
  color: #00827A;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

/* Inline 'add block' affordance with chevron menu */
.tpl-flow-add-content-wrap { position: relative; display: inline-block; margin-top: 8px; }
.tpl-flow-add-content-menu {
  position: absolute;
  top: calc(100% + 6px);
  inset-inline-start: 0;
  background: white;
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
  padding: 6px;
  z-index: 50;
  min-width: 220px;
  display: grid;
  gap: 2px;
}
.tpl-flow-add-content-menu .opt {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 9px;
  border-radius: 7px;
  font-size: 12px;
  color: var(--text);
  cursor: pointer;
  font-family: inherit;
  background: transparent;
  border: none;
  width: 100%;
  text-align: start;
}
.tpl-flow-add-content-menu .opt:hover { background: #F1F6F6; color: var(--teal); }
.tpl-flow-add-content-menu .opt .ic {
  width: 22px; height: 22px; border-radius: 6px;
  background: #F1F6F6; color: #00827A;
  display: inline-flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}

/* Flow block: drag/delete affordances */
.tpl-flow-block-head .acts {
  margin-inline-start: auto;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.tpl-flow-block-head .icon-btn {
  width: 22px;
  height: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.12s ease;
}
.tpl-flow-block-head .icon-btn:hover { background: #F1F6F6; color: var(--teal); }
.tpl-flow-block-head .icon-btn.danger:hover { background: #FEF2F2; color: #DC2626; }

/* Contact group multi-select chip popover */
.tpl-cg-multi {
  position: relative;
}
.tpl-cg-multi-control {
  min-height: 38px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 36px 6px 10px;
  background: white;
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  align-items: center;
  cursor: pointer;
  position: relative;
  font-size: 13px;
  color: var(--text);
}
body[dir="rtl"] .tpl-cg-multi-control { padding: 6px 10px 6px 36px; }
.tpl-cg-multi-control:focus-within,
.tpl-cg-multi-control.open { border-color: var(--teal); }
.tpl-cg-multi-control .placeholder { color: var(--text-muted); font-size: 12.5px; }
.tpl-cg-multi-control .chev {
  position: absolute;
  inset-inline-end: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
}
.tpl-cg-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: #F1F6F6;
  color: #00827A;
  border-radius: 999px;
  padding: 2px 4px 2px 9px;
  font-size: 11.5px;
  font-weight: 500;
}
body[dir="rtl"] .tpl-cg-chip { padding: 2px 9px 2px 4px; }
.tpl-cg-chip .x {
  width: 16px; height: 16px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 50%;
  cursor: pointer;
  color: #00827A;
}
.tpl-cg-chip .x:hover { background: rgba(0, 130, 122, 0.15); }
.tpl-cg-multi-menu {
  position: absolute;
  top: calc(100% + 4px);
  inset-inline-start: 0;
  inset-inline-end: 0;
  background: white;
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
  padding: 4px;
  z-index: 100;
  max-height: 240px;
  overflow-y: auto;
}
.tpl-cg-multi-opt {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 7px;
  font-size: 12.5px;
  cursor: pointer;
  color: var(--text);
}
.tpl-cg-multi-opt:hover { background: #F1F6F6; }
.tpl-cg-multi-opt .cb {
  width: 14px;
  height: 14px;
  border: 1.5px solid var(--border);
  border-radius: 3px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  background: white;
  color: white;
}
.tpl-cg-multi-opt.checked .cb { background: var(--teal); border-color: var(--teal); }
.tpl-cg-multi-opt .meta { flex: 1; min-width: 0; }
.tpl-cg-multi-opt .meta .nm { font-weight: 500; }
.tpl-cg-multi-opt .meta .ct { font-size: 11px; color: var(--text-muted); }

/* ============ Country dropdown (Call Phone number) ============ */
.tpl-cc-wrap { position: relative; }
.tpl-cc-trigger {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
  height: 40px;
  padding: 0 12px;
  background: white;
  border: 1px solid var(--border);
  border-radius: 8px;
  font: inherit;
  color: var(--text);
  cursor: pointer;
  text-align: start;
  transition: border-color .15s, box-shadow .15s;
}
.tpl-cc-trigger:hover { border-color: #d1d5db; }
.tpl-cc-trigger:focus-visible,
.tpl-cc-wrap.open .tpl-cc-trigger { outline: none; border-color: var(--teal); box-shadow: 0 0 0 3px rgba(13, 63, 68, 0.08); }
.tpl-cc-flag { display: inline-flex; align-items: center; justify-content: center; width: 22px; height: 22px; border-radius: 50%; overflow: hidden; flex-shrink: 0; background: #f3f4f6; }
.tpl-cc-flag svg { width: 100%; height: 100%; display: block; }
.tpl-cc-flag-md { width: 26px; height: 26px; }
.tpl-cc-text { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.tpl-cc-chev { color: var(--text-muted); display: inline-flex; }

.tpl-cc-menu {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  z-index: 30;
  background: white;
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.12);
  max-height: 320px;
  display: flex;
  flex-direction: column;
}
.tpl-cc-search {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border-2);
  color: var(--text-muted);
}
.tpl-cc-search input {
  flex: 1;
  border: 0;
  outline: none;
  font: inherit;
  font-size: 13px;
  color: var(--text);
  background: transparent;
}
.tpl-cc-list { flex: 1; overflow-y: auto; padding: 4px; }
.tpl-cc-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border: 0;
  background: transparent;
  border-radius: 8px;
  cursor: pointer;
  font: inherit;
  text-align: start;
  color: var(--text);
}
.tpl-cc-item:hover { background: var(--bg-hover, #F5F5F5); }
.tpl-cc-item.is-active { background: rgba(13, 63, 68, 0.06); }
.tpl-cc-name { flex: 1; min-width: 0; font-size: 13px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tpl-cc-dial {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 52px;
  height: 24px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: 100px;
  font-size: 12px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}
.tpl-cc-empty { padding: 16px; text-align: center; color: var(--text-muted); font-size: 13px; }

/* Fixed-position variant escapes parent overflow:hidden (e.g. wizard cards) */
.tpl-cc-menu-fixed {
  position: fixed;
  top: 0;
  left: 0;
  right: auto;
  width: auto;
  z-index: 1000;
  max-height: 340px;
}

/* ============ Template wizard — Header media drop zone ============ */
.tpl-media-drop {
  border: 1.5px dashed var(--border);
  border-radius: 10px;
  background: #FAFBFC;
  padding: 28px 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  text-align: center;
  color: var(--text-2);
  transition: border-color 0.15s, background 0.15s;
  min-height: 110px;
}
.tpl-media-drop:hover { border-color: var(--teal); background: #F4F8F8; }
.tpl-media-drop-title { font-size: 13px; font-weight: 500; color: var(--text); }
.tpl-media-drop-sub { font-size: 12.5px; color: var(--text-muted); }
.tpl-media-drop-link { color: var(--teal); cursor: pointer; text-decoration: underline; }
.tpl-media-drop-hint { font-size: 11.5px; color: var(--text-faint); margin-top: 4px; }

/* Fixed-position variant of Add Button menu — escapes overflow:hidden parents
   and auto-flips above/below the trigger via JS coordinates. */
.tpl-add-btn-menu-fixed {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 1000;
}

/* ===== Complete Flow card — separate full-width file-actions row ===== */
.tpl-flow-btntext { min-width: 0; }
.tpl-flow-fileactions-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  background: #FAFBFC;
  border: 1px solid var(--border-2);
  border-radius: 10px;
}
.tpl-flow-fileactions-row .tpl-flow-action-btn { flex-shrink: 0; }
.tpl-flow-fileactions {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding-bottom: 2px;
}
.tpl-flow-filename {
  font-size: 13px;
  color: var(--text);
  font-weight: 500;
  white-space: nowrap;
}
.tpl-flow-fileactions-row .tpl-flow-filename {
  flex: 0 0 auto;
  max-width: none;
  overflow: visible;
  text-overflow: clip;
}
.tpl-flow-fileactions-row .tpl-flow-action-btn:first-of-type { margin-inline-start: auto; }
.tpl-flow-action-btn {
  height: 34px;
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: white;
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s;
}
.tpl-flow-action-btn:hover { background: var(--bg-hover); border-color: #d1d5db; }

/* ===== Flow Preview modal ===== */
.tpl-flow-preview-scrim {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
}
.tpl-flow-preview-modal {
  background: white;
  border-radius: 12px;
  width: min(900px, 100%);
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.tpl-flow-preview-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 20px 24px 16px;
  gap: 16px;
}
.tpl-flow-preview-title { font-size: 18px; font-weight: 600; color: var(--text); }
.tpl-flow-preview-sub { font-size: 13px; color: var(--text-muted); margin-top: 4px; }
.tpl-flow-preview-close {
  width: 32px; height: 32px;
  border: 0; background: transparent; cursor: pointer;
  color: var(--text-muted); border-radius: 6px;
  display: inline-flex; align-items: center; justify-content: center;
}
.tpl-flow-preview-close:hover { background: var(--bg-hover); color: var(--text); }

.tpl-flow-preview-body {
  flex: 1;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 8px 24px 16px;
  overflow-y: auto;
}
.tpl-flow-preview-phone {
  width: 320px;
  height: min(640px, calc(90vh - 180px));
  border: 1px solid var(--border-2);
  border-radius: 12px;
  background: white;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.08);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.tpl-flow-preview-phone-bar {
  height: 18px;
  background: #cbd5d2;
}
.tpl-flow-preview-phone-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border-2);
}
.tpl-flow-preview-phone-close {
  width: 24px; height: 24px;
  border: 0; background: transparent;
  color: var(--text); cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
}
.tpl-flow-preview-phone-title { flex: 1; text-align: center; font-size: 14px; color: var(--text); }
.tpl-flow-preview-phone-more { color: var(--text-muted); font-size: 18px; }
.tpl-flow-preview-phone-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 16px 18px 8px;
  font-size: 13px;
  color: var(--text);
}
.tpl-flow-preview-phone-body::-webkit-scrollbar { width: 6px; }
.tpl-flow-preview-phone-body::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.18); border-radius: 4px; }
.tpl-flow-preview-phone-body::-webkit-scrollbar-thumb:hover { background: rgba(0,0,0,0.32); }
.tpl-flow-preview-phone-head { flex-shrink: 0; }
.tpl-flow-preview-phone-foot { flex-shrink: 0; }
.tpl-flow-preview-phone-h { font-size: 16px; font-weight: 700; margin: 0 0 12px; }
.tpl-flow-preview-phone-q { font-size: 14px; font-weight: 500; margin: 8px 0; }
.tpl-flow-preview-phone-sub { font-size: 12px; color: var(--text-muted); margin: 6px 0; }
.tpl-flow-preview-phone-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid var(--border-2);
}
.tpl-flow-preview-phone-row:last-of-type { border-bottom: 0; }
.tpl-flow-preview-phone-radio {
  width: 18px; height: 18px;
  border: 1.5px solid var(--border);
  border-radius: 50%;
  flex-shrink: 0;
  transition: border-color 0.12s, background 0.12s, box-shadow 0.12s;
}
.tpl-flow-preview-phone-row { cursor: pointer; }
.tpl-flow-preview-phone-row:hover .tpl-flow-preview-phone-radio { border-color: var(--teal); }
.tpl-flow-preview-phone-radio.is-selected {
  border-color: var(--teal);
  background: radial-gradient(circle, var(--teal) 0 5px, white 6px);
}
.tpl-flow-preview-phone-divider {
  height: 1px;
  background: var(--border-2);
  margin: 14px 0 12px;
}
.tpl-flow-preview-phone-foot {
  padding: 12px 18px 16px;
  border-top: 1px solid var(--border-2);
}
.tpl-flow-preview-phone-send {
  width: 100%;
  height: 38px;
  border: 0;
  border-radius: 100px;
  background: #f0f2f5;
  color: var(--text-faint);
  font-size: 13px;
  font-weight: 500;
  cursor: not-allowed;
  transition: background 0.15s, color 0.15s;
}
.tpl-flow-preview-phone-send.is-active {
  background: var(--teal);
  color: white;
  cursor: pointer;
}
.tpl-flow-preview-phone-send.is-active:hover { background: var(--teal-hover); }
.tpl-flow-preview-phone-managed {
  margin-top: 10px;
  text-align: center;
  font-size: 11px;
  color: var(--text-muted);
}
.tpl-flow-preview-phone-managed span { color: var(--teal); cursor: pointer; }

.tpl-flow-preview-foot {
  display: flex;
  justify-content: flex-end;
  padding: 14px 24px;
  border-top: 1px solid var(--border-2);
  background: #FAFAFA;
}

/* ===== Call Phone — combined PhoneInput inside the button card ===== */
.tpl-flow-card .tpl-phone-field .otp-phone-wrap { width: 100%; }
.tpl-flow-card .tpl-phone-field .otp-phone-input { width: 100%; }
.tpl-flow-card .tpl-phone-field .req { color: #dc2626; margin-inline-start: 2px; }

/* ===== Visit Website — Dynamic URL variable chip ({{1}}) ===== */
.tpl-url-var-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 40px;
  padding: 0 14px;
  background: #FAFBFC;
  border: 1px dashed var(--border);
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  color: var(--teal);
  font-family: 'Courier New', monospace;
  align-self: end;
  cursor: default;
}
.tpl-url-var-chip .tpl-url-var-info { color: var(--text-muted); display: inline-flex; }
/* Variable URL sample (Dynamic URL button) — mirrors Meta's "Add sample URL":
   shows once a {{1}} variable is added to the URL, to capture a sample value. */
.tpl-url-sample-block {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}
.tpl-url-sample-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 4px;
}
.tpl-url-sample-desc {
  font-size: 12px;
  color: var(--text-2);
  line-height: 1.5;
  margin-bottom: 12px;
}
.tpl-url-sample-err {
  font-size: 12px;
  color: #d4351c;
  margin-top: 4px;
}

/* ===== Flow block — Required toggle (Meta style) ===== */
.tpl-flow-required {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  align-self: flex-end;
  margin-top: 6px;
  cursor: pointer;
  user-select: none;
}
.tpl-flow-required-lbl {
  font-size: 12px;
  color: var(--text-2);
}
.tpl-flow-required-switch {
  position: relative;
  width: 36px;
  height: 20px;
  border-radius: 100px;
  background: #d1d5db;
  transition: background 0.18s;
  flex-shrink: 0;
}
.tpl-flow-required-switch .knob {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  background: white;
  border-radius: 50%;
  box-shadow: 0 1px 2px rgba(0,0,0,0.2);
  transition: transform 0.18s;
}
.tpl-flow-required-switch.on { background: var(--teal); }
.tpl-flow-required-switch.on .knob { transform: translateX(16px); }

/* ===== Flow preview — date picker block ===== */
.qdate {
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border-2);
  border-radius: 8px;
  margin: 4px 0 2px;
  color: var(--text);
  background: white;
}
.qdate .qdate-text { font-size: 13px; color: var(--text-muted); }
.qdate svg { color: var(--text-muted); flex-shrink: 0; }
.qhelper { font-size: 11px; color: var(--text-muted); margin-top: 4px; }

/* ===== Flow block — input with right-aligned counter (Meta-style) ===== */
.tpl-flow-mini-input-wrap {
  position: relative;
  width: 100%;
}
.tpl-flow-mini-input-wrap .tpl-flow-mini-input {
  width: 100%;
  padding-right: 50px;
}
.tpl-flow-mini-counter {
  position: absolute;
  inset-inline-end: 10px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 11px;
  color: var(--text-faint);
  pointer-events: none;
}
body[dir="rtl"] .tpl-flow-mini-input-wrap .tpl-flow-mini-input { padding-right: 10px; padding-left: 50px; }
.tpl-flow-mini-label {
  font-size: 13px;
  color: var(--text);
  margin-top: 2px;
}
.tpl-flow-mini-label .opt { color: var(--text-muted); font-weight: 400; }

/* ===== Complete Flow (Create new variant) — dropdown + Edit + Delete row ===== */
.tpl-flow-newrow {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px 8px 12px;
  background: #FAFBFC;
  border: 1px solid var(--border-2);
  border-radius: 10px;
}
.tpl-flow-newrow-select {
  flex: 1;
  min-width: 0;
}
.tpl-flow-newrow .tpl-flow-action-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

/* ===== Flow preview — Paragraph input field ===== */
.qparaInput {
  width: 100%;
  border: 1px solid var(--border-2);
  border-radius: 8px;
  padding: 8px 10px;
  font: inherit;
  font-size: 13px;
  color: var(--text);
  background: white;
  resize: none;
  margin: 4px 0 2px;
}
.qparaInput::placeholder { color: var(--text-muted); }

/* ===== Flow editor — drag-and-drop reordering for content blocks ===== */
.tpl-flow-block .grip {
  cursor: grab;
  user-select: none;
  padding: 0 4px;
}
.tpl-flow-block .grip:active { cursor: grabbing; }
.tpl-flow-block.is-dragging {
  opacity: 0.5;
}
.tpl-flow-block.is-drag-over {
  outline: 2px dashed var(--teal);
  outline-offset: -2px;
  background: rgba(13, 63, 68, 0.04);
}

/* ===== Flow editor — Add content max-limit note + disabled state ===== */
.tpl-flow-add-max-note {
  font-size: 12px;
  color: var(--text-2);
  margin-bottom: 6px;
}
.tpl-flow-add-content.is-disabled,
.tpl-flow-add-content:disabled {
  background: #E5E7EA !important;
  color: var(--text-faint) !important;
  cursor: not-allowed !important;
  border-color: var(--border) !important;
  position: relative;
}
.tpl-flow-add-content.is-disabled svg,
.tpl-flow-add-content:disabled svg {
  color: var(--text-faint);
}
.tpl-flow-add-content.is-disabled::after,
.tpl-flow-add-content:disabled::after {
  content: '';
  position: absolute;
  width: 14px;
  height: 14px;
  border: 1.5px solid #dc2626;
  border-radius: 50%;
  bottom: -6px;
  inset-inline-end: -6px;
  background: white;
  background-image: linear-gradient(135deg, transparent calc(50% - 0.8px), #dc2626 calc(50% - 0.8px), #dc2626 calc(50% + 0.8px), transparent calc(50% + 0.8px));
}

/* ===== Opt-in block (Meta-style) — Label textarea + Read more link + buttons ===== */
.tpl-flow-optin-textarea {
  width: 100%;
  resize: vertical;
  min-height: 96px;
  padding-right: 60px;
  font-family: inherit;
  font-size: 13px;
}
.tpl-flow-optin-linkrow {
  display: flex;
  gap: 10px;
  margin-top: 4px;
}
.tpl-flow-optin-linkbtn {
  height: 36px;
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: white;
  color: var(--text);
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s;
}
.tpl-flow-optin-linkbtn:hover { background: var(--bg-hover); border-color: #d1d5db; }

/* Sub-screen (Read more) inside the screens list — indented under its parent */
.tpl-flow-screen-sub {
  padding-inline-start: 32px;
  font-size: 12.5px;
  color: var(--text-2);
  background: rgba(255, 255, 255, 0.5);
}
.tpl-flow-screen-sub.active { background: rgba(13, 63, 68, 0.06); color: var(--text); }


/* ===== Custom icon dropdown (Media sample, etc.) ===== */
.tpl-icon-select { position: relative; width: 100%; }
.tpl-icon-select-trigger {
  display: flex; align-items: center; justify-content: space-between;
  width: 100%; height: 38px; box-sizing: border-box;
  border: 1px solid var(--border); border-radius: 8px;
  padding: 0 12px;
  background: white; color: var(--text);
  font-size: 13px; font-family: inherit;
  cursor: pointer; outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.tpl-icon-select-trigger:hover { border-color: #cfd6dc; }
.tpl-icon-select.is-open .tpl-icon-select-trigger { border-color: var(--teal); box-shadow: 0 0 0 3px rgba(45, 212, 217, 0.12); }
.tpl-icon-select-current { display: inline-flex; align-items: center; gap: 8px; min-width: 0; }
.tpl-icon-select-ic { display: inline-flex; align-items: center; justify-content: center; width: 16px; height: 16px; flex-shrink: 0; }
.tpl-icon-select-chev { transition: transform 0.18s ease; flex-shrink: 0; }
.tpl-icon-select.is-open .tpl-icon-select-chev { transform: rotate(180deg); }

.tpl-icon-select-menu {
  position: absolute; top: calc(100% + 6px); left: 0; right: 0;
  background: white;
  border: 1px solid var(--border); border-radius: 10px;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.08), 0 2px 6px rgba(15, 23, 42, 0.04);
  padding: 6px;
  z-index: 10000;
  max-height: 320px; overflow-y: auto;
}
/* When the menu is positioned via JS (fixed coords), let the inline style win. */
.tpl-icon-select-menu-fixed { top: auto; bottom: auto; left: auto; right: auto; }
/* Open upward when there isn't enough room below the trigger */
.tpl-icon-select.drop-up .tpl-icon-select-menu:not(.tpl-icon-select-menu-fixed) {
  top: auto;
  bottom: calc(100% + 6px);
  box-shadow: 0 -8px 24px rgba(15, 23, 42, 0.08), 0 -2px 6px rgba(15, 23, 42, 0.04);
}
.tpl-icon-select.drop-up .tpl-icon-select-menu-fixed {
  box-shadow: 0 -8px 24px rgba(15, 23, 42, 0.08), 0 -2px 6px rgba(15, 23, 42, 0.04);
}
/* Chevron flips down when the dropdown is opening upward */
.tpl-icon-select.is-open.drop-up .tpl-icon-select-chev { transform: none; }
.tpl-icon-select.is-open:not(.drop-up) .tpl-icon-select-chev { transform: rotate(180deg); }
.tpl-icon-select-row {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: 8px;
  cursor: pointer; user-select: none;
  transition: background-color 0.12s ease;
}
.tpl-icon-select-row:hover { background: #F4F6F8; }
.tpl-icon-select-row.is-selected { background: #f3f8f5; }
.tpl-icon-select-row.is-selected .tpl-icon-select-label { color: var(--text); font-weight: 500; }

.tpl-icon-select-label { font-size: 13px; color: var(--text); }

/* Disabled state for the reusable dropdown */
.tpl-icon-select.is-disabled .tpl-icon-select-trigger {
  background: #F2F4F6;
  color: var(--text-muted);
  cursor: not-allowed;
}
.tpl-icon-select.is-disabled .tpl-icon-select-chev { opacity: 0.4; }

/* Validity period: warning hint banner under the dropdown */
.tpl-auth-validity-hint {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-top: 10px;
  padding: 10px 12px;
  background: #fdf4dc;
  border-radius: 8px;
  font-size: 12px;
  line-height: 1.5;
  color: #7a5800;
}
.tpl-auth-validity-hint svg { flex-shrink: 0; margin-top: 1px; color: #c98b15; }

/* ===== Single-page "Edit Template" screen ===== */
.tpl-edit-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px 20px;
  margin-bottom: 18px;
}
.tpl-edit-grid .tpl-field { margin: 0; }
/* Template ID — the one field that is locked in edit mode */
.tpl-field-input.is-locked {
  background: #f1f3f5; color: var(--text-muted); cursor: not-allowed;
  border-color: var(--border); -webkit-text-fill-color: var(--text-muted); opacity: 1;
}
/* Compact "Shared With" multi-select */
.tpl-share-multi-wrap { position: relative; }
.tpl-share-multi-trigger {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  width: 100%; text-align: start; cursor: pointer; background: #fff;
}
.tpl-share-multi-trigger.open { border-color: var(--teal); }
.tpl-share-multi-trigger .ph { color: var(--text-faint); }
.tpl-share-multi-trigger svg { color: var(--text-muted); flex-shrink: 0; }
.tpl-share-multi-pop {
  position: absolute; z-index: 40; top: calc(100% + 4px); left: 0; right: 0;
  background: #fff; border: 1px solid var(--border); border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.12); padding: 6px; max-height: 240px; overflow-y: auto;
}
.tpl-share-multi-opt {
  display: flex; align-items: center; gap: 9px; padding: 8px 10px; border-radius: 7px;
  cursor: pointer; font-size: 13.5px; color: var(--text);
}
.tpl-share-multi-opt:hover { background: #f3f6f6; }
.tpl-share-multi-opt .cb {
  width: 16px; height: 16px; border: 1.5px solid #c5cbd2; border-radius: 4px;
  display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; color: #fff;
}
.tpl-share-multi-opt.on .cb { background: var(--teal); border-color: var(--teal); }
.tpl-share-multi-empty { padding: 12px; color: var(--text-muted); font-size: 13px; text-align: center; }
.tpl-share-multi-opt.all { font-weight: 600; color: var(--teal); }
.tpl-share-multi-sep { height: 1px; background: var(--border); margin: 4px 6px; }

/* ===== Share mode — the Edit screen rendered read-only, only "Shared With" enabled ===== */
.tpl-share-locked { pointer-events: none; }
.tpl-share-locked .tpl-edit-shared,
.tpl-share-locked .tpl-share-note { pointer-events: auto; }
.tpl-share-locked .tpl-field-input:not(.tpl-share-multi-trigger),
.tpl-share-locked textarea,
.tpl-share-locked .tpl-field-textarea,
.tpl-share-locked .tpl-field-select,
.tpl-share-locked .tpl-icon-select-trigger { background: #f6f7f8; color: #5b6572; cursor: not-allowed; }
.tpl-share-locked .tpl-field-select { background-image: none; }
.tpl-share-locked .tpl-icon-select-chev { opacity: 0.45; }
.tpl-share-locked .tpl-edit-shared .tpl-field-input,
.tpl-share-locked .tpl-edit-shared .tpl-icon-select-trigger { background: #fff; color: var(--text); cursor: pointer; }
.tpl-share-locked .tpl-edit-shared .tpl-field-label { color: var(--teal); }
/* Read-only share form: drop the green "valid" border on fields, and hide the Add-button control. */
.tpl-share-locked .tpl-field-input.is-valid,
.tpl-share-locked .tpl-field-textarea.is-valid { border-color: var(--border); }
.tpl-share-locked .tpl-add-btn-wrap { display: none; }
.tpl-share-note {
  display: flex; align-items: center; gap: 8px; margin-bottom: 16px;
  padding: 10px 14px; border-radius: 10px; background: #eef6f7;
  border: 1px solid #cfe6e8; color: #235e63; font-size: 13px;
}
.tpl-share-note svg { flex-shrink: 0; color: var(--teal); }
