/* watchlist.css — Replica visiva WatchlistView.swift (iOS).
   Aree: Home / Da vedere / Condivise / Per te.
   Sezioni Home: Percorsi&rewatch / Da vedere / Condivise / Idee rapide. */

:root {
  --wl-card-radius: 22px;
  --wl-row-radius: 18px;
  --wl-section-gap: 1.4rem;
}

/* ─── Page header (matching iOS WatchlistPageHeader) ───────────────── */
.wl-page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.8rem;
  padding: 0 0 0.8rem;
}
.wl-page-headline h1 {
  margin: 0 0 0.15rem;
  font-size: 1.85rem;
  font-weight: var(--weight-bold);
  color: var(--text-primary);
  letter-spacing: -0.01em;
}
.wl-page-headline p {
  margin: 0;
  color: var(--text-secondary);
  font-size: 0.92rem;
}
.wl-page-actions { display: flex; gap: 0.45rem; }
.wl-page-iconbtn {
  width: 40px; height: 40px;
  border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text-primary);
  cursor: pointer;
  transition: transform 0.12s ease, background 0.12s ease;
}
.wl-page-iconbtn:active { transform: scale(0.95); }
.wl-page-iconbtn.primary {
  background: var(--text-primary);
  color: var(--bg-primary);
  border-color: var(--text-primary);
}
.wl-page-iconbtn svg { width: 18px; height: 18px; }

/* ─── Area picker (4 segment iOS) ──────────────────────────────────── */
.wl-area-picker {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.4rem;
  padding: 0.35rem;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  margin-bottom: 1rem;
}
.wl-area-btn {
  appearance: none;
  background: transparent;
  border: 0;
  color: var(--text-secondary);
  padding: 0.55rem 0.4rem;
  border-radius: var(--radius-md);
  display: flex; flex-direction: column; align-items: center; gap: 0.25rem;
  font-size: 0.74rem; font-weight: var(--weight-semibold);
  cursor: pointer;
  transition: background 0.18s ease, color 0.18s ease;
}
.wl-area-btn svg { width: 18px; height: 18px; }
.wl-area-btn.is-active {
  background: var(--text-primary);
  color: #0A0A0A;
}
.wl-area-btn.is-active svg,
.wl-area-btn.is-active span { color: #0A0A0A; }
.wl-area-subtitle {
  text-align: center;
  font-size: 0.78rem;
  color: var(--text-muted);
  margin: 0 0 1rem;
}

/* ─── Sezione generica ─────────────────────────────────────────────── */
.wl-section {
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
  margin-bottom: var(--wl-section-gap);
}
.wl-section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem;
}
.wl-section-title {
  display: inline-flex; align-items: center; gap: 0.45rem;
  font-size: 1.15rem; font-weight: var(--weight-bold);
  color: var(--text-primary);
  margin: 0;
}
.wl-section-title svg { width: 18px; height: 18px; color: var(--brand-primary); }
.wl-section-link {
  font-size: 0.86rem; font-weight: var(--weight-semibold);
  color: var(--brand-primary);
  background: none; border: 0; cursor: pointer;
  text-decoration: none;
}

/* ─── Horizontal scroll generico ───────────────────────────────────── */
.wl-hscroll {
  display: flex; gap: 0.7rem;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  padding: 0.1rem 0 0.4rem;
  margin: 0 -1rem;
  padding-left: 1rem; padding-right: 1rem;
  scrollbar-width: none;
}
.wl-hscroll::-webkit-scrollbar { display: none; }
.wl-hscroll > * { scroll-snap-align: start; flex: 0 0 auto; }

