/* PlexRemap components: show list, remap editor, rule cards, plan preview, source picker.
   Builds on the tokens and primitives in app.css. */

/* ------------------------------------------------------------------ shows */
.show-head { display: grid; grid-template-columns: 60px minmax(0, 1fr) auto; gap: var(--s-m); align-items: center; padding: 12px 14px; }
.show-head .poster { width: 60px; height: 90px; }
.show-list { display: flex; flex-direction: column; gap: 2px; }
.show-row { display: grid; grid-template-columns: 44px minmax(0, 1fr) auto; gap: 12px; align-items: center;
  padding: 8px 12px; cursor: pointer; border-radius: var(--r); border: 1px solid transparent; text-align: left;
  background: transparent; width: 100%; color: inherit; }
.show-row:hover { background: var(--surface2); border-color: var(--border); }
.show-row .poster { width: 44px; height: 66px; }
.show-row .t { font-weight: 600; }

/* ------------------------------------------------------------------ editor */
.editor { display: grid; grid-template-columns: minmax(0, 1fr) minmax(360px, 460px); gap: var(--s-l); align-items: start; }
.rule-col { position: sticky; top: 74px; display: flex; flex-direction: column; gap: var(--s-m);
  max-height: calc(100vh - 92px); overflow: auto; padding-right: 2px; }
@media (max-width: 1080px) {
  .editor { grid-template-columns: 1fr; }
  .rule-col { position: static; max-height: none; order: -1; }
}

.season-block + .season-block { margin-top: var(--s-m); }
.season-head { display: flex; align-items: center; gap: 10px; padding: 9px 12px; background: var(--surface2);
  border: 1px solid var(--border); border-radius: var(--r) var(--r) 0 0; position: sticky; top: 58px; z-index: 5; }
.season-head .h3 { flex: 1; }
.season-body { border: 1px solid var(--border); border-top: 0; border-radius: 0 0 var(--r) var(--r);
  background: var(--surface); overflow: hidden; }

.ep-row { display: grid; grid-template-columns: 52px 92px minmax(0, 1fr) auto; gap: 12px; align-items: center;
  padding: 7px 12px; position: relative; }
.ep-row + .ep-row { border-top: 1px solid var(--border); }
.ep-row:hover { background: var(--surface2); }
.ep-row .num { font-family: var(--mono); font-size: 12px; font-weight: 700; color: var(--text2); letter-spacing: -.3px; }
.ep-row .still { width: 92px; aspect-ratio: 16/9; border-radius: 5px; background: var(--surface2);
  border: 1px solid var(--border); overflow: hidden; position: relative; flex: none; }
.ep-row .still img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.ep-row .t { font-weight: 600; line-height: 1.3; }
.ep-row .sub { color: var(--text3); font-size: 12px; margin-top: 1px; }
.ep-row.mapped { background: color-mix(in srgb, var(--accent) 8%, transparent); }
.ep-row.mapped:hover { background: color-mix(in srgb, var(--accent) 13%, transparent); }
.ep-row.mapped::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--accent); }
.ep-row.mapped .num { color: var(--accent); }
.ep-row.placeholder .t { color: var(--text3); font-weight: 500; font-style: italic; }
.ep-row .acts { display: flex; gap: 4px; opacity: 0; transition: opacity .12s; }
.ep-row:hover .acts, .ep-row:focus-within .acts { opacity: 1; }
@media (hover: none) { .ep-row .acts { opacity: 1; } }

/* ------------------------------------------------------------------ rules */
.rule { border: 1px solid var(--border); border-radius: var(--r); background: var(--surface); overflow: hidden; }
.rule.off { opacity: .55; }
.rule > header { display: flex; align-items: center; gap: 8px; padding: 8px 10px 8px 12px;
  background: var(--surface2); border-bottom: 1px solid var(--border); }
.rule > header .grow { min-width: 0; }
.rule .flow { display: grid; grid-template-columns: minmax(0, 1fr) 22px minmax(0, 1fr); gap: 8px;
  align-items: center; padding: 10px 12px; }
