/* ===== FORMS: TAB SHELL + LIST PAGE (frm-list.css) ===== */
/* Owned by forms.js (tab orchestrator + list page + New Form / Edit metadata
   modals). Leans on the frm-shared.css design system (.frm-btn / .frm-input /
   .frm-select / .frm-textarea / .frm-badge / .frm-field / .frm-empty /
   .frm-modal-* + the generic form-table component) and only adds list- and
   shell-specific layout here — no duplicated primitives that would globally
   override the shared layer. Colors come exclusively from the kanban design
   tokens in index.css, so the dark default and [data-theme=light] both work. */

/* ── sub-nav (static markup from the integration pass; decorated + wired by
      forms.js — each button gets an inline-SVG icon + a label span) ── */
.frm-subnav {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s1);
  margin-bottom: var(--s4);
}
.frm-subnav button {
  display: inline-flex;
  align-items: center;
  gap: var(--s2);
  background: transparent;
  border: 1px solid transparent;
  color: var(--text2);
  padding: 7px 14px;
  border-radius: 999px;
  font-size: var(--fz-base);
  font-weight: var(--fw-medium);
  font-family: inherit;
  cursor: pointer;
  transition:
    background 0.15s,
    color 0.15s,
    border-color 0.15s;
}
.frm-subnav button .mi,
.frm-subnav button .frm-ico {
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
  color: var(--text3);
  transition: color 0.15s;
}
.frm-subnav button:hover {
  background: var(--card2);
  color: var(--text);
}
.frm-subnav button:hover .frm-ico {
  color: var(--text2);
}
.frm-subnav button.active {
  background: var(--accent-dim);
  color: var(--accent);
}
.frm-subnav button.active .frm-ico {
  color: var(--accent);
}
.frm-subnav button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ── persistent client switcher (injected above the subnav by forms.js) ──
   A single tab-wide filter that scopes the Forms list + Contacts + Appointments
   + Submissions + Dashboard to one client. Lives outside #formsRoot so it
   survives every subview re-render. */
.frm-clientbar {
  display: flex;
  align-items: center;
  gap: var(--s3);
  margin-bottom: var(--s3);
}
.frm-clientbar-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: var(--fz-xs);
  font-weight: var(--fw-bold);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text3);
  white-space: nowrap;
}
.frm-clientbar-label .mi,
.frm-clientbar-label .frm-ico {
  width: 15px;
  height: 15px;
  color: var(--text3);
}
select.frm-select.frm-clientbar-select {
  width: auto;
  min-width: 210px;
  max-width: 340px;
  padding-top: 7px;
  padding-bottom: 7px;
  font-size: var(--fz-sm);
  font-weight: var(--fw-semibold);
}
@media (max-width: 640px) {
  select.frm-select.frm-clientbar-select {
    flex: 1 1 auto;
    min-width: 0;
    max-width: none;
  }
}

/* ── list header ── */
.frm-list-head {
  display: flex;
  align-items: center;
  gap: var(--s3);
  margin-bottom: var(--s4);
  flex-wrap: wrap;
}
.frm-list-title {
  font-size: var(--fz-xl);
  font-weight: var(--fw-bold);
  color: var(--text);
  margin-right: auto;
}
.frm-count {
  display: inline-block;
  min-width: 22px;
  text-align: center;
  font-size: var(--fz-xs);
  font-weight: var(--fw-semibold);
  color: var(--text3);
  background: var(--card2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 1px 8px;
  vertical-align: middle;
}
.frm-list-searchwrap {
  position: relative;
  display: inline-flex;
  align-items: center;
}
.frm-list-search-ico {
  position: absolute;
  left: 11px;
  width: 15px;
  height: 15px;
  color: var(--text3);
  pointer-events: none;
}
.frm-list-search {
  background: var(--bg2);
  border: 1px solid var(--border2);
  border-radius: var(--r2);
  color: var(--text);
  padding: 8px 12px 8px 34px;
  font-size: var(--fz-base);
  font-family: inherit;
  min-width: 240px;
  transition:
    border-color 0.15s,
    box-shadow 0.15s;
}
.frm-list-search::placeholder {
  color: var(--text3);
}
.frm-list-search:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}

/* ── list table (form-table.js markup; base styling from frm-shared.css) ── */
/* The header search proxies into the toolbar's search — hide the duplicate. */
.frm-list .frm-table-search {
  display: none;
}
/* Numeric columns (Completed → Book Call %, cols 4–10) read right-aligned +
   tabular. Column order is set in forms.js LIST_COLUMNS — keep in lockstep. */
.frm-list .frm-table-el th:nth-child(n + 4):nth-child(-n + 10),
.frm-list .frm-table-el td:nth-child(n + 4):nth-child(-n + 10) {
  text-align: right;
  font-variant-numeric: tabular-nums;
}
/* Tighten the dense metric + date columns (4–12) so the 12-column ROASform
   grid stays compact without cramping the Name / Client / Status columns. */
