/* ============================================================
   FPLMan redesign — Squad Builder per-screen styles
   Layers on top of redesign.css. Holds the interactive states
   the client-side pitch / bench / players engine needs (swap
   targets, selection, status dots, the action popover) plus the
   sync card, flash and Pro-gate chrome — the static component
   classes all live in redesign.css.
   ============================================================ */

/* sync card — Save/Sync are separate forms, let their children flow into the flex row */
.synccard form { display: contents; }
.synccard > * { min-width: 0; }
.title-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: flex-end; min-width: 0; }
.fx-mobile-label { display: none; }
.grid > .card { min-width: 0; }

/* flash + onboarding banners */
.flashwrap { margin: 0 2px 14px; }
.flash {
  padding: 11px 16px; border-radius: var(--radius-md);
  font-size: 13.5px; font-weight: 600;
}
.flash a { color: inherit; text-decoration: underline; font-weight: 700; }
.flash-success { background: var(--green-tint); color: var(--green-deep); }
.flash-error   { background: var(--red-tint);   color: #b73a4d; }
.info-banner {
  display: flex; align-items: center; gap: 10px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md);
  padding: 13px 18px; margin: 0 2px 14px; font-size: 13.5px; color: var(--text-2);
  box-shadow: var(--shadow-sm);
}
.info-banner a { color: var(--green-deep); font-weight: 700; }