/* ─── Section A: Percorsi & Rewatch (280px card) ───────────────────── */
.wl-path-card {
  width: 280px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--wl-card-radius);
  overflow: hidden;
  display: flex; flex-direction: column;
  text-decoration: none;
  color: var(--text-primary);
  cursor: pointer;
  transition: transform 0.12s ease;
}
.wl-path-card:active { transform: scale(0.98); }
.wl-path-cover {
  height: 140px;
  position: relative;
  background: linear-gradient(135deg, color-mix(in oklab, var(--brand-primary) 36%, transparent), color-mix(in oklab, var(--brand-secondary, var(--brand-primary)) 32%, transparent), rgba(0,0,0,0.7));
  display: flex; align-items: center; justify-content: center;
  color: rgba(255,255,255,0.65);
}
.wl-path-cover svg { width: 38px; height: 38px; }
.wl-path-cover .wl-path-badge {
  position: absolute; top: 12px; right: 12px;
  padding: 0.35rem 0.6rem;
  border-radius: var(--radius-pill);
  background: color-mix(in oklab, var(--brand-primary) 18%, transparent);
  color: var(--brand-primary);
  font-size: 0.72rem;
  font-weight: var(--weight-bold);
  letter-spacing: 0.02em;
}
.wl-path-body { padding: 0.85rem; display: flex; flex-direction: column; gap: 0.55rem; }
.wl-path-title { margin: 0; font-size: 0.98rem; font-weight: var(--weight-bold); }
.wl-path-sub { margin: 0; font-size: 0.78rem; color: var(--text-secondary); }
.wl-progress-bar {
  height: 5px; border-radius: var(--radius-pill);
  background: color-mix(in oklab, var(--brand-primary) 12%, transparent);
  overflow: hidden;
}
.wl-progress-bar > span {
  display: block; height: 100%;
  background: var(--brand-primary);
  border-radius: var(--radius-pill);
}
.wl-path-foot { display: flex; align-items: center; justify-content: space-between; }
.wl-path-foot strong { font-size: 0.78rem; color: var(--text-secondary); font-variant-numeric: tabular-nums; }
.wl-path-foot .pill {
  padding: 0.2rem 0.55rem; border-radius: var(--radius-pill);
  font-size: 0.72rem; font-weight: var(--weight-bold);
  color: var(--brand-primary);
  background: var(--panel-strong);
  border: 1px solid var(--border);
}

