/* ── Shops page layout ──────────────────────────────────────────────────────── */
.page-layout {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.page-main {
  flex: 1;
  padding: var(--space-6);
  max-width: 1800px;
  width: 100%;
  margin: 0 auto;
}

/* ── Sub-navigation ─────────────────────────────────────────────────────────── */
.sub-nav {
  display: flex;
  gap: var(--space-1);
  border-bottom: 1px solid var(--color-border);
  margin-bottom: var(--space-5);
  padding: 0;
}

.sub-nav__item {
  display: inline-flex;
  align-items: center;
  padding: var(--space-2) var(--space-4);
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  color: var(--color-text-secondary);
  text-decoration: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color var(--transition-fast), border-color var(--transition-fast);
  white-space: nowrap;
}
.sub-nav__item:hover    { color: var(--color-text-primary); }
.sub-nav__item.is-active {
  color: var(--color-accent);
  border-bottom-color: var(--color-accent);
}


/* PHASE5_SHOPS_LIST_PAGE — scoped with .shops-* prefix
   Append-only — existing .page-layout / .page-main / .sub-nav rules above
   are preserved verbatim. */

.shops-page {
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
}

/* ── KPI grid (5 cards) ──────────────────────────────────────────────────── */
.shops-metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: var(--space-4);
}

.shops-metric-card--skeleton {
  background: linear-gradient(
    90deg,
    var(--color-surface-2) 25%,
    var(--color-surface-3) 50%,
    var(--color-surface-2) 75%
  );
  background-size: 200% 100%;
  animation: shops-skeleton-shimmer 1.4s ease infinite;
}
@keyframes shops-skeleton-shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ── Partner pills (admin-only) ──────────────────────────────────────────── */
.shops-partner-bar {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}
.shops-partner-bar[hidden] { display: none; }

.shops-partner-bar__pill {
  display: inline-flex;
  align-items: center;
  padding: var(--space-2) var(--space-4);
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  color: var(--color-text-secondary);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-full);
  cursor: pointer;
  transition:
    color var(--transition-fast),
    background var(--transition-fast),
    border-color var(--transition-fast);
}
.shops-partner-bar__pill:hover {
  color: var(--color-text-primary);
  border-color: var(--color-accent-dim);
}
.shops-partner-bar__pill.is-active {
  color: var(--color-accent);
  background: var(--color-accent-dim);
  border-color: var(--color-accent);
}

/* ── Filter bar ──────────────────────────────────────────────────────────── */
.shops-filter-bar {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}
.shops-filter-bar__row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  align-items: flex-end;
}
.shops-filter-bar__field {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  min-width: 140px;
}
.shops-filter-bar__field--grow { flex: 1 1 240px; }