.rule .side { min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.rule .side .lbl { font-size: 11px; text-transform: uppercase; letter-spacing: .6px; color: var(--text3); font-weight: 700; }
.rule .side .val { font-weight: 600; line-height: 1.25; overflow-wrap: anywhere; }
.rule .side .val .mono { color: var(--accent); }
.rule .arrow { display: grid; place-items: center; color: var(--text3); }
.rule .note { padding: 0 12px 10px; }
.rule footer { display: flex; gap: 6px; align-items: center; padding: 8px 10px; border-top: 1px solid var(--border); }

.kind-chip { display: inline-flex; align-items: center; gap: 5px; font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .5px; padding: 2px 8px; border-radius: 6px;
  background: color-mix(in srgb, var(--c, var(--accent)) 16%, transparent); color: var(--c, var(--accent));
  border: 1px solid color-mix(in srgb, var(--c, var(--accent)) 38%, transparent); }
.k-episode { --c: var(--accent); }
.k-season { --c: var(--manual); }
.k-movie { --c: var(--auto); }

/* ------------------------------------------------------------------ plan preview */
.plan { display: flex; flex-direction: column; border: 1px solid var(--border); border-radius: var(--r); overflow: hidden; }
.plan-row { display: grid; grid-template-columns: 22px 78px minmax(0, 1fr); gap: 10px; padding: 9px 12px;
  align-items: start; background: var(--surface); }
.plan-row + .plan-row { border-top: 1px solid var(--border); }
.plan-row .slot { font-family: var(--mono); font-size: 12px; font-weight: 700; padding-top: 1px; }
.plan-row .state { display: grid; place-items: center; padding-top: 2px; }
.plan-row.is-missing, .plan-row.is-nosource { background: color-mix(in srgb, var(--error) 7%, transparent); }
.plan-row.is-unchanged { color: var(--text2); }
.diff { display: grid; grid-template-columns: 74px minmax(0, 1fr); gap: 2px 10px; font-size: 12.5px; margin-top: 4px; }
.diff .f { color: var(--text3); font-size: 12px; }
.diff .old { color: var(--text3); text-decoration: line-through;
  text-decoration-color: color-mix(in srgb, var(--error) 70%, transparent); }
.diff .new { color: var(--text); overflow-wrap: anywhere; }
.plan-head { display: flex; gap: var(--s-s); flex-wrap: wrap; align-items: center; margin-bottom: var(--s-m); }

/* ------------------------------------------------------------------ source picker */
.src-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(300px, 380px); gap: var(--s-m); align-items: start; }
@media (max-width: 860px) { .src-grid { grid-template-columns: 1fr; } }
.src-list { display: flex; flex-direction: column; gap: 2px; max-height: 46vh; overflow: auto; }
.src-row { display: grid; grid-template-columns: 40px minmax(0, 1fr) auto; gap: 10px; align-items: center;
  padding: 6px 8px; border-radius: var(--r); border: 1px solid transparent; cursor: pointer; background: transparent;
  width: 100%; text-align: left; color: inherit; }
.src-row:hover { background: var(--surface2); border-color: var(--border); }
.src-row.active { background: var(--accent-soft); border-color: var(--accent); }
.src-row .poster { width: 40px; height: 60px; }
.src-eps { max-height: 42vh; overflow: auto; display: flex; flex-direction: column; gap: 1px; }
.src-ep { display: grid; grid-template-columns: 58px minmax(0, 1fr); gap: 10px; padding: 6px 8px; border-radius: 6px;
  cursor: pointer; border: 1px solid transparent; background: transparent; width: 100%; text-align: left;
  align-items: center; color: inherit; }
.src-ep:hover { background: var(--surface2); border-color: var(--border); }
.src-ep.active { background: var(--accent-soft); border-color: var(--accent); }
.src-ep .n { font-family: var(--mono); font-size: 12px; font-weight: 700; color: var(--text2); }
.src-ep.active .n { color: var(--accent); }

.steps { display: flex; gap: 6px; align-items: center; margin-bottom: var(--s-m); flex-wrap: wrap; }
.step { display: inline-flex; align-items: center; gap: 7px; padding: 4px 11px; border-radius: 20px; font-size: 12.5px;
  font-weight: 600; background: var(--surface2); border: 1px solid var(--border); color: var(--text3); }
