/* Fast Player — web portal (Add Playlist + Manage). Builds on site.css; load after it.
 *
 * Every class/state below that the portal scripts read or toggle is load-bearing:
 *   app.js      .form-step(.active/.slide-in) .step-item(.active/.done)[data-step]
 *               .type-card(.selected)[data-type] #step2Next[disabled] .spinner (inline-block/none)
 *               .error-box (block/none) .pin-fields (block/none) [data-role="paired-content"]
 *   manage.js   .playlist-card .glass-card .playlist-card-header .playlist-name .playlist-actions
 *               .edit-btn .delete-btn .type-badge .xtream-badge .m3u-badge .stalker-badge
 *               .protected-badge .cred-grid .cred-row .cred-label .cred-val(.locked)
 *               .modal-overlay (flex/none) .add-step (block/none) .toast(.show) #addTypeStep .type-card
 *   pairing.js  #notPairedState (block/none) [data-role="not-paired-message"] spinner/label ('' / none)
 *   app.js + manage.js toggle .nav-links.nav-open / .nav-toggle.is-open (styled in site.css).
 * Visibility of those elements is driven by inline style.display from the scripts, so nothing here
 * sets !important display on them; the defaults below are what '' falls back to. */

/* ── Page shell ───────────────────────────────────────────────────────────── */
.site-header { border-bottom-color: var(--line); background: rgba(7, 8, 10, 0.82); } /* no scroll script here */

.portal {
    /* No isolation/z-index here on purpose: the modals and toast live inside <main> and must be able
       to stack above the sticky header (z 50). The decorative layers below use negative z-index in the
       root stacking context, which still paints above the body/canvas background. */
    position: relative; overflow: hidden;
    padding: clamp(40px, 7vw, 88px) 0 clamp(72px, 9vw, 128px);
    min-height: calc(100vh - 68px);
}
.portal::before { /* soft green bloom behind the heading, same family as the homepage hero glow */
    content: ""; position: absolute; z-index: -1; left: 50%; top: -260px; width: min(1100px, 140vw); height: 640px;
    transform: translateX(-50%); border-radius: 50%; pointer-events: none;
    background: radial-gradient(closest-side, rgba(54, 226, 126, 0.13), rgba(54, 226, 126, 0.03) 55%, transparent 75%);
}
.portal::after { /* faint dot grid that fades out downwards */
    content: ""; position: absolute; inset: 0; z-index: -2; pointer-events: none;
    background-image: radial-gradient(rgba(255, 255, 255, 0.05) 1px, transparent 1px);
    background-size: 28px 28px;
    -webkit-mask-image: linear-gradient(180deg, #000 0%, transparent 60%); mask-image: linear-gradient(180deg, #000 0%, transparent 60%);
}
.portal-head {
    max-width: 680px; margin: 0 auto clamp(32px, 5vw, 52px); text-align: center;
    display: grid; gap: 16px; justify-items: center;
}
.portal-title { font-size: clamp(38px, 5.6vw, 64px); line-height: 1.02; letter-spacing: -0.035em; font-weight: 800; margin: 0; }
.portal-head .lead { max-width: 520px; }

/* Content columns. The wizard / playlist list read best narrow; the not-paired choice gets two columns. */
.form-container { max-width: 720px; margin: 0 auto; }
.manage-col { max-width: 760px; margin: 0 auto; }

/* ── Cards ────────────────────────────────────────────────────────────────── */
/* .glass-card is still emitted by manage.js on every playlist card, so it keeps a real style. */
.glass-card {
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.055), rgba(255, 255, 255, 0.025));
    border: 1px solid var(--line); border-radius: var(--radius-l);
}
.form-card { padding: clamp(24px, 3.6vw, 44px); box-shadow: 0 40px 90px -50px rgba(0, 0, 0, 0.9); }
.form-card .icon-tile { margin-bottom: 20px; }
.form-card h2 { font-size: clamp(22px, 2.4vw, 27px); line-height: 1.2; letter-spacing: -0.02em; font-weight: 750; margin: 0 0 8px; }
.card p.form-card-desc, .form-card-desc { color: var(--muted); font-size: 15.5px; line-height: 1.6; margin: 0 0 26px; }
.form-card-desc strong { color: var(--text); font-weight: 650; }

/* ── Not-paired state: Device ID + PIN, or the secure link ────────────────── */
.connect-grid {
    display: grid; grid-template-columns: minmax(0, 1.15fr) auto minmax(0, 1fr);
    gap: clamp(20px, 3vw, 32px); align-items: stretch; max-width: 1040px; margin: 0 auto;
}
.connect-link-card { display: flex; flex-direction: column; }
.connect-link-card .form-card-desc { margin-bottom: 0; }