.shops-filter-bar__label {
  font-size: var(--text-xs);
  font-weight: var(--font-medium);
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.shops-filter-bar__input {
  padding: var(--space-2) var(--space-3);
  font-size: var(--text-sm);
  color: var(--color-text-primary);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  transition: border-color var(--transition-fast);
}
.shops-filter-bar__input:focus {
  outline: none;
  border-color: var(--color-accent);
}

/* ── Table ───────────────────────────────────────────────────────────────── */
.shops-table-card { padding: 0; }

.shops-table th,
.shops-table td {
  vertical-align: middle;
  /* Tighter horizontal gutters so all columns fit without horizontal scroll. */
  padding-left: var(--space-2);
  padding-right: var(--space-2);
}
.shops-table .shops-th--num,
.shops-table td.shops-td--num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* Level Up column — compact, ellipsis + tooltip carries the full text. */
.shops-th--rec { min-width: 0; }

.shops-th--sortable {
  cursor: pointer;
  user-select: none;
  position: relative;
}
.shops-th--sortable:hover { color: var(--color-text-primary); }
.shops-th--sortable::after {
  content: "";
  display: inline-block;
  width: 0.7em;
  margin-left: var(--space-1);
  opacity: 0;
  transition: opacity var(--transition-fast);
}
.shops-th--sortable.shops-th--sorted::after { opacity: 1; }
.shops-th--sortable.shops-th--sorted-asc::after  { content: "▲"; }
.shops-th--sortable.shops-th--sorted-desc::after { content: "▼"; }

/* ── Signal dots ─────────────────────────────────────────────────────────── */
.shops-signal {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: var(--radius-full);
  flex-shrink: 0;
  vertical-align: middle;
  background: var(--color-text-muted);
}
.shops-signal--green  { background: var(--color-success); }
.shops-signal--yellow { background: var(--color-warning); }
.shops-signal--red    { background: var(--color-danger);  }
.shops-signal--grey   { background: var(--color-text-muted); }

.shops-signal-cell {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
}

/* ── Phase badges ────────────────────────────────────────────────────────── */
.shops-phase {
  display: inline-block;
  padding: 2px var(--space-2);
  font-size: var(--text-xs);
  font-weight: var(--font-medium);
  border-radius: var(--radius-sm);
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  color: var(--color-text-secondary);
  white-space: nowrap;
}
.shops-phase--Qualify {
  color: var(--color-text-secondary);
  border-color: var(--color-border);
}
.shops-phase--Across {
  color: var(--color-info);
  background: var(--color-info-dim);
  border-color: var(--color-info);
}
.shops-phase--Observe {
  color: var(--color-warning);
  background: var(--color-warning-dim, var(--color-surface));
  border-color: var(--color-warning);
}
.shops-phase--Index {
  color: var(--color-success);
  background: var(--color-success-dim, var(--color-surface));
  border-color: var(--color-success);
}
.shops-phase--Dead {
  color: var(--color-danger);
  background: var(--color-danger-dim);
  border-color: var(--color-danger);
}

/* Phase = Linkbase shop segment (shown as-is, no label mapping). Single neutral
   pill for all segment values; the engine owns the taxonomy. */
.shops-segment {
  display: inline-block;
  padding: 2px var(--space-2);
  font-size: var(--text-xs);
  font-weight: var(--font-medium);
  border-radius: var(--radius-sm);
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  color: var(--color-text-secondary);
  white-space: nowrap;
}
.shops-segment--none { color: var(--color-text-muted); border-style: dashed; }

/* ── MVP-parity metric coloring (avg_position / rev_per_click / conv_rate) ── */
/* Threshold buckets mirror the MVP /shops badges; colors are our --color-*. */
.shops-rating        { font-weight: var(--font-semibold, 600); }
.shops-rating--green { color: var(--color-success); }
.shops-rating--blue  { color: var(--color-info); }
.shops-rating--amber { color: var(--color-warning); }
.shops-rating--red   { color: var(--color-danger); }
.shops-rating--muted { color: var(--color-text-muted); font-weight: var(--font-normal, 400); }

/* Dead-phase row tint (MVP parity: subtle red wash on the whole row). */
.shops-row--dead > td { background: var(--color-danger-dim); }

/* ── Links cell (per-shop placements, MVP-style level + bar) ───────────────── */
.shops-th--links { min-width: 0; }
.shops-links__inner { display: inline-flex; align-items: center; gap: 4px; }
.shops-links__level {
  font-size: var(--text-xs);
  font-weight: var(--font-semibold);
  min-width: 18px;
}
.shops-links__bar {
  width: 44px;
  height: 5px;
  background: var(--color-border);
  border-radius: 3px;
  flex-shrink: 0;
  overflow: hidden;
}
.shops-links__fill { display: block; height: 100%; border-radius: 3px; }
.shops-links__count { font-size: var(--text-xs); color: var(--color-text-muted); }
.shops-links__empty { color: var(--color-text-muted); font-size: var(--text-xs); }

/* ── Level Up (recommendation) cell ──────────────────────────────────────── */
.shops-recommendation {
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
}
.shops-recommendation__text {
  display: inline-block;
  max-width: 104px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  vertical-align: middle;
}

/* ── Responsive ──────────────────────────────────────────────────────────── */
@media (max-width: 900px) {
  .shops-filter-bar__row { flex-direction: column; align-items: stretch; }
  .shops-filter-bar__field { min-width: 0; }
}
/* /PHASE5_SHOPS_LIST_PAGE */


/* ════════════════════════════════════════════════════════════════════════
   PHASE_SHOPS_EDIT — Actions column for admin Edit affordances
   (Modal readonly/notes styles migrated to components/modal.css on 2026-04-27)
   ════════════════════════════════════════════════════════════════════════ */

/* Actions column: hidden by default, shown only for admins via body attr. */
.shops-th--actions,
.shops-actions-cell {
  display: none;
  text-align: right;
  white-space: nowrap;
}

body[data-user-role="admin"] .shops-th--actions,
body[data-user-role="admin"] .shops-actions-cell {
  display: table-cell;
}

.shops-edit-btn {
  min-width: 60px;
}
/* /PHASE_SHOPS_EDIT */

/* ─── Columns visibility popover ─────────────────────────────────────────── */

.shops-columns-control {
  position: relative;
}
.shops-columns-btn {
  min-width: 6rem;
}
.shops-columns-panel {
  position: absolute;
  top: calc(100% + var(--space-2));
  right: 0;
  z-index: 20;
  min-width: 16rem;
  max-height: 24rem;
  overflow-y: auto;
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.25);
  padding: var(--space-3);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}
.shops-columns-panel[hidden] {
  display: none;
}
.shops-columns-panel__header {
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.shops-columns-panel__body {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}
.shops-columns-panel__item {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-sm);
  color: var(--color-text-primary);
  cursor: pointer;
  user-select: none;
}
.shops-columns-panel__item.is-required {
  color: var(--color-text-muted);
  cursor: not-allowed;
}
.shops-columns-panel__item input[type="checkbox"] {
  cursor: pointer;
}
.shops-columns-panel__item.is-required input[type="checkbox"] {
  cursor: not-allowed;
}
.shops-columns-panel__footer {
  display: flex;
  justify-content: flex-end;
  border-top: 1px solid var(--color-border);
  padding-top: var(--space-3);
}