.frm-list .frm-table-el th:nth-child(n + 4):nth-child(-n + 12),
.frm-list .frm-table-el td:nth-child(n + 4):nth-child(-n + 12) {
  padding-left: var(--s2);
  padding-right: var(--s2);
}
/* Pin the row-actions column to the right edge so edit/duplicate/delete stay
   reachable even while the wide table scrolls horizontally. */
.frm-list .frm-table-el th:last-child,
.frm-list .frm-table-el td:last-child {
  position: sticky;
  right: 0;
  background: var(--card);
  border-left: 1px solid var(--border);
  /* soft shadow so scrolled columns read as tucked BEHIND the pinned actions */
  box-shadow: -10px 0 10px -8px rgba(0, 0, 0, 0.35);
  padding-right: var(--s4);
  z-index: 1;
}
.frm-list .frm-table-el th:last-child {
  z-index: 2;
}
.frm-list .frm-table-el tr.frm-table-row:hover td:last-child {
  background: var(--card-hover);
}
.frm-form-name {
  display: inline-block;
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  vertical-align: middle;
  color: var(--text);
  font-weight: var(--fw-semibold);
}
.frm-cell-sub {
  color: var(--text3);
  font-size: var(--fz-sm);
}

/* ── row actions (icon buttons, revealed emphasis on row hover) ── */
.frm-row-actions {
  display: inline-flex;
  gap: var(--s1);
  justify-content: flex-end;
}
.frm-act {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  padding: 0;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--r2);
  color: var(--text3);
  cursor: pointer;
  font-family: inherit;
  transition:
    color 0.15s,
    background 0.15s,
    border-color 0.15s;
}
.frm-act .mi,
.frm-act .frm-ico {
  width: 15px;
  height: 15px;
}
.frm-act:hover {
  color: var(--text);
  background: var(--card2);
  border-color: var(--border2);
}
.frm-act-danger:hover {
  color: var(--red);
  background: color-mix(in srgb, var(--red) 12%, transparent);
  border-color: color-mix(in srgb, var(--red) 40%, transparent);
}
/* row actions stay subtle until the row is hovered/focused (ROASform pattern) */
.frm-list .frm-table-el tr.frm-table-row .frm-act {
  opacity: 0.55;
}
.frm-list .frm-table-el tr.frm-table-row:hover .frm-act,
.frm-list .frm-table-el tr.frm-table-row:focus-within .frm-act {
  opacity: 1;
}

/* ── loading state ── */
.frm-loading {
  color: var(--text3);
  font-size: var(--fz-base);
  padding: var(--s6);
  text-align: center;
}

/* ── #formNewModal content (New Form + Edit metadata) ── */
.frm-new,
.frm-meta {
  display: grid;
  gap: var(--s5);
}
.frm-new .frm-modal-title,
.frm-meta .frm-modal-title {
  margin: 0;
}
.frm-new .frm-modal-actions,
.frm-meta .frm-modal-actions {
  margin-top: 0;
}
.frm-new-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--s4);
}
@media (max-width: 720px) {
  .frm-new-grid {
    grid-template-columns: 1fr;
  }
}
.frm-new-card {
  background: var(--card2);
  border: 1px solid var(--border2);
  border-radius: var(--r4);
  padding: var(--s5);
  display: flex;
  flex-direction: column;
  gap: var(--s3);
}
.frm-new-card h4 {
  display: flex;
  align-items: center;
  gap: var(--s2);
  margin: 0;
  font-size: var(--fz-md);
  font-weight: var(--fw-semibold);
  color: var(--text);
}
.frm-new-card-ico {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: var(--r2);
  background: var(--accent-dim);
  color: var(--accent);
  flex: 0 0 auto;
}
.frm-new-card-ico .frm-ico {
  width: 16px;
  height: 16px;
}
.frm-new-hint {
  margin: 0;
  color: var(--text3);
  font-size: var(--fz-sm);
  line-height: var(--lh-snug);
}
.frm-new-card-actions {
  display: flex;
  gap: var(--s2);
  margin-top: auto;
}
.frm-new-create {
  align-self: flex-start;
  margin-top: auto;
}

/* ── import feedback ── */
.frm-import-msg {
  font-size: var(--fz-sm);
}
.frm-import-ok {
  color: var(--green);
}
.frm-import-error {
  color: var(--red);
}
.frm-import-warn {
  color: var(--gold);
  margin-top: var(--s2);
}
.frm-import-unmapped {
  margin: var(--s1) 0 0;
  padding-left: var(--s5);
  color: var(--text3);
  max-height: 120px;
  overflow-y: auto;
}
.frm-import-unmapped code {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r1);
  padding: 0 4px;
  font-size: var(--fz-xs);
}

/* ── responsive ── */
@media (max-width: 640px) {
  .frm-list-search,
  .frm-list-searchwrap {
    flex: 1 1 100%;
    min-width: 0;
  }
  .frm-new-btn {
    flex: 1 1 100%;
    justify-content: center;
  }
}