.or-divider {
    display: flex; flex-direction: column; align-items: center; gap: 14px;
    color: var(--faint); font-size: 12px; font-weight: 700; letter-spacing: 0.16em; text-transform: uppercase;
}
.or-divider::before, .or-divider::after {
    content: ""; flex: 1; width: 1px; min-height: 24px;
    background: linear-gradient(180deg, transparent, var(--line-strong), transparent);
}
.portal-download { margin: 0; color: var(--faint); font-size: 15px; line-height: 1.6; }
.connect-link-card .portal-download { margin-top: auto; padding-top: 28px; }
.connect-link-card .portal-download::before { content: ""; display: block; height: 1px; background: var(--line); margin-bottom: 20px; }
.portal-download a { color: var(--accent); font-weight: 650; white-space: nowrap; }
.portal-download a:hover { text-decoration: underline; text-underline-offset: 3px; }

@media (max-width: 900px) {
    .connect-grid { grid-template-columns: minmax(0, 1fr); max-width: 620px; gap: 18px; }
    .or-divider { flex-direction: row; }
    .or-divider::before, .or-divider::after { width: auto; height: 1px; min-height: 0; background: linear-gradient(90deg, transparent, var(--line-strong), transparent); }
}

/* ── Step indicator (app.js toggles .active/.done on .step-item) ──────────── */
.step-indicator { display: flex; align-items: center; justify-content: center; gap: 14px; margin: 0 auto 28px; }
.step-item { display: flex; align-items: center; gap: 10px; color: var(--faint); font-size: 14px; font-weight: 600; transition: color .2s ease; }
.step-circle {
    position: relative; width: 30px; height: 30px; border-radius: 50%; flex-shrink: 0;
    display: grid; place-items: center; font-size: 13px; font-weight: 700;
    border: 1px solid var(--line-strong); background: var(--surface); color: var(--muted);
    transition: background .2s ease, border-color .2s ease, color .2s ease;
}
.step-item.active { color: var(--text); }
.step-item.active .step-circle { background: #fff; border-color: #fff; color: #050607; }
.step-item.done { color: var(--muted); }
.step-item.done .step-circle { background: var(--accent-soft); border-color: rgba(54, 226, 126, 0.45); color: transparent; }
.step-item.done .step-circle::before {
    content: "\2713"; position: absolute; inset: 0; display: grid; place-items: center; color: var(--accent); font-size: 14px;
}
.step-line { width: 56px; height: 1px; background: var(--line-strong); flex-shrink: 1; }

/* ── Wizard steps (app.js swaps .active / .slide-in) ──────────────────────── */
.form-step { display: none; }
.form-step.active { display: block; }
.form-step.slide-in { animation: fp-step-in .42s cubic-bezier(.2, .7, .2, 1); }
@keyframes fp-step-in { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: none; } }

/* ── Playlist type cards (.selected is toggled by app.js and manage.js) ───── */
.type-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.type-card {
    -webkit-appearance: none; appearance: none; width: 100%; margin: 0; font: inherit; color: var(--text); text-align: left;
    position: relative; display: flex; flex-direction: column; align-items: flex-start; gap: 14px;
    padding: 18px 18px 20px; border-radius: 18px; cursor: pointer;
    border: 1px solid var(--line-strong); background: var(--surface);
    transition: background .18s ease, border-color .18s ease, box-shadow .18s ease, transform .18s ease;
}
.type-card:hover { background: var(--surface-strong); border-color: rgba(255, 255, 255, 0.26); }
.type-card:active { transform: scale(0.99); }
.type-card:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.type-card.selected {
    border-color: var(--accent);
    background: linear-gradient(180deg, rgba(54, 226, 126, 0.15), rgba(54, 226, 126, 0.05));
    box-shadow: inset 0 0 0 1px var(--accent), 0 22px 44px -26px rgba(54, 226, 126, 0.55);
}
.type-icon {
    width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; flex-shrink: 0;
    background: var(--surface-strong); border: 1px solid var(--line); color: var(--text);
    transition: background .18s ease, color .18s ease, border-color .18s ease;
}
.type-icon svg { width: 20px; height: 20px; }
.type-card.selected .type-icon { background: var(--accent-soft); border-color: rgba(54, 226, 126, 0.32); color: var(--accent); }
.type-info { display: grid; gap: 4px; min-width: 0; padding-right: 18px; }
.type-title { font-size: 16px; font-weight: 700; letter-spacing: -0.01em; line-height: 1.3; }
.type-sub { font-size: 13.5px; color: var(--muted); line-height: 1.45; }
.type-check {
    position: absolute; top: 14px; right: 14px; width: 22px; height: 22px; border-radius: 50%;
    display: grid; place-items: center; background: var(--accent); color: var(--accent-ink);
    opacity: 0; transform: scale(0.6); transition: opacity .18s ease, transform .18s ease;
}
.type-check svg { width: 14px; height: 14px; }
.type-card.selected .type-check { opacity: 1; transform: none; }