/* ─── Section B: Da vedere righe compatte (poster 56x80) ──────────── */
.wl-row {
  display: flex; align-items: center; gap: 0.7rem;
  padding: 0.7rem;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--wl-row-radius);
  text-decoration: none;
  color: var(--text-primary);
  cursor: pointer;
  transition: background 0.15s ease;
}
.wl-row:hover { background: var(--panel-hover, var(--panel)); }
.wl-row-poster {
  width: 56px; height: 80px;
  border-radius: 10px;
  background: var(--panel-strong);
  flex: 0 0 auto;
  object-fit: cover;
}
.wl-row-main { min-width: 0; flex: 1; display: flex; flex-direction: column; gap: 0.3rem; }
.wl-row-name { margin: 0; font-size: 0.92rem; font-weight: var(--weight-bold); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wl-row-meta { display: flex; align-items: center; gap: 0.45rem; flex-wrap: wrap; }
.wl-chip {
  font-size: 0.66rem; font-weight: var(--weight-bold);
  padding: 0.15rem 0.45rem;
  border-radius: var(--radius-pill);
  background: color-mix(in oklab, var(--brand-primary) 16%, transparent);
  color: var(--brand-primary);
}
.wl-row-meta-line { font-size: 0.78rem; color: var(--text-secondary); }
.wl-row-rating { display: inline-flex; align-items: center; gap: 0.2rem; color: var(--brand-primary); font-size: 0.78rem; font-weight: var(--weight-semibold); }
.wl-row-rating svg { width: 12px; height: 12px; }
.wl-row-genres { font-size: 0.74rem; color: var(--text-muted); }
.wl-row-info { color: var(--text-muted); }
.wl-row-info svg { width: 18px; height: 18px; }

/* ─── Section C: Condivise (collage 200x200) ──────────────────────── */
.wl-shared-card {
  width: 200px;
  display: flex; flex-direction: column; gap: 0.55rem;
  text-decoration: none; color: var(--text-primary);
  cursor: pointer;
}
.wl-shared-collage {
  width: 200px; height: 200px;
  border-radius: var(--wl-row-radius);
  border: 1px solid var(--border);
  overflow: hidden;
  background: linear-gradient(135deg, color-mix(in oklab, var(--brand-secondary, var(--brand-primary)) 45%, transparent), color-mix(in oklab, var(--brand-primary) 35%, transparent));
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr 1fr;
  gap: 1px;
}
.wl-shared-collage > div {
  background: rgba(0,0,0,0.5) center/cover no-repeat;
}
.wl-shared-collage.empty { display: flex; align-items: center; justify-content: center; color: rgba(255,255,255,0.6); }
.wl-shared-collage.empty svg { width: 32px; height: 32px; }
.wl-shared-title { margin: 0; font-size: 0.92rem; font-weight: var(--weight-bold); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wl-shared-sub { margin: 0; font-size: 0.78rem; color: var(--text-secondary); }

/* ─── Section D: Idee rapide (240px chip orizzontale) ─────────────── */
.wl-idea-card {
  width: 240px;
  padding: 0.7rem;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--wl-row-radius);
  display: flex; align-items: center; gap: 0.7rem;
  text-decoration: none; color: var(--text-primary);
  cursor: pointer;
}
.wl-idea-icon {
  width: 36px; height: 36px; border-radius: 50%;
  background: color-mix(in oklab, var(--brand-primary) 16%, transparent);
  color: var(--brand-primary);
  display: inline-flex; align-items: center; justify-content: center;
  flex: 0 0 auto;
}
.wl-idea-icon svg { width: 16px; height: 16px; }
.wl-idea-main { min-width: 0; flex: 1; display: flex; flex-direction: column; gap: 0.15rem; }
.wl-idea-title { margin: 0; font-size: 0.86rem; font-weight: var(--weight-bold); }
.wl-idea-sub { margin: 0; font-size: 0.74rem; color: var(--text-secondary); }
.wl-idea-chev { color: var(--text-muted); }
.wl-idea-chev svg { width: 14px; height: 14px; }

/* ─── Empty state inline ──────────────────────────────────────────── */
.wl-empty {
  border: 1px dashed var(--border);
  border-radius: var(--wl-row-radius);
  padding: 1.3rem;
  text-align: center;
  background: var(--panel);
  display: flex; flex-direction: column; gap: 0.4rem;
  align-items: center;
}
/* L'attributo [hidden] va rispettato: senza questo, display:flex sopra lo nasconde
   mai (es. #wlToWatchEmpty restava visibile anche con titoli in lista). */
.wl-empty[hidden] { display: none; }
.wl-empty .wl-empty-icon { color: var(--text-muted); }
.wl-empty .wl-empty-icon svg { width: 30px; height: 30px; }
.wl-empty h4 { margin: 0; font-size: 0.95rem; font-weight: var(--weight-bold); color: var(--text-primary); }
.wl-empty p { margin: 0; font-size: 0.84rem; color: var(--text-secondary); line-height: 1.45; }
.wl-empty .btn { margin-top: 0.35rem; }

/* ─── Filtri/sort/search per area Da vedere ───────────────────────── */
.wl-tools {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  margin-bottom: 1rem;
}
.wl-search {
  position: relative;
  display: flex; align-items: center;
  background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  padding: 0 0.85rem;
}
.wl-search svg { width: 16px; height: 16px; color: var(--text-muted); flex: 0 0 auto; }
.wl-search input {
  flex: 1; min-width: 0;
  background: transparent; border: 0; outline: none;
  color: var(--text-primary);
  padding: 0.65rem 0.5rem;
  font-size: 0.92rem;
}
.wl-search input::placeholder { color: var(--text-muted); }

.wl-filters-row {
  display: flex; flex-wrap: wrap; gap: 0.45rem;
}
.wl-filters-row .select,
.wl-filters-row input[type="number"] {
  flex: 1 1 calc(33% - 0.45rem);
  min-width: 0;
  background: var(--panel);
  border: 1px solid var(--border);
  color: var(--text-primary);
  padding: 0.55rem 0.7rem;
  border-radius: var(--radius-md);
  font-size: 0.86rem;
}
.wl-sort {
  display: flex; align-items: center; gap: 0.6rem;
  font-size: 0.78rem; color: var(--text-muted);
}
.wl-sort-group {
  display: inline-flex;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  padding: 0.2rem;
  gap: 0.15rem;
}
.wl-sort-btn {
  appearance: none; border: 0;
  background: transparent;
  color: var(--text-secondary);
  padding: 0.35rem 0.7rem;
  border-radius: var(--radius-pill);
  font-size: 0.78rem;
  font-weight: var(--weight-semibold);
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}
.wl-sort-btn.is-active { background: var(--text-primary); color: var(--bg-primary); }
.wl-sort-btn.is-active { color: #0A0A0A; }

/* ─── Chip filtro piattaforma (riga a sé, stile capsule autonomo) ───── */
.wl-platform-chips { gap: 0.4rem; }
.wl-platform-chips .wl-sort-btn {
  background: var(--panel-strong, var(--panel));
  border: 1px solid var(--border);
  color: var(--text-primary);
  padding: 0.4rem 0.8rem;
}
.wl-platform-chips .wl-sort-btn.is-active {
  background: var(--brand-primary);
  border-color: transparent;
  color: #0A0A0A;
}
.wl-platform-group-head {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.4rem;
}
.wl-platform-group-count {
  font-size: 0.72rem;
  font-weight: var(--weight-bold);
  color: var(--text-secondary);
  background: var(--panel);
  border-radius: var(--radius-pill);
  padding: 0.05rem 0.45rem;
}

/* ─── Lista compatta (area Da vedere) ─────────────────────────────── */
.wl-vstack { display: flex; flex-direction: column; gap: 0.55rem; }

/* ─── Grid liste (area Condivise full) ────────────────────────────── */
.wl-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 0.7rem;
}
.wl-grid .wl-shared-card { width: 100%; }
.wl-grid .wl-shared-collage { width: 100%; aspect-ratio: 1 / 1; height: auto; }

/* ─── Area Per te (full ideas) ────────────────────────────────────── */
.wl-ideas-vstack {
  display: flex; flex-direction: column; gap: 0.55rem;
}
.wl-ideas-vstack .wl-idea-card { width: 100%; }

@media (min-width: 720px) {
  .wl-section-title { font-size: 1.25rem; }
}

/* ============================================
   SHEET — Editor liste (Crea/Modifica)
   ============================================ */
.wl-sheet {
  position: fixed; inset: 0;
  z-index: 200;
  display: flex; flex-direction: column; justify-content: flex-end;
  pointer-events: none;
}
.wl-sheet[aria-hidden="false"] { pointer-events: auto; }
.wl-sheet-backdrop {
  position: absolute; inset: 0;
  background: rgba(0,0,0,0.55);
  opacity: 0;
  transition: opacity 0.18s ease;
}
.wl-sheet[aria-hidden="false"] .wl-sheet-backdrop { opacity: 1; }
.wl-sheet-panel {
  position: relative;
  background: var(--bg-secondary, #131313);
  border-top-left-radius: 24px;
  border-top-right-radius: 24px;
  max-height: 92vh;
  display: flex; flex-direction: column;
  transform: translateY(100%);
  transition: transform 0.24s cubic-bezier(0.2, 0.85, 0.3, 1);
  padding-bottom: env(safe-area-inset-bottom, 0);
}
.wl-sheet[aria-hidden="false"] .wl-sheet-panel { transform: translateY(0); }
.wl-sheet-handle {
  width: 38px; height: 4px; margin: 0.5rem auto 0;
  border-radius: 999px;
  background: var(--text-muted);
  opacity: 0.55;
}
.wl-sheet-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0.65rem 1rem 0.55rem;
}
.wl-sheet-head h2 {
  margin: 0; font-size: 1.05rem; font-weight: var(--weight-bold);
  color: var(--text-primary);
}
.wl-sheet-close {
  appearance: none; background: none; border: 0;
  color: var(--text-primary);
  font-size: 1.8rem; line-height: 1;
  cursor: pointer;
}
.wl-sheet-body {
  flex: 1; overflow-y: auto;
  padding: 0 1rem 1rem;
  display: flex; flex-direction: column; gap: 0.95rem;
}
.wl-sheet-foot {
  display: flex; gap: 0.5rem; flex-wrap: wrap;
  padding: 0.7rem 1rem 1rem;
  border-top: 1px solid var(--border);
  background: var(--bg-secondary, #131313);
}
.wl-sheet-foot .wl-btn-primary { flex: 1 1 auto; }

/* Form rows */
.wl-form-row { display: flex; flex-direction: column; gap: 0.4rem; }
.wl-form-row[hidden] { display: none; }
.wl-form-label {
  font-size: 0.72rem; font-weight: var(--weight-bold);
  letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--text-secondary);
}
.wl-form-label em { font-style: normal; color: var(--text-muted); }
.wl-form-input {
  background: var(--panel);
  border: 1px solid var(--border);
  color: var(--text-primary);
  border-radius: var(--radius-md);
  padding: 0.65rem 0.8rem;
  font-size: 0.92rem;
  font-family: inherit;
  outline: none;
}
.wl-form-input:focus { border-color: var(--brand-primary); }
.wl-form-textarea { resize: vertical; min-height: 64px; }

.wl-form-segments {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(0, 1fr));
  gap: 0.4rem;
}
.wl-segment-btn {
  appearance: none; background: var(--panel);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  border-radius: var(--radius-md);
  padding: 0.55rem 0.6rem;
  display: flex; flex-direction: column; align-items: flex-start; gap: 0.15rem;
  cursor: pointer;
  text-align: left;
}
.wl-segment-btn strong { font-size: 0.85rem; font-weight: var(--weight-bold); color: var(--text-primary); }
.wl-segment-btn small { font-size: 0.72rem; color: var(--text-muted); }
.wl-segment-btn.is-active {
  border-color: var(--brand-primary);
  background: color-mix(in oklab, var(--brand-primary) 12%, transparent);
}
.wl-segment-btn.is-active strong,
.wl-segment-btn.is-active small { color: #0A0A0A; }

/* Search inline */
.wl-form-search input {
  width: 100%;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  color: var(--text-primary);
  padding: 0.6rem 0.85rem;
  font-size: 0.88rem;
  outline: none;
}
.wl-search-results {
  display: flex; flex-direction: column; gap: 0.4rem;
  margin-top: 0.3rem;
  max-height: 250px; overflow-y: auto;
}
.wl-search-hint {
  font-size: 0.82rem;
  color: var(--text-muted);
  padding: 0.5rem 0.2rem;
}
.wl-search-row {
  display: flex; align-items: center; gap: 0.6rem;
  width: 100%;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0.55rem;
  color: var(--text-primary);
  cursor: pointer;
  text-align: left;
}
.wl-search-row[disabled] { opacity: 0.6; cursor: default; }
.wl-search-row img {
  width: 36px; height: 52px;
  border-radius: 8px;
  object-fit: cover;
  flex: 0 0 auto;
  background: var(--panel-strong);
}
.wl-search-poster.placeholder, .wl-collab-avatar.placeholder, .wl-selected-placeholder {
  background: linear-gradient(135deg, color-mix(in oklab, var(--brand-primary) 25%, transparent), var(--panel-strong));
}
.wl-search-poster.placeholder { width: 36px; height: 52px; border-radius: 8px; flex: 0 0 auto; }
.wl-collab-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  object-fit: cover;
  flex: 0 0 auto;
}
.wl-search-meta { min-width: 0; flex: 1; display: flex; flex-direction: column; gap: 0.1rem; }
.wl-search-meta strong { font-size: 0.86rem; font-weight: var(--weight-bold); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wl-search-meta small { font-size: 0.72rem; color: var(--text-muted); }
.wl-search-add {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--brand-primary);
  color: #fff;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 1.05rem; font-weight: var(--weight-bold);
  flex: 0 0 auto;
}
.wl-search-already { font-size: 0.7rem; color: var(--text-muted); }

