/* ── Live Chasers layout ──────────────────────────────────────────── */

/* Full-viewport flex layout. Sidebar is fixed-width on the left; stage
 * takes the rest. Stage is a flex-column where the primary grid grows
 * to fill whatever vertical space the browser has. Nothing hard-capped. */
.chasers-main {
  display: flex;
  align-items: stretch;
  gap: 0.85rem;
  min-height: calc(100vh - 5.5rem);
}

.chasers-stage {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
}

.chasers-preview-card {
  padding: 0.55rem 0.7rem;
  flex: 0 0 auto;
}

.chasers-primary-card {
  padding: 0.55rem 0.7rem;
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  min-height: 0;
  position: relative;
}

.chasers-toolbar {
  display: flex;
  gap: 0.5rem;
}

/* Sticky sidebar — Refresh/Add stays put, feed list scrolls internally. */
.chasers-sidebar {
  flex: 0 0 16rem;
  padding: 0.6rem 0.7rem;
  position: sticky;
  top: 5rem;
  align-self: flex-start;
  max-height: calc(100vh - 6rem);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.chasers-sidebar #feed-list {
  flex: 1 1 auto;
  min-height: 0;
  max-height: none;
}
@media (max-width: 900px) {
  .chasers-main { flex-direction: column; }
  .chasers-sidebar {
    position: static;
    max-height: none;
    flex: 1 1 100%;
  }
  .chasers-sidebar #feed-list { max-height: 18rem; }
}

.chasers-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.45rem;
}
.chasers-section-header h2 {
  margin: 0;
  font-size: 0.95rem;
  letter-spacing: 0.02em;
}

/* ── Layout toggles (preview count / primary grid dimensions) ───── */

.chasers-layout-toggle {
  display: inline-flex;
  gap: 0.18rem;
  padding: 0.18rem;
  background: rgba(15, 12, 32, 0.75);
  border: 1px solid var(--border);
  border-radius: 0.45rem;
}
.chaser-layout-btn {
  appearance: none;
  background: transparent;
  color: var(--muted);
  border: 1px solid transparent;
  border-radius: 0.35rem;
  padding: 0.2rem 0.55rem;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  cursor: pointer;
  transition: background 0.12s ease, color 0.12s ease, border-color 0.12s ease;
}
.chaser-layout-btn:hover {
  color: var(--text);
  background: rgba(179, 136, 255, 0.1);
}
.chaser-layout-btn[aria-pressed="true"] {
  color: var(--text);
  background: rgba(179, 136, 255, 0.25);
  border-color: var(--accent);
  box-shadow: inset 0 0 8px rgba(179, 136, 255, 0.25);
}

/* Primary grid — columns/rows driven by data attributes from JS. Slots
 * have `aspect-ratio: auto` so they shrink into whatever space the flex
 * parent gives them, instead of forcing the page taller. */
.primary-grid-inner {
  display: grid;
  gap: 0.45rem;
  flex: 1 1 auto;
  min-height: 0;
  grid-template-columns: repeat(var(--cols, 2), minmax(0, 1fr));
  grid-template-rows: repeat(var(--rows, 2), minmax(0, 1fr));
}
.primary-grid-inner[data-cols="2"] { --cols: 2; }
.primary-grid-inner[data-cols="3"] { --cols: 3; }
.primary-grid-inner[data-cols="4"] { --cols: 4; }
.primary-grid-inner[data-rows="2"] { --rows: 2; }
.primary-grid-inner[data-rows="3"] { --rows: 3; }
.primary-grid-inner > .stream-slot {
  aspect-ratio: auto;
  min-height: 0;
  min-width: 0;
}

/* ── Sidebar feed cards ─────────────────────────────────────────────
 *
 * Compact mode: name + platform icon on a tight first line, icon row
 * directly underneath (no gap), location as a 10px inline chip. With 20+
 * feeds the sidebar becomes a scrollable column that doesn't demand
 * nearly as much vertical space per item.
 */

#feed-list {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding-right: 0.25rem;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}
#feed-list::-webkit-scrollbar        { width: 6px; }
#feed-list::-webkit-scrollbar-thumb  { background: var(--border); border-radius: 3px; }

/* Sidebar pager: prev/next + "1 / N" label. Hidden when only one page
 * of feeds exists. Sits just below the feed list so the page controls
 * stay put while the cards above re-render per page. */
