/* Shared pieces for the section pages (Conversations, Leads, Catalogue,
   Knowledge, Analytics, Deploy, Integrations, Assistant). */

/* Toolbar: search + filter chips + actions */
.pg-toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.pg-search { position: relative; flex: 1 1 220px; min-width: 0; max-width: 360px; }
.pg-search .ico { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--text-tertiary); pointer-events: none; }
.pg-search input {
  width: 100%; height: 40px; padding: 0 12px 0 38px; border-radius: var(--radius-button);
  border: 1px solid var(--border); background: var(--surface-primary); color: var(--text-primary);
  font-family: inherit; font-size: 14px; outline: none;
}
.pg-search input:focus { border-color: var(--brand-primary); box-shadow: 0 0 0 4px var(--brand-ring); }
.pg-chips { display: flex; gap: 6px; flex-wrap: wrap; }
.pg-chip {
  height: 34px; padding: 0 12px; border-radius: var(--radius-pill); border: 1px solid var(--border);
  background: var(--surface-primary); color: var(--text-secondary); font-family: inherit; font-size: 13px; font-weight: 600;
  cursor: pointer; display: inline-flex; align-items: center; gap: 6px; white-space: nowrap;
}
.pg-chip:hover { color: var(--text-primary); }
.pg-chip[aria-pressed="true"] { background: var(--brand-soft); color: var(--brand-ink); border-color: transparent; }
.pg-chip .count { font-size: 11px; padding: 0 6px; border-radius: 8px; background: var(--surface-secondary); color: var(--text-secondary); }
.pg-chip[aria-pressed="true"] .count { background: var(--brand-primary); color: #fff; }
.pg-toolbar .end { margin-left: auto; display: flex; gap: 8px; align-items: center; }
.pg-empty { text-align: center; padding: 28px 12px; color: var(--text-secondary); font-size: 14px; }
.pg-count { font-size: 13px; color: var(--text-secondary); }
.pg-count a, .tab-panel .sc-head a { color: var(--brand-ink); }
.pg-more { display: flex; justify-content: center; margin-top: 14px; }

/* List rows (knowledge docs, etc.) */
.pg-list { display: flex; flex-direction: column; }
.pg-row { display: flex; align-items: center; gap: 12px; padding: 12px 4px; border-top: 1px solid var(--border); min-width: 0; }
.pg-row:first-child { border-top: 0; }
.pg-row-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.pg-row-title { font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pg-row-sub { font-size: 12.5px; color: var(--text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pg-row-meta { font-size: 12px; color: var(--text-tertiary); white-space: nowrap; }

/* Product grid (Catalogue) */
.pg-products { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(190px, 100%), 1fr)); gap: 12px; }
.pg-product { border: 1px solid var(--border); border-radius: 16px; overflow: hidden; background: var(--surface-primary); display: flex; flex-direction: column; min-width: 0; }
.pg-product-img { aspect-ratio: 4 / 3; background: var(--surface-secondary) center / contain no-repeat; display: grid; place-items: center; color: var(--text-tertiary); }
.pg-product-body { padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.pg-product-title { font-size: 13.5px; font-weight: 600; line-height: 1.35; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.pg-product-price { font-size: 14px; font-weight: 700; color: var(--brand-ink); }
.pg-product-chips { display: flex; gap: 6px; flex-wrap: wrap; margin-top: auto; }
.pg-product a { color: inherit; text-decoration: none; }
.pg-product a:hover .pg-product-title { color: var(--brand-ink); }

/* Integrations */
.pg-integ { display: flex; gap: 16px; align-items: flex-start; flex-wrap: wrap; }
.pg-integ-logo { width: 52px; height: 52px; border-radius: 14px; display: grid; place-items: center; background: var(--success-soft); color: var(--success-ink); flex-shrink: 0; }
.pg-integ-main { flex: 1 1 280px; min-width: 0; display: flex; flex-direction: column; gap: 8px; }
.pg-integ-main h2 { margin: 0; font-size: 18px; font-weight: 650; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.pg-kv { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(200px, 100%), 1fr)); gap: 10px; }
.pg-kv div { padding: 12px 14px; border-radius: 14px; background: var(--surface-secondary); border: 1px solid var(--border); display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.pg-kv span { font-size: 12px; color: var(--text-secondary); }
.pg-kv strong { font-size: 14px; font-weight: 600; overflow-wrap: anywhere; }
.pg-scopes { display: flex; gap: 6px; flex-wrap: wrap; }

/* Conversations: three panes (list · thread · details) */
.inbox-wrap.pg-3 { grid-template-columns: 344px minmax(0, 1fr) 260px; }
.inbox-wrap.pg-3 .inbox-list { max-height: 640px; }   /* overrides the old stacked-layout cap */
.inbox-details { border: 1px solid var(--glass-border); border-radius: var(--radius-card); background: var(--glass-bg); -webkit-backdrop-filter: blur(var(--blur)); backdrop-filter: blur(var(--blur)); padding: 16px; display: flex; flex-direction: column; gap: 14px; align-self: start; }
.inbox-details h3 { margin: 0; font-size: 14px; font-weight: 650; }
.inbox-details dl { margin: 0; display: flex; flex-direction: column; gap: 10px; font-size: 13px; }
.inbox-details dl div { display: flex; justify-content: space-between; gap: 10px; }
.inbox-details dt { color: var(--text-secondary); }
.inbox-details dd { margin: 0; font-weight: 600; text-align: right; overflow-wrap: anywhere; }
.inbox-details ul { margin: 0; padding-left: 18px; font-size: 13px; color: var(--text-secondary); display: flex; flex-direction: column; gap: 4px; }
.inbox-list-head { padding: 12px; border-bottom: 1px solid var(--border); display: flex; flex-direction: column; gap: 10px; position: sticky; top: 0; background: var(--glass-bg-strong); z-index: 1; }
.inbox-list-head .pg-search { max-width: none; flex: none; }
.inbox-list-head .pg-chips { gap: 4px; }
.inbox-list-head .pg-chip { height: 30px; padding: 0 9px; font-size: 12.5px; gap: 5px; }
.ib-back { display: none; }

/* Leads cards (phones) */
.pg-cards { display: none; flex-direction: column; gap: 10px; padding: 12px; }
.pg-card { padding: 14px; border-radius: 14px; background: var(--surface-secondary); border: 1px solid var(--border); display: flex; flex-direction: column; gap: 6px; font-size: 13px; min-width: 0; }
.pg-card-top { display: flex; justify-content: space-between; gap: 10px; align-items: center; }
.pg-card a { color: var(--brand-ink); overflow-wrap: anywhere; }

.pg-leads-table td:nth-child(1), .pg-leads-table td:nth-child(4) { white-space: nowrap; }

/* Leads: cards below 1024px (the table needs ~900px for all six columns) */
@media (max-width: 1023px) {
  .pg-leads-table { display: none; }
  .pg-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(280px, 100%), 1fr)); }
}

/* Deploy */
.pg-status { display: flex; align-items: center; gap: 12px; padding: 14px 16px; border-radius: 14px; font-size: 14px; }
.pg-status.ok { background: var(--success-soft); }
.pg-status.wait { background: var(--warning-soft); }
.pg-status strong { display: block; }
.pg-status p { margin: 0; font-size: 13px; color: var(--text-secondary); }

/* Assistant settings: sticky save bar */
.rc-content-row .save-bar {
  position: sticky; bottom: 12px; z-index: 2; margin-top: 16px; padding: 12px 16px; border-top: 0;
  border: 1px solid var(--glass-border); border-radius: 16px;
  background: var(--glass-bg-strong); box-shadow: var(--glass-shadow);
  -webkit-backdrop-filter: blur(var(--blur)); backdrop-filter: blur(var(--blur));
}

@media (max-width: 1279px) {
  .inbox-wrap.pg-3 { grid-template-columns: 300px minmax(0, 1fr); }
  .inbox-details { display: none; }
}
@media (max-width: 767px) {
  .inbox-wrap.pg-3 { grid-template-columns: minmax(0, 1fr); }
  .inbox-wrap.pg-3 .inbox-list { max-height: none; }
  .inbox-wrap.pg-3.show-thread .inbox-list { display: none; }
  .inbox-wrap.pg-3:not(.show-thread) .inbox-thread { display: none; }
  .ib-back { display: inline-flex; }
  .pg-search { max-width: none; flex-basis: 100%; }
  .pg-toolbar .end { margin-left: 0; }
  .pg-products { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .pg-product-body { padding: 8px 10px 10px; }
}

/* ── Phase 6: widths ─────────────────────────────────────────────────── */
/* Data pages use the full content width like Dashboard and Billing;
   forms stay at a comfortable reading width beside the live preview. */
#tab-inbox, #tab-analytics, #tab-catalogue, #tab-integrations, #tab-leads { max-width: var(--content-max); }
#tab-general, #tab-appearance, #tab-instructions, #tab-deploy { max-width: 820px; }

/* Analytics: date controls on their own row, left-aligned */
#tab-analytics .panel-title-row { flex-direction: column; align-items: stretch; }
#tab-analytics .an-controls { width: 100%; justify-content: space-between; align-items: flex-end; }
#tab-analytics .date-range-pro { flex-direction: row; flex-wrap: wrap; align-items: flex-end; gap: 10px 16px; }
#tab-analytics .preset-buttons { max-width: none; justify-content: flex-start; }
#tab-analytics .preset-buttons button.active { border-color: transparent; background: var(--brand-soft); color: var(--brand-ink); }
#tab-analytics .an-controls > .an-updated { margin-left: auto; }
@media (max-width: 767px) {
  #tab-analytics .preset-buttons { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
  #tab-analytics .preset-buttons::-webkit-scrollbar { display: none; }
  #tab-analytics .preset-buttons button { flex: 0 0 auto; }
  #tab-analytics .an-controls > .an-updated { margin-left: 0; }
}

/* ── Phase 6: touch targets on phones (≥ 36px) ───────────────────────── */
@media (max-width: 767px) {
  #tab-analytics .preset-buttons button,
  .seg-btn,
  .inbox-list-head .pg-chip,
  .pg-chip { min-height: 36px; }
  .copy-btn { min-height: 36px; min-width: 56px; }
  .live-toggle input[type="checkbox"] { width: 20px; height: 20px; }
  .live-toggle { min-height: 40px; display: inline-flex; align-items: center; }
  .custom-range input[type="date"], .custom-range button { min-height: 40px; }
  .dash-link { display: inline-flex; align-items: center; min-height: 36px; padding: 0 6px; margin: -10px -6px; }
}

/* Very small phones (< 360px): icon-only Upgrade so the store name fits */
@media (max-width: 359px) {
  .rc-upgrade .rc-upgrade-word { display: none; }
  .rc-upgrade { padding-left: 10px; padding-right: 10px; }
}

/* Sidebar: nav scrolls, store card + account footer stay put on short screens */
.rc-side { overflow-y: hidden; }
.rc-side .rc-nav { flex: 1 1 auto; min-height: 0; overflow-y: auto; overflow-x: hidden; scrollbar-width: thin; margin: 0 -4px; padding: 0 4px; }
@media (max-height: 860px) {
  .rc-side .nav-item { min-height: 36px; }
  .rc-side { gap: 10px; }
}

/* ── Product Finder ─────────────────────────────────────────────────────── */
.fd-list { display: flex; flex-direction: column; gap: 12px; }
.fd-card {
  padding: 16px 18px; border-radius: var(--radius-card); border: 1px solid var(--glass-border);
  background: var(--glass-bg); box-shadow: var(--glass-shadow); -webkit-backdrop-filter: blur(var(--blur)); backdrop-filter: blur(var(--blur));
  display: flex; flex-direction: column; gap: 10px; min-width: 0;
}
.fd-card-top { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; align-items: flex-start; }
.fd-who { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.fd-who strong { font-size: 15px; overflow-wrap: anywhere; }
.fd-badges { display: flex; gap: 6px; flex-wrap: wrap; }
.fd-need { margin: 0; font-size: 14px; }
.fd-answers { display: flex; gap: 6px; flex-wrap: wrap; }
.fd-answer { font-size: 12.5px; padding: 4px 10px; border-radius: var(--radius-pill); background: var(--surface-secondary); border: 1px solid var(--border); }
.fd-picks { display: flex; gap: 6px 12px; flex-wrap: wrap; align-items: baseline; font-size: 13.5px; }
.fd-picks a { color: var(--brand-ink); }
.fd-order { margin: 0; font-size: 13px; font-weight: 600; color: var(--success-ink); }
.fd-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.fd-actions .icon-btn { margin-left: auto; }
.fd-note {
  width: 100%; min-height: 0; font: inherit; font-size: 13px; padding: 8px 10px; border-radius: 10px; resize: vertical;
  border: 1px dashed var(--border); background: transparent; color: var(--text-primary);
}
.fd-note:focus { outline: none; border-style: solid; border-color: var(--brand-primary); }

.fd-settings { display: grid; grid-template-columns: minmax(0, 1fr) 280px; gap: 16px; align-items: start; }
.fd-settings-main { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.fd-settings-side { position: sticky; top: 0; }
.fd-label { font-size: 13px; font-weight: 600; }
.fd-modes { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.fd-mode {
  display: flex; flex-direction: column; gap: 4px; padding: 12px 14px; border-radius: 14px; cursor: pointer;
  border: 1.5px solid var(--border); background: var(--surface-primary); position: relative;
}
.fd-mode input { position: absolute; opacity: 0; pointer-events: none; }
.fd-mode.on { border-color: var(--brand-primary); background: var(--brand-soft); }
.fd-mode:focus-within { box-shadow: 0 0 0 4px var(--brand-ring); }
.fd-mode strong { font-size: 14px; }
.fd-check { display: inline-flex; gap: 8px; align-items: center; font-size: 13.5px; cursor: pointer; }
.fd-check input { width: 18px; height: 18px; accent-color: var(--brand-primary); }
.fd-sets-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.fd-sets-head h2 { margin: 0; font-size: 18px; font-weight: 650; }
.fd-set-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.fd-set-tools { display: flex; gap: 10px; align-items: center; }
.fd-two { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.fd-qs { display: flex; flex-direction: column; gap: 10px; margin-bottom: 12px; }
.fd-q { border: 1px solid var(--border); border-radius: 14px; padding: 12px; background: var(--surface-secondary); display: flex; flex-direction: column; gap: 8px; }
.fd-q.off { opacity: .6; }
.fd-q-head { display: flex; gap: 10px; align-items: flex-start; }
.fd-q-num { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; font-size: 12px; font-weight: 700; background: var(--brand-soft); color: var(--brand-ink); flex-shrink: 0; margin-top: 7px; }
.fd-q-fields { flex: 1; display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.fd-q-tools { display: flex; gap: 2px; }
.fd-q-opts { display: flex; gap: 16px; flex-wrap: wrap; padding-left: 36px; }
.fd-chips, .fd-preview-chips { display: flex; gap: 6px; flex-wrap: wrap; }
.fd-chip { font-size: 12px; padding: 3px 10px; border-radius: var(--radius-pill); border: 1.5px solid var(--brand-primary); color: var(--brand-ink); }
.fd-chip.other { border-style: dashed; opacity: .8; }
.fd-hints { padding-left: 36px; font-size: 13px; }
.fd-hints summary { cursor: pointer; color: var(--brand-ink); font-weight: 600; }
.fd-hint { display: grid; grid-template-columns: 110px minmax(0, 1fr); gap: 8px; align-items: center; margin-top: 6px; }
.fd-hint span { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fd-hint input { height: 34px; padding: 0 10px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface-primary); color: var(--text-primary); font: inherit; font-size: 13px; }
.fd-preview { border-radius: var(--radius-card); border: 1px solid var(--glass-border); background: var(--glass-bg); padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.fd-preview-head { font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--text-tertiary); }
.fd-bubble { max-width: 85%; padding: 8px 12px; border-radius: 14px; font-size: 13px; line-height: 1.4; }
.fd-bubble.user { align-self: flex-end; background: var(--brand-primary); color: #fff; border-bottom-right-radius: 4px; }
.fd-bubble.bot { align-self: flex-start; background: var(--surface-secondary); border: 1px solid var(--border); border-bottom-left-radius: 4px; }
.fd-locked { display: flex; gap: 16px; align-items: flex-start; flex-wrap: wrap; }
.fd-locked h3 { margin: 0 0 8px; font-size: 18px; }
.fd-bullets { margin: 0 0 14px; padding-left: 18px; display: flex; flex-direction: column; gap: 6px; font-size: 14px; color: var(--text-secondary); }
#tab-finder { max-width: var(--content-max); }
@media (max-width: 1023px) {
  .fd-settings { grid-template-columns: minmax(0, 1fr); }
  .fd-settings-side { position: static; order: -1; }
}
@media (max-width: 767px) {
  .fd-modes, .fd-two { grid-template-columns: minmax(0, 1fr); }
  .fd-q-opts, .fd-hints { padding-left: 0; }
  .fd-hint { grid-template-columns: minmax(0, 1fr); gap: 4px; }
  .fd-actions .btn { min-height: 36px; }
}
/* .form-group label sets display/weight; keep the mode cards stacked */
.fd-modes .fd-mode { display: flex; flex-direction: column; font-weight: 400; }