.step.done { color: var(--text); }
.step.now { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.step .n { width: 18px; height: 18px; border-radius: 50%; display: grid; place-items: center; font-size: 11px;
  background: var(--border-strong); color: var(--surface); }
.step.now .n, .step.done .n { background: var(--accent); color: var(--accent-text); }

/* ------------------------------------------------------------------ responsive */
@media (max-width: 720px) {
  .topbar { flex-wrap: wrap; gap: 4px; }
  .topbar .segment { order: 3; width: 100%; overflow-x: auto; }
  .brand small { display: none; }
  .topbar .brand > span { display: none; }
  .grid { grid-template-columns: minmax(0, 1fr); }
  .main { padding-inline: 12px; }
  .stat-row { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-bottom: var(--s-m); }
  .stat { padding: 10px; gap: 8px; }
  .stat .ico { width: 28px; height: 28px; border-radius: 8px; }
  .stat .big { font-size: 18px; }
  .season-head { top: 52px; }
  /* the still is the first thing to go: number, title and buttons must stay readable */
  .ep-row { grid-template-columns: 46px minmax(0, 1fr) auto; gap: 8px; padding: 7px 10px; }
  .ep-row .still { display: none; }
  .rule .flow { grid-template-columns: minmax(0, 1fr); gap: 6px; }
  .rule .arrow { display: none; }
  .plan-row { grid-template-columns: 20px minmax(0, 1fr); gap: 4px 8px; }
  .plan-row .slot { grid-column: 2; }
  .diff { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .diff .f { margin-top: 4px; }
  .dialog > footer { flex-wrap: wrap; justify-content: flex-start; padding: 10px 12px; }
  .dialog > header, .dialog > .body { padding: 12px; }
}

/* rows in the "target slot has no file" card carry their own delete button */
.missing-row { align-items: stretch; gap: 0; background: var(--surface); }
.missing-row + .missing-row { border-top: 1px solid var(--border); }
.missing-row > .grow { min-width: 0; }
.missing-row > .btn { align-self: center; margin-right: 8px; }
.missing-row .plan-row { border: 0; }

/* ------------------------------------------------------------------ backups */
.backup-list { display: flex; flex-direction: column; border: 1px solid var(--border);
  border-radius: var(--r); overflow: hidden; margin-top: 10px; }
.backup-row { display: grid; grid-template-columns: 26px minmax(0, 1fr) auto; gap: 10px; align-items: center;
  padding: 8px 10px; background: var(--surface); }
.backup-row + .backup-row { border-top: 1px solid var(--border); }
.backup-row:hover { background: var(--surface2); }
.backup-row .ico { display: grid; place-items: center; color: var(--text3); }
.backup-row .t { font-weight: 600; line-height: 1.25; }
.check-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px 14px; }

/* ------------------------------------------------------------------ column headings */
/* Both columns of the editor start with the same kind of line, so the two halves read as
   two lists instead of one wall of cards. */
.col-head { display: flex; align-items: baseline; gap: 10px; padding: 0 2px var(--s-s); }
.col-head .h2 { margin: 0; }
.rule-list { display: flex; flex-direction: column; gap: 10px; margin-top: 10px; }

/* the delete button sits beside the row, not inside its click area */
.show-row-wrap { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px; align-items: center; }
.show-row-wrap .show-row { grid-column: 1; }
.show-row-wrap > .btn { opacity: 0; transition: opacity .12s; }
.show-row-wrap:hover > .btn, .show-row-wrap:focus-within > .btn { opacity: 1; }
@media (hover: none) { .show-row-wrap > .btn { opacity: 1; } }

/* ------------------------------------------------------------------ source preview */
/* What the rule would put on the episode: texts with their language, and the picture -
   the one thing a URL cannot tell you anything about. */
.pv { margin-top: 10px; border-top: 1px solid var(--border); padding-top: 10px; }
.pv-top { display: grid; grid-template-columns: 168px minmax(0, 1fr); gap: 12px; align-items: start; }
.pv-still { aspect-ratio: 16/9; border-radius: 6px; background: var(--surface2); border: 1px solid var(--border);
  overflow: hidden; display: grid; place-items: center; font-size: 12px; text-align: center; padding: 6px; }
.pv-still img { width: 100%; height: 100%; object-fit: cover; }
.pv-line + .pv-line { margin-top: 6px; }
.pv-line > .faint { font-size: 11px; text-transform: uppercase; letter-spacing: .5px; }
.pv-images { margin-top: 12px; }
.thumb-pick { display: flex; gap: 8px; overflow-x: auto; padding: 8px 2px 2px; }
.thumb-tile { flex: none; width: 104px; aspect-ratio: 16/9; border-radius: 6px; overflow: hidden; padding: 0;
  border: 2px solid var(--border); background: var(--surface2); cursor: pointer; position: relative;
  color: var(--text3); display: grid; place-items: center; }
.thumb-tile img { width: 100%; height: 100%; object-fit: cover; }
.thumb-tile:hover { border-color: var(--border-strong); }
.thumb-tile.active { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.thumb-tile .tag { position: absolute; left: 4px; bottom: 4px; font-size: 10px; font-weight: 700;
  padding: 1px 5px; border-radius: 4px; background: rgba(0, 0, 0, .62); color: #fff; }
/* "keep what Plex has" - dashed, and showing the picture that would stay */
.thumb-tile.none { border-style: dashed; }
.thumb-tile.none img { opacity: .8; }
.thumb-tile.none.active img { opacity: 1; }
.thumb-tile.none .tag { background: rgba(0, 0, 0, .72); }
@media (max-width: 720px) {
  .pv-top { grid-template-columns: minmax(0, 1fr); }
  .pv-still { max-width: 220px; }
}

/* ------------------------------------------------------------------ compact status */
/* Icon-only pills: the same tinted pill as before, reduced to a circle around its icon, so a
   row can carry three of them without losing the episode title. Not called ".dot" - that
   name already is the plain 8px colour dot in app.css. */
.pill.icon-only { width: 22px; height: 22px; padding: 0; gap: 0; border-radius: 50%;
  justify-content: center; flex: none; }
.pill.icon-only svg.icon { width: 13px; height: 13px; }
.ep-row .row.nowrap { gap: 5px; }

/* The season head now carries Plex's own name for the season, which is the part that may
   grow and truncate - the number beside it never wraps. */
.season-head .h3 { flex: none; }
.season-name { flex: 1; min-width: 0; color: var(--text2); font-weight: 600; }
.season-head .nowrap { white-space: nowrap; }
@media (max-width: 720px) { .season-name { display: none; } }

/* ------------------------------------------------------------------ settings */
/* One column of cards with the same gap everywhere, as in PlexAniSyncPlus. Headings inside a
   card keep their own rhythm from .stack-m. */
.settings-stack { display: flex; flex-direction: column; gap: var(--s-m); max-width: 960px; }
.settings-stack .card h3 { padding-top: var(--s-s); }

/* ------------------------------------------------------------------ hover zoom */
/* Floats above dialogs and toasts, never takes the pointer - otherwise it would steal the
   hover from the very image it enlarges. Sized by the picture: wide stills get width,
   portrait covers get height. */
.zoom { position: fixed; left: 0; top: 0; z-index: 80; pointer-events: none; padding: 4px;
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: 10px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, .45); opacity: 0; transition: opacity .12s; }
.zoom.ready { opacity: 1; }
.zoom img { display: block; max-width: min(640px, 46vw); max-height: min(560px, 72vh);
  width: auto; height: auto; border-radius: 7px; }
[data-zoom] { cursor: zoom-in; }
.thumb-tile[data-zoom] { cursor: pointer; }

/* ------------------------------------------------------------------ insert dialog */
.insert-list { margin: 0; padding-left: 18px; display: flex; flex-direction: column; gap: 4px; font-size: 13px; }
.insert-list b { font-weight: 600; }

/* an episode Plex could not place anywhere and nothing fills - it has no metadata at all */
.ep-row.unmatched { background: color-mix(in srgb, var(--warning) 7%, transparent); }
.ep-row.unmatched::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px;
  background: var(--warning); }
.ep-row.unmatched .num { color: var(--warning); }