.chaser-pager {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.4rem;
  padding: 0.25rem 0.1rem 0;
  flex: 0 0 auto;
}
.chaser-pager.hidden { display: none; }
.chaser-pager .chaser-icon-btn {
  flex: 0 0 auto;
  min-width: 1.8rem;
  height: 1.55rem;
}
.chaser-pager .chaser-icon-btn[disabled] {
  opacity: 0.35;
  cursor: not-allowed;
}
.chaser-pager-label {
  flex: 1 1 auto;
  text-align: center;
  font-size: 0.72rem;
  color: var(--muted);
  letter-spacing: 0.04em;
}

.chaser-card {
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-areas:
    "title    platform"
    "actions  actions";
  gap: 0.2rem 0.5rem;
  align-items: center;
  padding: 0.3rem 0.5rem;
  border-radius: 0.5rem;
  background: rgba(15, 12, 32, 0.75);
  border: 1px solid var(--border);
  border-left-width: 3px;
  margin-bottom: 0.3rem;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.chaser-card:hover {
  border-color: var(--accent);
  background: rgba(22, 18, 44, 0.9);
}
.chaser-card--focus   { border-left-color: var(--accent);   box-shadow: 0 0 10px -3px var(--accent); }
.chaser-card--primary { border-left-color: var(--success); }
.chaser-card--preview { border-left-color: var(--info); }

/* 1.18 live tracking — LIVE chasers get a pulsing red border-left so the
 * eye locks onto active streams during severe coverage. Offline chasers
 * fade so they don't visually compete; click them to load anyway (the
 * url column still points at their last-known broadcast). */
.chaser-card--live {
  border-left-color: #dc2626;
  border-left-width: 4px;
  animation: chaser-live-pulse 1.6s ease-in-out infinite;
}
.chaser-card--offline {
  opacity: 0.55;
}
.chaser-card--offline:hover { opacity: 0.95; }

@keyframes chaser-live-pulse {
  0%, 100% { box-shadow: inset 4px 0 0 rgba(220, 38, 38, 0.95), 0 0 0 transparent; }
  50%      { box-shadow: inset 4px 0 0 rgba(220, 38, 38, 1.0),  0 0 12px rgba(220, 38, 38, 0.55); }
}
@media (prefers-reduced-motion: reduce) {
  .chaser-card--live { animation: none; }
}

.chaser-live-pill {
  display: inline-block;
  margin-left: 0.35rem;
  padding: 0.05rem 0.4rem;
  border-radius: 3px;
  background: #dc2626;
  color: #fff;
  font-size: 0.62rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  vertical-align: middle;
}
.chaser-offline-pill {
  display: inline-block;
  margin-left: 0.35rem;
  padding: 0.05rem 0.4rem;
  border-radius: 3px;
  background: rgba(148, 163, 184, 0.15);
  color: var(--muted);
  font-size: 0.62rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  vertical-align: middle;
}

.chaser-card-title {
  grid-area: title;
  font-weight: 600;
  font-size: 0.82rem;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}
.chaser-card-platform {
  grid-area: platform;
  font-size: 0.95rem;
  line-height: 1;
  flex-shrink: 0;
  opacity: 0.85;
}
.chaser-card-actions {
  grid-area: actions;
  display: flex;
  gap: 0.18rem;
  flex-wrap: nowrap;
  align-items: center;
}

/* Inline location pin button: sits at the right edge of the actions
 * row. Two visual states:
 *   --has    = location is set; shows pin + truncated text in accent color
 *   --empty  = no location; shows just a faded pin (Set affordance)
 * Click opens the location popover so the operator can set/edit without
 * opening the full feed modal. */
.chaser-location-btn {
  flex: 1 1 auto;
  min-width: 0;
  max-width: 100%;
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  margin-left: auto;
  padding: 0.15rem 0.35rem;
  height: 1.55rem;
  font-size: 0.7rem;
  line-height: 1;
  appearance: none;
  background: transparent;
  border: 1px dashed transparent;
  color: var(--muted);
  border-radius: 0.35rem;
  cursor: pointer;
  overflow: hidden;
  transition: background 0.12s ease, border-color 0.12s ease, color 0.12s ease;
}
.chaser-location-btn:hover {
  background: rgba(179, 136, 255, 0.12);
  border-color: var(--accent);
  color: var(--text);
}
.chaser-location-btn--has {
  color: var(--text);
  border-color: rgba(179, 136, 255, 0.35);
  background: rgba(179, 136, 255, 0.08);
}
.chaser-location-btn--empty {
  flex: 0 0 auto;
  color: var(--muted);
  opacity: 0.5;
  border-color: transparent;
}
.chaser-location-btn--empty:hover { opacity: 1; }
.chaser-location-btn .pin-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

/* Tight emoji icon buttons. */
.chaser-icon-btn {
  appearance: none;
  background: rgba(28, 24, 56, 0.7);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 0.35rem;
  padding: 0.1rem 0.28rem;
  min-width: 1.55rem;
  height: 1.45rem;
  font-size: 0.75rem;
  line-height: 1;
  cursor: pointer;
  flex: 0 0 auto;
  transition: background 0.12s ease, border-color 0.12s ease, transform 0.08s ease;
}
.chaser-icon-btn:hover {
  border-color: var(--accent);
  background: rgba(179, 136, 255, 0.16);
}
.chaser-icon-btn:active { transform: translateY(1px); }
.chaser-icon-btn[aria-pressed="true"] {
  border-color: var(--accent);
  background: rgba(179, 136, 255, 0.3);
  box-shadow: inset 0 0 8px rgba(179, 136, 255, 0.35);
}
.chaser-icon-btn--danger:hover {
  border-color: var(--danger);
  background: rgba(255, 43, 90, 0.2);
}

/* ── Stream slots (preview + primary + focus) ─────────────────────── */

.stream-slot {
  position: relative;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 0.55rem;
  background: #05030f;
  display: flex;
  flex-direction: column;
}

.stream-slot .wx-placeholder {
  margin: auto;
  color: var(--muted);
  font-size: 0.78rem;
}

.stream-frame {
  width: 100%;
  height: 100%;
  border: 0;
  background: transparent;
}

/* Top overlay: small translucent strip with name + hover-visible controls */
.stream-overlay-top {
  position: absolute;
  top: 0; left: 0; right: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.3rem 0.45rem;
  background: linear-gradient(180deg, rgba(5, 3, 15, 0.8), rgba(5, 3, 15, 0));
  opacity: 0;
  transition: opacity 0.15s ease;
  pointer-events: none;
}
.stream-slot:hover .stream-overlay-top { opacity: 1; }
.stream-overlay-top > * { pointer-events: auto; }
/* The overlay-top bar is the drag handle for slot reordering. The grab
 * cursor signals it; while dragging the browser auto-changes to grabbing. */
.stream-overlay-top[draggable="true"] {
  cursor: grab;
  pointer-events: auto;  /* override the parent's pointer-events:none so dragstart fires */
}
.stream-overlay-top[draggable="true"]:active { cursor: grabbing; }
.stream-drag-grip {
  font-size: 0.85rem;
  color: rgba(255, 255, 255, 0.55);
  letter-spacing: -2px;
  margin-right: 0.25rem;
  user-select: none;
}

/* Drag/drop visual feedback */
.stream-slot--dragging {
  opacity: 0.55;
  outline: 2px dashed rgba(56, 189, 248, 0.55);
  outline-offset: -2px;
}
.stream-slot--drop-target {
  outline: 3px solid #22c55e;
  outline-offset: -3px;
}
.stream-slot--drop-target::before {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(34, 197, 94, 0.12);
  pointer-events: none;
  z-index: 3;
}
.chaser-card[draggable="true"] {
  cursor: grab;
}
.chaser-card[draggable="true"]:active { cursor: grabbing; }
.chaser-card--dragging {
  opacity: 0.55;
  outline: 2px dashed rgba(56, 189, 248, 0.55);
}

.stream-name-chip {
  font-size: 0.78rem;
  font-weight: 600;
  color: #fff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.7);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 70%;
}
.stream-overlay-controls {
  display: flex;
  gap: 0.25rem;
}
.stream-overlay-controls .chaser-icon-btn {
  padding: 0.15rem 0.35rem;
  min-width: 1.7rem;
  font-size: 0.8rem;
  background: rgba(10, 8, 24, 0.75);
}

/* News-ticker location overlay — always visible, bottom-left of the
 * player. Styled after a broadcast lower-third. */
.stream-location-chip {
  position: absolute;
  left: 0.45rem;
  bottom: 0.45rem;
  z-index: 2;
  padding: 0.28rem 0.65rem;
  border-radius: 0.35rem;
  font-size: 0.72rem;
  font-weight: 600;
  color: #fff;
  background: linear-gradient(135deg, rgba(179, 136, 255, 0.92), rgba(139, 92, 246, 0.9));
  border: 1px solid rgba(255, 255, 255, 0.25);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.45);
  letter-spacing: 0.02em;
  text-transform: uppercase;
  max-width: calc(100% - 0.9rem);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  pointer-events: none;
}
/* Red news-ticker when the feed is in focus (urgent viewing) */
.focus-slot .stream-location-chip {
  background: linear-gradient(135deg, rgba(255, 43, 90, 0.95), rgba(185, 28, 28, 0.95));
}