/* Narrow column (phones, and inside the Manage modal): one row per type, icon left. */
@media (max-width: 640px) {
    .type-grid { grid-template-columns: minmax(0, 1fr); }
    .type-card { flex-direction: row; align-items: center; padding: 16px 48px 16px 16px; }
    .type-check { top: 50%; margin-top: -11px; }
    .type-info { padding-right: 0; }
}
.modal-card .type-grid { grid-template-columns: minmax(0, 1fr); }
.modal-card .type-card { flex-direction: row; align-items: center; padding: 16px 48px 16px 16px; }
.modal-card .type-check { top: 50%; margin-top: -11px; }
.modal-card .type-info { padding-right: 0; }

/* ── Fields ───────────────────────────────────────────────────────────────── */
.fields { display: grid; gap: 16px; }
.fields-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.field-group { display: grid; gap: 8px; min-width: 0; }
.field-group label { font-size: 14px; font-weight: 600; color: var(--text); }
.field-optional { font-weight: 500; color: var(--faint); }
.field-input { width: 100%; min-width: 0; }
.mono-input { font-family: var(--mono); text-transform: uppercase; letter-spacing: 0.04em; }
.mono-input::placeholder { text-transform: none; }
.pin-input { font-family: var(--mono); }
.pin-input:not(:placeholder-shown) { letter-spacing: 0.3em; }
@media (max-width: 560px) { .fields-row { grid-template-columns: minmax(0, 1fr); } }

/* PIN-protect switch. The real checkbox stays in the tab order (visually hidden, not display:none). */
.protect-toggle { margin-top: 22px; padding: 16px 18px; border-radius: 16px; background: var(--surface); border: 1px solid var(--line); }
.toggle-label { position: relative; display: flex; align-items: center; gap: 14px; cursor: pointer; -webkit-user-select: none; user-select: none; }
.toggle-check { position: absolute; left: 0; top: 50%; width: 1px; height: 1px; margin: 0; opacity: 0; pointer-events: none; }
.toggle-slider {
    position: relative; flex-shrink: 0; width: 46px; height: 28px; border-radius: 999px;
    background: rgba(255, 255, 255, 0.16); transition: background .2s ease;
}
.toggle-slider::after {
    content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%;
    background: #fff; box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4); transition: transform .2s ease;
}
.toggle-check:checked + .toggle-slider { background: var(--accent); }
.toggle-check:checked + .toggle-slider::after { transform: translateX(18px); }
.toggle-check:focus-visible + .toggle-slider { outline: 2px solid var(--accent); outline-offset: 3px; }
.toggle-text { display: inline-flex; align-items: center; gap: 8px; font-size: 15px; font-weight: 600; color: var(--text); }
.toggle-text svg { width: 16px; height: 16px; color: var(--muted); flex-shrink: 0; }
.protect-toggle .toggle-hint { margin: 8px 0 0 60px; font-size: 13.5px; line-height: 1.5; color: var(--muted); }
.pin-fields { margin-top: 14px; animation: fp-fade-in .25s ease; }
@media (max-width: 420px) { .protect-toggle .toggle-hint { margin-left: 0; } }

/* ── Messages ─────────────────────────────────────────────────────────────── */
.error-box {
    margin-top: 16px; padding: 12px 16px; border-radius: 14px; font-size: 14.5px; line-height: 1.5;
    border: 1px solid rgba(255, 93, 93, 0.38); background: rgba(255, 93, 93, 0.1); color: #ffd0d0;
}

