/* ═══════════════════════════════════════════════════════════════
   channels.css — Channels tab
   ───────────────────────────────────────────────────────────────
   Selectors that ONLY render in the Channels tab.
   Extracted from dashboard.css in Phase 3.5 (2026-05-30).
   Loaded AFTER dashboard.css; shared chrome lives there.
   ═══════════════════════════════════════════════════════════════ */


.dash-channel-card {
  background: var(--bg-card, #181b23);
  border: 1px solid var(--glass-border, rgba(255,255,255,0.08));
  border-radius: 12px;
  padding: 1.15rem;
  transition: border-color 0.2s;
}

.dash-channel-card:hover { border-color: var(--glass-border-hover, rgba(255,255,255,0.14)); }

.dash-channel-inactive {
  opacity: 0.75;
  border-color: rgba(239, 68, 68, 0.15);
}

.dash-channel-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.75rem;
}

.dash-channel-name {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.92rem;
  min-width: 0;
}

.dash-channel-name strong {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── WA Channel: Stacked ID cells ── */
.dash-ch-ids {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 0.6rem;
  margin-bottom: 0.65rem;
  padding-bottom: 0.65rem;
  border-bottom: 1px solid var(--glass-border, rgba(255,255,255,0.06));
}

/* ── WA Channel: Stats row (Balance, TPS, Expires) ── */
.dash-ch-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.2rem;
  margin-bottom: 0.1rem;
}

.dash-ch-stat {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.dash-ch-stat-label {
  font-size: 0.68rem;
  color: var(--text-muted, #5c6577);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.dash-ch-stat-value {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-primary, #e2e4e9);
}

/* ─── Template Table ─── */
.dash-tpl-name { word-break: break-all; }
.dash-tpl-lang-col { white-space: nowrap; font-size: 0.78rem; }

/* Toggle bar for Templates & Flows */
.dash-ch-toggle-bar {
  display: flex;
  gap: 0.5rem;
}

.dash-ch-toggle-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.08);
  background: rgba(255,255,255,0.03);
  color: var(--text-secondary, #8b95a5);
  font-size: 0.82rem;
  font-family: inherit;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
}

.dash-ch-toggle-btn:hover {
  background: rgba(255,255,255,0.06);
  border-color: rgba(255,255,255,0.12);
  color: var(--text-primary, #e8ecf1);
}

.dash-ch-toggle-btn.active {
  background: rgba(37,211,102,0.08);
  border-color: rgba(37,211,102,0.25);
  color: var(--accent-green);
}

/* ═══════════════════════════════════════════════════════════════
   WHATSAPP HEALTH INDICATORS
   ═══════════════════════════════════════════════════════════════ */

.dash-wa-health {
  margin-top: 0.75rem;
  padding-top: 0.65rem;
  border-top: 1px solid var(--glass-border, rgba(255,255,255,0.06));
}

.dash-wa-indicators {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 0.85rem;
}

.dash-wa-ind {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}

.dash-wa-ind-label {
  font-size: 0.7rem;
  color: var(--text-muted, #5c6577);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.dash-wa-ind-value {
  font-size: 0.8rem;
  font-weight: 600;
}

.dash-qr-green { color: var(--color-success); }
.dash-qr-yellow { color: var(--color-warning); }
.dash-qr-red { color: var(--color-error); }

/* ═══════════════════════════════════════════════════════════════
   V3.1: CHANNEL SELECTION STATE (Channels tab)
   ═══════════════════════════════════════════════════════════════ */

.dash-channel-selected {
  border-color: var(--color-success) !important;
  box-shadow: 0 0 0 2px rgba(37, 211, 102, 0.15);
}

/* ═══════════════════════════════════════════════════════════════
   V3.1: CAMPAIGN ACCORDION (CRM tab)
   ═══════════════════════════════════════════════════════════════ */

.dash-campaign-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  padding: 0.1rem 0;
  transition: background 0.15s;
}

/* Channel card detail button */
.dash-ch-detail-btn {
  width: 100%; margin-top: 0.5rem; justify-content: center;
  font-size: 0.78rem !important; gap: 0.4rem;
}

/* ── Master-detail shell ─────────────────────────────────────────── */
.dash-ch2-shell {
  display: grid;
  grid-template-columns: minmax(280px, 32%) 1fr;
  gap: 1.25rem;
  align-items: start;
}

.dash-ch2-list {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  min-width: 0;
}

.dash-ch2-list-group { display: flex; flex-direction: column; gap: 0.5rem; }

.dash-ch2-list-title {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-secondary);
  margin: 0 0 0.15rem;
}

.dash-ch2-list-rows {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

/* ── Unified channel row (replaces .dash-channel-card grid usage) ── */
.dash-ch2-row {
  display: grid;
  grid-template-columns: 28px 1fr auto;
  align-items: center;
  gap: 0.65rem;
  padding: 0.7rem 0.8rem;
  border-radius: 10px;
  background: var(--bg-card);
  border: 1px solid var(--glass-border);
  text-decoration: none;
  color: inherit;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, transform 0.15s;
  min-width: 0;
}

.dash-ch2-row:hover {
  border-color: var(--glass-border-hover);
  background: var(--bg-card-hover);
}

.dash-ch2-row.is-selected {
  border-color: var(--color-success);
  background: var(--bg-card-hover);
  box-shadow: 0 0 0 2px rgba(37, 211, 102, 0.12);
}

.dash-ch2-row.is-inactive { opacity: 0.7; }

.dash-ch2-row-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-secondary);
}
.dash-ch2-row-icon i { width: 14px; height: 14px; }