/* ─── Pagination footer (inside .shops-table-card) ───────────────────────── */

.shops-pagination {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-3) var(--space-4);
  border-top: 1px solid var(--color-border);
  flex-wrap: wrap;
}
.shops-pagination__summary {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
}
.shops-pagination__controls {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}
.shops-pagination__indicator {
  font-size: var(--text-sm);
  color: var(--color-text-primary);
  min-width: 8rem;
  text-align: center;
}
.shops-pagination .btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}


/* ─── Domain cell link → /shops/{id} (Phase 2.2, 2026-04-24) ─────────────── */

.shops-domain-link {
  color: inherit;
  text-decoration: none;
  outline: none;
  /* Cap the domain width; long domains ellipsize, full value in the cell title. */
  display: inline-block;
  max-width: 150px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  vertical-align: middle;
}
.shops-domain-link:hover {
  text-decoration: underline;
}
.shops-domain-link:focus-visible {
  outline: 2px solid var(--color-input-focus);
  outline-offset: 2px;
  border-radius: 2px;
}

/* ─── PHASE_SHOPS_CUSTOM_RANGE_FRONTEND ───────────────────────────────────── */

/* Wrapper section that holds date row + error + label. */
.shops-date-range-section {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

/* Row of two date inputs (From / To). Hidden when period != 'custom'. */
.shops-date-range-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  align-items: flex-end;
}
.shops-date-range-row[hidden] { display: none; }

/* Inline validation message near the date inputs. Reserves vertical
   space to avoid layout shift when the message appears or clears. */
.shops-date-range-error {
  font-size: var(--text-xs);
  color: var(--color-danger);
  min-height: 1em;
}
.shops-date-range-error:empty {
  visibility: hidden;
}

/* Period label, shown only for valid custom range. Hidden when empty
   (default for fixed/all and for invalid custom). */
.shops-period-label {
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
}
.shops-period-label:empty {
  display: none;
}

/* Responsive: stack date row vertically on narrow viewports. */
@media (max-width: 900px) {
  .shops-date-range-row { flex-direction: column; align-items: stretch; }
}
/* /PHASE_SHOPS_CUSTOM_RANGE_FRONTEND */
/* ════════════════════════════════════════════════════════════════════════
   PHASE_SHOPS_CREATE — Add shop toolbar (admin-only, mirrors Actions gate)
   ════════════════════════════════════════════════════════════════════════ */

/* Hidden by default; shown only for admins via body attr (same pattern as
   .shops-th--actions). Non-admins never see the Add shop button. */
.shops-toolbar {
  display: none;
}
body[data-user-role="admin"] .shops-toolbar {
  display: flex;
  justify-content: flex-end;
}
.shops-add-btn {
  white-space: nowrap;
}
/* /PHASE_SHOPS_CREATE */

/* ════════════════════════════════════════════════════════════════════════
   Add-link-task — per-product "+" button + donor combobox (Products tab)
   ════════════════════════════════════════════════════════════════════════ */

/* Compact "+" appended to the Links cell; admin/manager only (render-gated). */
.prod-add-task {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  margin-left: 6px;
  padding: 0;
  font-size: 14px;
  font-weight: 600;
  line-height: 1;
  color: var(--color-accent);
  background: transparent;
  border: 1px solid var(--color-border);
  border-radius: 4px;
  cursor: pointer;
  vertical-align: middle;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
}
.prod-add-task:hover {
  color: var(--color-text-inverse);
  background: var(--color-accent);
  border-color: var(--color-accent);
}

/* Donor searchable combobox inside the Add-link-task modal. */
.addtask-combo {
  position: relative;
}
.addtask-combo__list {
  position: absolute;
  z-index: 20;
  left: 0;
  right: 0;
  top: 100%;
  max-height: 240px;
  margin-top: 4px;
  overflow-y: auto;
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  border-radius: 6px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}
.addtask-combo__item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  padding: 7px 10px;
  font-size: 13px;
  text-align: left;
  color: var(--color-text-primary);
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--color-border-subtle);
  cursor: pointer;
}
.addtask-combo__item:last-child { border-bottom: none; }
.addtask-combo__item:hover { background: var(--color-surface-3); }
.addtask-combo__domain { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.addtask-combo__dr {
  flex: 0 0 auto;
  font-size: 11px;
  color: var(--color-text-muted);
}
.addtask-combo__empty {
  padding: 8px 10px;
  font-size: 12px;
  color: var(--color-text-muted);
}
.form-hint-inline {
  font-weight: 400;
  font-size: 11px;
  color: var(--color-text-muted);
}