/* ── Actions + loading ────────────────────────────────────────────────────── */
.form-actions { display: flex; flex-wrap: wrap; gap: 12px; justify-content: flex-end; margin-top: 28px; }
.form-actions .btn { min-width: 140px; }
.form-actions .btn-back { margin-right: auto; }
.btn svg.btn-icon { width: 18px; height: 18px; }
.btn-block { width: 100%; }
.btn-danger { background: rgba(255, 93, 93, 0.14); border-color: rgba(255, 93, 93, 0.45); color: #ff9a9a; }
.btn-danger:hover { background: rgba(255, 93, 93, 0.22); color: #ffd0d0; }
@media (max-width: 560px) {
    .form-actions .btn { flex: 1 1 0; min-width: 0; padding: 0 16px; }
    .form-actions .btn-back { margin-right: 0; }
}

/* Spinner: app.js/manage.js set display inline-block|none; pairing.js sets ''|none (falls back to this). */
.spinner {
    display: inline-block; flex-shrink: 0; width: 18px; height: 18px; border-radius: 50%; vertical-align: middle;
    border: 2px solid currentColor; border-right-color: transparent; opacity: 0.85;
    animation: fp-spin .7s linear infinite;
}
/* A button that is disabled *because it is saving* (its spinner is showing) stays readable;
   a plain disabled button (e.g. Continue before a type is picked) keeps site.css's dimmed look. */
.btn[disabled]:has(.spinner:not([style*="none"])) { opacity: 0.8; cursor: progress; }
@keyframes fp-spin { to { transform: rotate(360deg); } }
@keyframes fp-fade-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ── Success step ─────────────────────────────────────────────────────────── */
.success-screen { text-align: center; }
.success-icon {
    width: 76px; height: 76px; border-radius: 50%; margin: 0 auto 22px; display: grid; place-items: center;
    background: var(--accent-soft); border: 1px solid rgba(54, 226, 126, 0.38); color: var(--accent);
    box-shadow: 0 0 60px -10px rgba(54, 226, 126, 0.45);
    animation: fp-pop .5s cubic-bezier(.175, .885, .32, 1.275) both;
}
.success-icon svg { width: 34px; height: 34px; }
.success-screen h2 { font-size: clamp(26px, 3vw, 32px); }
.card.success-screen > p { max-width: 480px; margin: 0 auto 26px; color: var(--muted); font-size: 15.5px; line-height: 1.65; }
.success-steps {
    display: grid; gap: 12px; text-align: left; padding: 18px 20px; border-radius: 16px;
    background: var(--surface); border: 1px solid var(--line);
}
.success-step { display: flex; align-items: center; gap: 14px; color: var(--muted); font-size: 15px; }
.success-step strong { color: var(--text); font-weight: 650; }
.success-step-num {
    width: 28px; height: 28px; border-radius: 50%; flex-shrink: 0; display: grid; place-items: center;
    background: var(--surface-strong); border: 1px solid var(--line-strong); color: var(--text); font-size: 13px; font-weight: 700;
}
.success-screen .form-actions { justify-content: center; margin-top: 30px; }
@keyframes fp-pop { from { transform: scale(0.4); opacity: 0; } to { transform: none; opacity: 1; } }

/* ── Manage: header bar ───────────────────────────────────────────────────── */
.manage-header {
    display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap;
    padding: 16px 18px; margin-bottom: 16px; border-radius: 20px; background: var(--surface); border: 1px solid var(--line);
}
.manage-device { display: flex; align-items: center; gap: 14px; min-width: 0; flex: 1 1 260px; }
.manage-device .icon-tile { margin: 0; flex-shrink: 0; }
.manage-device-text { min-width: 0; }
.manage-mac { font-size: 13.5px; color: var(--muted); font-weight: 600; line-height: 1.4; }
.manage-mac #displayMac { display: inline-block; font-family: var(--mono); font-size: 15px; color: var(--text); letter-spacing: 0.04em; overflow-wrap: anywhere; }
.playlist-count { font-size: 13px; color: var(--faint); margin-top: 2px; }
@media (max-width: 480px) { .manage-header .btn { width: 100%; } }

/* ── Manage: playlist cards (markup is generated by manage.js) ────────────── */
#playlistList { display: grid; gap: 12px; }
.playlist-card { padding: 18px 20px 20px; border-radius: 20px; transition: border-color .18s ease, background .18s ease; }
.playlist-card:hover { border-color: var(--line-strong); }
.playlist-card-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.playlist-card-header > div:first-child { flex: 1; min-width: 0; }
.playlist-name { order: -1; flex-basis: 100%; font-size: 17px; font-weight: 700; letter-spacing: -0.01em; line-height: 1.35; overflow-wrap: anywhere; }
.playlist-actions { display: flex; gap: 8px; flex-shrink: 0; }
.edit-btn, .delete-btn {
    width: 40px; height: 40px; padding: 0; border-radius: 12px; cursor: pointer; display: grid; place-items: center;
    border: 1px solid var(--line-strong); background: var(--surface); color: var(--muted);
    transition: background .15s ease, color .15s ease, border-color .15s ease;
}
.edit-btn svg, .delete-btn svg { width: 17px; height: 17px; }
.edit-btn:hover { background: var(--surface-strong); color: var(--text); }
.delete-btn:hover { background: rgba(255, 93, 93, 0.1); border-color: rgba(255, 93, 93, 0.45); color: var(--danger); }
.edit-btn:focus-visible, .delete-btn:focus-visible { outline-offset: 2px; }

.type-badge, .protected-badge {
    display: inline-flex; align-items: center; gap: 5px; padding: 4px 10px; border-radius: 999px;
    font-size: 12px; font-weight: 650; line-height: 1.3; border: 1px solid var(--line-strong); background: var(--surface); color: var(--muted);
}
.xtream-badge, .m3u-badge, .stalker-badge { color: var(--text); }
.protected-badge { background: var(--accent-soft); border-color: rgba(54, 226, 126, 0.32); color: #bff5d4; }

.cred-grid { display: grid; gap: 2px; padding: 10px 14px; border-radius: 14px; background: rgba(0, 0, 0, 0.28); border: 1px solid var(--line); }
.cred-row { display: flex; align-items: baseline; gap: 12px; padding: 4px 0; font-size: 14px; }
.cred-label { min-width: 84px; font-size: 11.5px; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; color: var(--faint); }
.cred-val { flex: 1; min-width: 0; font-family: var(--mono); font-size: 13px; color: var(--text); word-break: break-all; }
.cred-val.locked { color: var(--faint); letter-spacing: 0.2em; }

/* Empty state (manage.js sets display block|none) */
.empty-state { text-align: center; padding: clamp(36px, 6vw, 56px) 24px; }
.empty-state .icon-tile { margin: 0 auto 18px; }
.empty-state h3 { font-size: 21px; margin: 0 0 6px; }
.card.empty-state p { margin: 0 auto 24px; max-width: 360px; }
.manage-footer { margin-top: 16px; }

/* ── Manage: modals (manage.js sets display flex|none on .modal-overlay) ──── */
.modal-overlay {
    position: fixed; inset: 0; z-index: 200; display: flex; align-items: flex-start; justify-content: center;
    padding: 24px 16px; overflow-y: auto; overscroll-behavior: contain;
    background: rgba(3, 4, 5, 0.74); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
}
.modal-card {
    width: 100%; max-width: 460px; margin: auto 0; position: relative;
    padding: clamp(22px, 3vw, 32px); border-radius: var(--radius-l);
    background: linear-gradient(180deg, #121417, #0c0e10); border: 1px solid var(--line-strong); box-shadow: var(--shadow);
    animation: fp-step-in .25s ease;
}
.modal-card-wide { max-width: 560px; }
.modal-card-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.modal-card h3 { font-size: 21px; font-weight: 750; letter-spacing: -0.015em; line-height: 1.25; margin: 0; }
.modal-desc { color: var(--muted); font-size: 15px; line-height: 1.6; margin: 10px 0 0; }
.modal-desc strong { color: var(--text); overflow-wrap: anywhere; }
.modal-card-header + .modal-desc { margin-top: 0; margin-bottom: 20px; }
.modal-close-btn {
    width: 38px; height: 38px; padding: 0; border-radius: 12px; flex-shrink: 0; cursor: pointer; display: grid; place-items: center;
    border: 1px solid var(--line-strong); background: var(--surface); color: var(--muted); transition: background .15s ease, color .15s ease;
}
.modal-close-btn svg { width: 16px; height: 16px; }
.modal-close-btn:hover { background: var(--surface-strong); color: var(--text); }
.add-step { animation: fp-fade-in .2s ease; }
.add-step > .modal-desc:first-child { margin: 0 0 18px; }

/* ── Toast (manage.js adds/removes .show) ─────────────────────────────────── */
.toast {
    position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom, 0px)); z-index: 300;
    max-width: calc(100vw - 32px); padding: 12px 20px; border-radius: 999px;
    background: #fff; color: #050607; font-size: 14.5px; font-weight: 650; box-shadow: 0 20px 50px -12px rgba(0, 0, 0, 0.8);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    opacity: 0; transform: translate(-50%, 12px); pointer-events: none; transition: opacity .25s ease, transform .25s ease;
}
.toast:empty { padding: 0; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