/* ── Preview row: 7 per row, 1–3 rows based on toggle ─────────── */

.preview-row {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  grid-auto-rows: minmax(0, 1fr);
  gap: 0.4rem;
}
.preview-row[data-rows="1"] { grid-template-rows: minmax(0, auto); }
.preview-row[data-rows="2"] { grid-template-rows: repeat(2, minmax(0, auto)); }
.preview-row[data-rows="3"] { grid-template-rows: repeat(3, minmax(0, auto)); }

.preview-slot { font-size: 0.7rem; aspect-ratio: 16 / 9; min-height: 0; min-width: 0; }
.preview-slot .stream-name-chip { max-width: 100%; font-size: 0.68rem; }
.preview-slot .stream-location-chip {
  font-size: 0.6rem;
  padding: 0.15rem 0.4rem;
  left: 0.3rem;
  bottom: 0.3rem;
}
.preview-slot .stream-overlay-top { opacity: 1; background: rgba(5, 3, 15, 0.6); }

/* On narrower windows reduce column count so slots don't become postage
 * stamps. At 7 columns on a 1024px display each slot is ~140px wide. */
@media (max-width: 1400px) {
  .preview-row { grid-template-columns: repeat(6, minmax(0, 1fr)); }
}
@media (max-width: 1100px) {
  .preview-row { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
@media (max-width: 700px) {
  .preview-row { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 480px) {
  .preview-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* ── Primary grid wrapper + focus overlay ──────────────────────── */

.primary-grid-wrapper {
  position: relative;
  overflow: hidden;
}
.focus-overlay {
  position: absolute;
  inset: 0;
  z-index: 10;
  background: var(--card);
  border-radius: inherit;
  display: flex;
  flex-direction: column;
  padding: 0.6rem;
}
.focus-overlay.hidden { display: none; }
.focus-overlay-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.5rem;
}
.focus-frame {
  flex: 1;
  min-height: 0;
  display: flex;
}
.focus-frame > .stream-slot {
  flex: 1;
  aspect-ratio: auto;
}

/* ── Add/Edit modal: detection hint ──────────────────────────────── */

.feed-detect-hint {
  margin-top: 0.3rem;
  font-size: 0.75rem;
  color: var(--muted);
  min-height: 1em;
}
.feed-detect-hint--ok   { color: var(--accent); }
.feed-detect-hint--warn { color: var(--warn); }

/* Narrow-viewport fallback: single-column primary grid so slots stay
 * usable. (The preview row's breakpoints live next to its rules above.) */
@media (max-width: 700px) {
  .primary-grid-inner { grid-template-columns: 1fr !important; }
}

/* ── Quick-edit location popover ──────────────────────────────────────
 * A tiny floating dialog anchored to whichever pin button was clicked.
 * Positioned absolutely (left/top set inline by JS based on the
 * button's bounding rect). Save commits a partial PUT to manage.php so
 * the operator never has to leave the dashboard to add a county tag. */
.location-popover {
  position: fixed;
  z-index: 60;
  background: var(--card, #110d28);
  border: 1px solid var(--accent);
  border-radius: 0.5rem;
  padding: 0.55rem;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.55);
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  min-width: 16rem;
  max-width: 22rem;
}
.location-popover.hidden { display: none; }
.location-popover input {
  width: 100%;
  padding: 0.35rem 0.5rem;
  font-size: 0.85rem;
  background: rgba(5, 3, 15, 0.7);
  border: 1px solid var(--border);
  border-radius: 0.3rem;
  color: var(--text);
}
.location-popover input:focus {
  outline: none;
  border-color: var(--accent);
}
.location-popover-actions {
  display: flex;
  gap: 0.35rem;
  justify-content: flex-end;
}
.location-popover-btn {
  padding: 0.25rem 0.7rem;
  font-size: 0.75rem;
  border-radius: 0.3rem;
}