/* Selected items */
.wl-selected-titles, .wl-selected-chips {
  display: flex; flex-wrap: wrap; gap: 0.4rem;
  margin-top: 0.3rem;
}
.wl-selected-titles { flex-direction: column; }
.wl-selected-card {
  display: flex; align-items: center; gap: 0.6rem;
  background: var(--panel-strong);
  border-radius: var(--radius-md);
  padding: 0.45rem 0.55rem;
}
.wl-selected-card img, .wl-selected-placeholder {
  width: 36px; height: 52px;
  border-radius: 8px;
  object-fit: cover;
  flex: 0 0 auto;
}
.wl-selected-meta { min-width: 0; flex: 1; display: flex; flex-direction: column; gap: 0.1rem; }
.wl-selected-meta strong { font-size: 0.84rem; font-weight: var(--weight-bold); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wl-selected-meta small { font-size: 0.7rem; color: var(--text-muted); }
.wl-selected-remove {
  appearance: none; background: none; border: 0;
  color: var(--text-muted);
  font-size: 1.3rem; line-height: 1;
  cursor: pointer;
}

.wl-collab-chip {
  display: inline-flex; align-items: center; gap: 0.35rem;
  padding: 0.3rem 0.65rem;
  background: var(--panel-strong);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  font-size: 0.78rem;
  color: var(--text-primary);
}
.wl-collab-chip-remove {
  appearance: none; background: none; border: 0;
  color: var(--text-muted);
  font-size: 1rem; line-height: 1;
  cursor: pointer; padding: 0;
}

/* Buttons */
.wl-btn-primary, .wl-btn-secondary, .wl-btn-danger {
  appearance: none;
  padding: 0.7rem 1rem;
  border-radius: var(--radius-pill);
  font-size: 0.92rem; font-weight: var(--weight-bold);
  cursor: pointer;
  font-family: inherit;
}
.wl-btn-primary {
  background: var(--brand-primary);
  color: #fff;
  border: 0;
}
.wl-btn-primary:disabled { opacity: 0.55; cursor: default; }
.wl-btn-secondary {
  background: var(--panel);
  color: var(--text-primary);
  border: 1px solid var(--border);
}
.wl-btn-danger {
  background: transparent;
  color: var(--danger, #ef4444);
  border: 1px solid color-mix(in oklab, var(--danger, #ef4444) 36%, transparent);
}
.wl-btn-danger:hover { background: color-mix(in oklab, var(--danger, #ef4444) 8%, transparent); }

/* Body lock quando sheet aperto */
body.wl-sheet-open { overflow: hidden; }