/* injury chip in the title row */
.injury-chip {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11.5px; font-weight: 700; padding: 5px 10px; border-radius: 999px;
  background: var(--red-tint); color: #b73a4d;
}
.injury-chip.doubtful { background: var(--orange-tint); color: #9a6312; }

/* tab panes (server renders every panel, JS toggles the active one) */
.tabpane { display: none; }
.tabpane.active { display: block; }

/* ============ pitch tokens (built client-side) ============ */
.player .token-status-dot {
  position: absolute; top: -2px; right: 16px;
  width: 10px; height: 10px; border-radius: 50%; border: 2px solid #fff; z-index: 6;
}
.player .token-status-dot.injured  { background: var(--red); }
.player .token-status-dot.doubtful { background: var(--amber); }
.player.selected    .nameplate { background: var(--amber); color: #3a2400; }
.player.swap-target .nameplate { background: var(--green); color: #fff; }
.player.swap-target { animation: swap-pulse 1.2s ease-in-out infinite; }
.player.swap-disabled { opacity: .32; pointer-events: none; }
.swap-mode-overlay {
  position: absolute; inset: 0; z-index: 1; pointer-events: none;
  background: rgba(20,23,28,.06); border-radius: var(--radius);
}

/* ============ bench cards (built client-side) ============ */
.bench-card { position: relative; }
.bench-card.selected    { outline: 2px solid var(--amber); outline-offset: 2px; border-color: var(--amber); }
.bench-card.swap-target  { border-color: var(--green); background: var(--green-tint); animation: swap-pulse 1.2s ease-in-out infinite; }
.bench-card.swap-disabled { opacity: .32; pointer-events: none; }
.bench-card .bench-status-dot {
  position: absolute; top: 7px; right: 7px;
  width: 8px; height: 8px; border-radius: 50%; border: 1.5px solid #fff;
}
.bench-card .bench-status-dot.injured  { background: var(--red); }
.bench-card .bench-status-dot.doubtful { background: var(--amber); }
.signin-prompt { flex: 1; text-align: center; font-size: 13px; color: var(--text-3); padding: 10px; }
.signin-prompt a { color: var(--green-deep); font-weight: 700; }

/* ============ players list (built client-side) ============ */
.prow-lead { display: flex; flex-direction: column; align-items: center; gap: 5px; min-width: 0; }
.prow.disabled        { opacity: .4; pointer-events: none; }
.prow.swap-target     { background: var(--green-tint); box-shadow: inset 3px 0 0 var(--green); }
.prow.transfer-target { background: var(--blue-tint);  box-shadow: inset 3px 0 0 var(--blue); }
.prow .nm { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.prow .pnews { font-size: 10.5px; color: #b1521b; line-height: 1.2; margin-top: 2px; }
.sdot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; flex-shrink: 0; }
.sdot.available   { background: var(--green); }
.sdot.doubtful    { background: var(--amber); }
.sdot.injured     { background: var(--red); }
.sdot.unavailable { background: var(--text-4); }
.players-count { display: flex; gap: 16px; margin: 0 2px 14px; font-size: 13.5px; color: var(--text-2); }
.players-count b { color: var(--green-deep); font-family: var(--mono); }
.list-empty { padding: 30px; text-align: center; color: var(--text-3); font-size: 13.5px; }

/* differentials already in the squad get the owned cue */
.diffrow.owned { background: var(--green-tint); }
.diffrow.owned:hover { background: var(--green-tint-2); }

/* ============ fixtures panel — stack double-GW chips ============ */
.fx-gw { display: flex; flex-direction: column; align-items: center; gap: 3px; }

/* podcast source pills */
.pod-srcs { display: flex; flex-wrap: wrap; gap: 6px 14px; min-width: 0; }
.pod-srcs .pod-src { transition: color .12s; }
.pod-srcs a.pod-src:hover { color: var(--green-deep); }
/* Scroll cues only appear on the side where more tabs are available. */
.tabbar-wrap { position: relative; min-width: 0; }
.tabbar-wrap::before,
.tabbar-wrap::after {
  content: ""; position: absolute; z-index: 2; top: 0; bottom: 1px; width: 24px;
  pointer-events: none; opacity: 0; transition: opacity .15s;
}
.tabbar-wrap::before { left: 0; background: linear-gradient(to right, var(--surface), transparent); }
.tabbar-wrap::after { right: 0; background: linear-gradient(to left, var(--surface), transparent); }
.tabbar-wrap.can-scroll-left::before,
.tabbar-wrap.can-scroll-right::after { opacity: 1; }

/* ============ Pro gate ============ */
.locked-tab {
  display: flex; flex-direction: column; align-items: center; gap: 11px;
  padding: 36px 22px; text-align: center;
  border: 1px dashed var(--border-2); border-radius: var(--radius-md); background: var(--surface-2);
}
.locked-tab svg { color: var(--text-3); }
.locked-tab .lt-title { font-weight: 700; color: var(--text-2); font-size: 14.5px; }
.locked-tab .lt-sub { font-size: 13px; color: var(--text-3); max-width: 40ch; }

/* ============ action popover ============ */
.action-popover {
  position: fixed; z-index: 1000; display: flex; flex-direction: column; gap: 4px;
  background: var(--surface); border: 1px solid var(--border-2); border-radius: var(--radius-md);
  padding: 6px; box-shadow: var(--shadow-pop); min-width: 170px;
}
.action-popover-btn {
  padding: 9px 14px; border-radius: 9px; font-size: 13.5px; font-weight: 600;
  color: var(--text); text-align: left; transition: background .12s;
}
.action-popover-btn:hover:not(:disabled) { background: var(--surface-3); }
.action-popover-btn:disabled { opacity: .4; cursor: not-allowed; }
.action-popover-btn.danger { color: #b73a4d; }
.action-popover-btn.danger:hover { background: var(--red-tint); }

@keyframes swap-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(21,160,106,.4); }
  50%      { box-shadow: 0 0 0 6px rgba(21,160,106,0); }
}

/* ============ data freshness ============ */
.data-freshness { margin: 18px 4px 0; font-size: 12px; color: var(--text-4); font-family: var(--mono); }

/* ============ responsive ============ */
@media (max-width: 767px) {
  .titlerow { align-items: stretch; flex-direction: column; }
  .title-actions { justify-content: flex-start; }
  .injury-chip { white-space: normal; }

  .synccard { align-items: stretch; flex-direction: column; gap: 11px; padding: 11px 13px; }
  .synccard .sync-id-form { display: grid; gap: 10px; width: 100%; }
  .synccard .sync-pull-form { display: block; width: 100%; }
  .synccard .sync-field { align-items: stretch; flex-direction: column; gap: 6px; width: 100%; }
  .synccard .sync-input,
  .synccard .btn { width: 100%; }
  .synccard .sync-status { justify-content: center; white-space: normal; }
  .sync-help, .sync-sep { display: none; }

  .pitch-row { width: 100%; }
  .pitch-row .player {
    flex: 1 1 0;
    min-width: 0;
    width: auto;
  }
  .pitch-row .nameplate {
    max-width: 100%;
    min-width: 0;
    width: 100%;
  }
  .pitch-row .nameplate .nm,
  .bench-card .bnm {
    display: -webkit-box;
    overflow: hidden;
    overflow-wrap: anywhere;
    white-space: normal;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
  }

  .bench-grid { gap: 7px; min-width: 0; }
  .bench-card { min-width: 0; padding: 9px 4px 8px; gap: 6px; border-radius: var(--radius-sm); }
  .bench-card .bnm { font-size: 11.5px; }
  .bench-xp { font-size: 11.5px; width: 38px; }
  .actions { gap: 8px; margin-top: 14px; }

  .tabbar {
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .tabbar::-webkit-scrollbar { display: none; }
  .tab { padding: 12px 11px; font-size: 13.5px; }
  .panel { padding: 14px 13px 16px; }
  .panel-intro { font-size: 13px; margin-bottom: 14px; }

  .fx-head, .fx-row { grid-template-columns: minmax(0,1fr) repeat(3,42px) 38px; gap: 6px; padding: 8px 4px; }
  .fchip { width: 42px; font-size: 9.5px; padding: 4px 0; }
  .fx-name { font-size: 13px; }
  .fx-player { gap: 7px; }
  .fx-xp { font-size: 13.5px; }

  .prow { grid-template-columns: 42px minmax(0, 1fr) auto; gap: 9px; padding: 9px 4px; }
  .pinfo .nm { font-size: 13.5px; }
  .pnums { gap: 9px; }
  .filterrow { gap: 9px; }
  .seg { padding: 8px 0; font-size: 13px; }

  .fx-name,
  .pinfo .nm,
  .swap-mid .nm,
  .cap-mid .nm,
  .diff-mid .nm,
  .pod-id .nm {
    overflow-wrap: anywhere;
    white-space: normal;
  }
  .swapline { grid-template-columns: 32px minmax(0, 1fr) auto; gap: 9px; }
  .swap-mid .nm { font-size: 13.5px; }
  .swap-mid .nm,
  .cap-mid .nm,
  .diff-mid .nm { display: block; }
  .caprow { grid-template-columns: 30px minmax(0, 1fr) auto; gap: 10px; padding: 12px 13px; }
  .cap-mid .nm { font-size: 14.5px; }
  .cap-xp .big { font-size: 21px; }
  .diffrow { grid-template-columns: 34px minmax(0, 1fr) auto; gap: 9px; }
  .pod-head,
  .pod-foot { align-items: flex-start; flex-wrap: wrap; gap: 8px; }
  .pod-body { font-size: 13px; }
}
@media (max-width: 480px) {
  .pitch-row .player .kit { height: 28px; width: 30px; }
  .pitch-row .nameplate { padding: 3px 2px; }
  .pitch-row .nameplate .nm { font-size: 8.5px; line-height: 1.05; }
  .player .token-status-dot { right: 7px; }

  .bench-grid { gap: 4px; }
  .bench-card { padding: 8px 2px; }
  .bench-card .kit { height: 27px; width: 29px; }
  .bench-card .bnm { font-size: 10.5px; }
  .bench-card .pos { padding-inline: 4px; }

  .fx-head { display: none; }
  .fx-row {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 8px 4px;
    margin-bottom: 10px;
    padding: 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-sm);
  }
  .fx-row:hover { background: var(--surface); }
  .fx-player { grid-column: 1 / -1; }
  .fx-name { font-size: 13px; }
  .fx-gw,
  .fx-xp {
    align-items: center;
    display: flex;
    flex-direction: column;
    gap: 4px;
    justify-content: flex-start;
    text-align: center;
  }
  .fx-mobile-label {
    color: var(--text-3);
    display: block;
    font-family: var(--mono);
    font-size: 9px;
    font-weight: 700;
    letter-spacing: .04em;
  }
  .fchip { max-width: 100%; width: 42px; }

  .prow { grid-template-columns: 38px minmax(0, 1fr) auto; }
  .pnums .sec { display: none; }

  .move-head { align-items: flex-start; gap: 8px; }
  .move-head .t { overflow-wrap: anywhere; }
  .move-body { padding-inline: 9px; }
}
@media (prefers-reduced-motion: reduce) {
  .player.swap-target, .bench-card.swap-target { animation: none !important; }
}