.dash-ch2-row-body {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  min-width: 0;
}

.dash-ch2-row-name {
  font-size: 0.88rem;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.dash-ch2-row-meta {
  font-size: 0.72rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.dash-ch2-row-pill { flex-shrink: 0; }

/* ── Detail column ───────────────────────────────────────────────── */
.dash-ch2-detail-col {
  position: sticky;
  top: calc(56px + 0.75rem);
  display: flex;
  flex-direction: column;
  min-width: 0;
  max-height: calc(100vh - 80px);
  overflow-y: auto;
  /* tame scrollbars on the sticky col */
  scrollbar-width: thin;
}

.dash-ch2-detail {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  min-width: 0;
}

.dash-ch2-detail-head {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  justify-content: space-between;
  padding: 0.1rem 0 0.4rem;
}

.dash-ch2-detail-title { display: flex; flex-direction: column; gap: 0.15rem; min-width: 0; }
.dash-ch2-detail-title strong { font-size: 1rem; color: var(--text-primary); }
.dash-ch2-detail-sub { color: var(--text-muted); font-size: 0.78rem; }

/* Phase 5j-fix (2026-05-30): brand-icon container in the detail header.
   Inline brand SVGs (WhatsApp, Telegram) ship their own brand colour as
   `fill`; Lucide brand icons (Instagram, Facebook) get colour via CSS. */
.dash-ch2-detail-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
  flex-shrink: 0;
}
.dash-ch2-detail-icon .dash-channel-brand-icon,
.dash-ch2-detail-icon i { width: 18px; height: 18px; }

/* Brand icon shared sizing — used inside .dash-ch2-row-icon and
   .dash-ch2-detail-icon. SVG brand icons inherit currentColor where
   applicable; inline brand SVGs ship their own fill colour. */
.dash-channel-brand-icon { display: inline-block; vertical-align: middle; }

/* ── Per-channel meta row (WA-only): label input + color swatch ──── */
.dash-ch2-meta-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0.15rem 0 0.6rem;
}

.dash-ch2-label-input {
  flex: 1;
  min-width: 0;
  padding: 0.4rem 0.6rem;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--glass-border);
  border-radius: 8px;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.82rem;
  outline: none;
  transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
}
.dash-ch2-label-input::placeholder { color: var(--text-muted); }
.dash-ch2-label-input:hover { border-color: var(--glass-border-hover); }
.dash-ch2-label-input:focus {
  border-color: var(--color-success, var(--accent-green));
  background: rgba(255, 255, 255, 0.05);
  box-shadow: 0 0 0 2px rgba(37, 211, 102, 0.18);
}

.dash-ch2-color-swatch {
  flex-shrink: 0;
  width: 24px;
  height: 24px;
  padding: 0;
  border-radius: 50%;
  border: 1.5px solid var(--glass-border);
  cursor: pointer;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.18), 0 1px 2px rgba(0, 0, 0, 0.25);
  transition: transform 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}
.dash-ch2-color-swatch:hover {
  transform: translateY(-1px);
  border-color: rgba(255, 255, 255, 0.45);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.22), 0 2px 6px rgba(0, 0, 0, 0.35);
}
.dash-ch2-color-swatch:focus-visible {
  outline: 2px solid var(--color-success, var(--accent-green));
  outline-offset: 2px;
}

.dash-ch2-card { margin-bottom: 0; }

.dash-ch2-detail-empty {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.dash-ch2-detail-fields {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.4rem;
}

/* ── Composite WA Health tile ────────────────────────────────────── */
.dash-ch2-health-tile {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.dash-ch2-health-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
}

.dash-ch2-health-title {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-secondary);
}

.dash-ch2-health-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem 0.4rem;
}

.dash-ch2-attr-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 6px;
  font-size: 0.7rem;
  color: var(--text-secondary);
}
.dash-ch2-attr-label {
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-size: 0.62rem;
}

/* ── Templates / Flows toolbar ───────────────────────────────────── */
.dash-ch2-toolbar {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 0.5rem;
  margin: 0.5rem 0 0.75rem;
  align-items: center;
}

.dash-ch2-search {
  position: relative;
  display: flex;
  align-items: center;
}
.dash-ch2-search-icon {
  position: absolute;
  left: 0.55rem;
  width: 14px;
  height: 14px;
  color: var(--text-muted);
  pointer-events: none;
}
.dash-ch2-search-input {
  width: 100%;
  padding: 0.4rem 0.6rem 0.4rem 1.85rem;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--glass-border);
  border-radius: 8px;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.82rem;
  outline: none;
  transition: border-color 0.15s, background 0.15s;
}
.dash-ch2-search-input:focus {
  border-color: var(--glass-border-hover);
  background: rgba(255, 255, 255, 0.05);
}
.dash-ch2-search-input:disabled { cursor: not-allowed; opacity: 0.65; }

.dash-ch2-filter {
  padding: 0.4rem 0.55rem;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--glass-border);
  border-radius: 8px;
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 0.78rem;
  outline: none;
  cursor: pointer;
}
.dash-ch2-filter:disabled { cursor: not-allowed; opacity: 0.65; }

/* ── Sticky table header (templates + flows) ─────────────────────── */
.dash-ch2-table-wrap { max-height: 60vh; overflow-y: auto; }

.dash-ch2-table thead th {
  position: sticky;
  top: 0;
  background: var(--bg-card);
  z-index: 1;
  box-shadow: 0 1px 0 0 var(--glass-border);
}
