/* style.css — True Shuffle Web — Spotify dark theme, mobile-first */

/* ── Variables ──────────────────────────────────────────────────────────────── */
:root {
    --bg:          #121212;
    --surface:     #181818;
    --surface-2:   #282828;
    --surface-3:   #333333;
    --green:       #1db954;
    --green-dark:  #158a3e;
    --text:        #ffffff;
    --text-muted:  #b3b3b3;
    --text-dim:    #6a6a6a;
    --danger:      #e74c3c;
    --radius:      12px;
    --radius-lg:   20px;
    --radius-pill: 999px;
    --transition:  0.2s ease;
    --max-w:       480px;
}

/* ── Reset & Base ────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
    height: 100%;
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    font-size: 16px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--green); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── App Container ───────────────────────────────────────────────────────────── */
.app {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* ── Screens ─────────────────────────────────────────────────────────────────── */
.screen {
    display: none;
    flex-direction: column;
    width: 100%;
    max-width: var(--max-w);
    min-height: 100vh;
    padding: 24px 20px 40px;
}
.screen.active { display: flex; }

/* ── Logo (setup screen) ─────────────────────────────────────────────────────── */
.logo-area {
    text-align: center;
    margin-bottom: 32px;
    padding-top: 40px;
}
.logo-img {
    width: 96px;
    height: 96px;
    margin-bottom: 14px;
    display: block;
    margin-left: auto;
    margin-right: auto;
    /* The SVG has its own dark bg — a subtle glow ties it to the page */
    filter: drop-shadow(0 6px 24px rgba(139, 92, 246, 0.45));
    border-radius: 50%;
}
.logo-area h1 {
    font-size: 28px;
    font-weight: 700;
    letter-spacing: -0.5px;
    color: var(--text);
}
.logo-area p {
    color: var(--text-muted);
    font-size: 14px;
    margin-top: 4px;
}

/* ── Buy Me a Coffee ─────────────────────────────────────────────────────────── */
.bmc-footer {
    text-align: center;
    padding: 20px 0 12px;
    margin-top: auto;
}
.bmc-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: #C8A000;
    background: transparent;
    border: 1.5px solid rgba(200, 160, 0, 0.35);
    padding: 10px 24px;
    border-radius: var(--radius-pill);
    font-size: 14px;
    font-weight: 600;
    letter-spacing: 0.1px;
    text-decoration: none;
    transition: color var(--transition), background var(--transition),
                border-color var(--transition), transform var(--transition);
}
.bmc-link:hover {
    color: #FFD700;
    background: rgba(200, 160, 0, 0.1);
    border-color: rgba(200, 160, 0, 0.7);
    text-decoration: none;
    transform: translateY(-1px);
}

/* ── Cards ───────────────────────────────────────────────────────────────────── */
.card {
    background: var(--surface);
    border-radius: var(--radius-lg);
    padding: 24px;
    margin-bottom: 16px;
}

/* ── Buttons ─────────────────────────────────────────────────────────────────── */
.btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 14px 20px;
    border: none;
    border-radius: var(--radius-pill);
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    transition: opacity var(--transition), transform var(--transition);
    text-decoration: none;
}
.btn:hover  { opacity: 0.88; }
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }

.btn-primary {
    background: var(--green);
    color: #000;
}
.btn-secondary {
    background: var(--surface-2);
    color: var(--text);
}
.btn-outline {
    background: transparent;
    color: var(--text);
    border: 1px solid var(--surface-3);
}
.btn-ghost {
    background: transparent;
    color: var(--text-muted);
    font-weight: 400;
}
.btn-danger {
    background: transparent;
    color: var(--danger);
    font-weight: 400;
}
.btn-sm {
    padding: 10px 16px;
    font-size: 13px;
}
.btn + .btn { margin-top: 10px; }

/* ── Labels & Inputs ─────────────────────────────────────────────────────────── */
label {
    display: block;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 8px;
}

input[type="text"],
input[type="password"] {
    width: 100%;
    background: var(--surface-2);
    border: 1px solid var(--surface-3);
    border-radius: var(--radius);
    padding: 12px 14px;
    color: var(--text);
    font-size: 15px;
    outline: none;
    transition: border-color var(--transition);
    margin-bottom: 12px;
}
input[type="text"]:focus,
input[type="password"]:focus {
    border-color: var(--green);
}

/* ── Redirect URI box ────────────────────────────────────────────────────────── */
.redirect-uri-box {
    background: var(--surface-2);
    border: 1px solid var(--surface-3);
    border-radius: var(--radius);
    padding: 10px 14px;
    font-size: 12px;
    color: var(--text-muted);
    word-break: break-all;
    margin-bottom: 4px;
    font-family: 'SF Mono', 'Consolas', 'Courier New', monospace;
}
.redirect-uri-label {
    font-size: 11px;
    color: var(--text-dim);
    margin-bottom: 12px;
    display: block;
}

/* ── Divider ─────────────────────────────────────────────────────────────────── */
.divider {
    height: 1px;
    background: var(--surface-3);
    margin: 20px 0;
}

/* ── Setup Screen ────────────────────────────────────────────────────────────── */
#screen-setup .logo-area { padding-top: 48px; }

.setup-steps {
    color: var(--text-muted);
    font-size: 14px;
    line-height: 1.7;
    margin-bottom: 20px;
}
.setup-steps strong { color: var(--text); }

.setup-steps ol {
    padding-left: 20px;
}
.setup-steps li { margin-bottom: 4px; }

/* ── Home Screen ─────────────────────────────────────────────────────────────── */
#screen-home {
    position: relative;
}

/* Settings gear: absolute top-right */
.home-settings-btn {
    position: absolute;
    top: 44px;
    right: 0;
    z-index: 1;
}

/* Centered logo lockup */
.home-header {
    text-align: center;
    padding-top: 44px;
    margin-bottom: 16px;
}
.home-logo-img {
    width: 120px;
    height: 120px;
    display: block;
    margin: 0 auto 14px;
    border-radius: 50%;
    filter: drop-shadow(0 6px 28px rgba(139, 92, 246, 0.5));
}
.home-header h1 {
    font-size: 26px;
    font-weight: 700;
    letter-spacing: -0.3px;
}

.icon-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 22px;
    padding: 4px 8px;
    border-radius: 8px;
    line-height: 1;
    transition: color var(--transition);
}
.icon-btn:hover { color: var(--text); }

.home-hero {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 12px 0 20px;
}
.home-hero h2 {
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 10px;
    color: var(--text);
}
.home-hero p {
    color: var(--text-muted);
    font-size: 15px;
    max-width: 300px;
    margin: 0 auto;
    line-height: 1.6;
}

#home-logged-out,
#home-logged-in {
    flex-direction: column;
    width: 100%;
}

/* ── Building Screen ─────────────────────────────────────────────────────────── */
#screen-building {
    align-items: center;
    justify-content: center;
    text-align: center;
    gap: 20px;
}
.spinner {
    width: 52px;
    height: 52px;
    border: 3px solid var(--surface-2);
    border-top-color: var(--green);
    border-radius: 50%;
    animation: spin 0.85s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

#build-status {
    color: var(--text);
    font-size: 15px;
    font-weight: 500;
    max-width: 280px;
}
#build-progress {
    color: var(--text-dim);
    font-size: 13px;
    min-height: 1.4em;
}

/* ── Success Screen ──────────────────────────────────────────────────────────── */
#screen-success {
    align-items: center;
    text-align: center;
    padding-top: 60px;
}
.success-check {
    width: 72px;
    height: 72px;
    background: var(--green);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 36px;
    color: #000;
    margin-bottom: 24px;
}
#screen-success h2 {
    font-size: 26px;
    font-weight: 700;
    margin-bottom: 8px;
}
#success-track-count {
    color: var(--text-muted);
    font-size: 15px;
    margin-bottom: 6px;
}
#success-tiers {
    color: var(--green);
    font-size: 13px;
    margin-bottom: 4px;
}
#scan-progress {
    color: var(--text-dim);
    font-size: 12px;
    margin-bottom: 32px;
    display: none;
}
.success-actions {
    width: 100%;
    margin-top: 32px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
#success-link {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 14px 20px;
    background: var(--green);
    color: #000;
    border-radius: var(--radius-pill);
    font-size: 15px;
    font-weight: 700;
    text-decoration: none;
    transition: opacity var(--transition);
}
#success-link:hover { opacity: 0.88; text-decoration: none; }

/* ── Error Screen ────────────────────────────────────────────────────────────── */
#screen-error {
    align-items: center;
    text-align: center;
    padding-top: 80px;
}
.error-icon {
    width: 72px;
    height: 72px;
    background: var(--surface-2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 32px;
    margin-bottom: 24px;
}
#screen-error h2 {
    font-size: 22px;
    font-weight: 700;
    margin-bottom: 12px;
}
#error-message {
    color: var(--text-muted);
    font-size: 15px;
    max-width: 300px;
    margin-bottom: 32px;
    white-space: pre-wrap;
    line-height: 1.6;
}

/* ── Settings Overlay ────────────────────────────────────────────────────────── */
.settings-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 100;
    align-items: flex-end;
    justify-content: center;
}
.settings-overlay.open {
    display: flex;
}
.settings-panel {
    width: 100%;
    max-width: var(--max-w);
    background: var(--surface);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    max-height: 85vh;
    overflow-y: auto;
    padding-bottom: env(safe-area-inset-bottom, 16px);
    animation: slideUp 0.25s ease;
}
@keyframes slideUp {
    from { transform: translateY(60px); opacity: 0; }
    to   { transform: translateY(0);    opacity: 1; }
}
.settings-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 20px 16px;
    border-bottom: 1px solid var(--surface-3);
    position: sticky;
    top: 0;
    background: var(--surface);
    z-index: 1;
}
.settings-header h2 {
    font-size: 18px;
    font-weight: 700;
}
.settings-close-btn {
    background: var(--surface-2);
    border: none;
    color: var(--text-muted);
    font-size: 16px;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background var(--transition);
}
.settings-close-btn:hover { background: var(--surface-3); }

.settings-body { padding: 16px 20px 20px; }

.setting-section {
    margin-bottom: 24px;
}
.setting-section-title {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: var(--text-dim);
    margin-bottom: 14px;
}
.setting-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}
.setting-row-label {
    font-size: 15px;
    color: var(--text);
    flex: 1;
}
.setting-row-desc {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 2px;
}
.setting-value {
    font-size: 15px;
    font-weight: 600;
    color: var(--green);
    min-width: 52px;
    text-align: right;
}

/* Slider */
input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 4px;
    background: var(--surface-3);
    border-radius: 2px;
    outline: none;
    margin-top: 8px;
}
input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 20px;
    height: 20px;
    background: var(--green);
    border-radius: 50%;
    cursor: pointer;
}
input[type="range"]::-moz-range-thumb {
    width: 20px;
    height: 20px;
    background: var(--green);
    border-radius: 50%;
    border: none;
    cursor: pointer;
}

/* Stepper */
.stepper {
    display: flex;
    align-items: center;
    gap: 12px;
}
.stepper-btn {
    width: 32px;
    height: 32px;
    background: var(--surface-2);
    border: none;
    border-radius: 50%;
    color: var(--text);
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background var(--transition);
    line-height: 1;
}
.stepper-btn:hover:not(:disabled) { background: var(--surface-3); }
.stepper-btn:disabled { opacity: 0.35; cursor: not-allowed; }
.stepper-val {
    font-size: 15px;
    font-weight: 600;
    color: var(--text);
    min-width: 28px;
    text-align: center;
}

/* Toggle switch */
.toggle-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
}
.toggle-label-group { flex: 1; }
.toggle-label-group .label-text {
    font-size: 15px;
    color: var(--text);
}
.toggle-label-group .label-desc {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 2px;
}
.toggle-switch {
    position: relative;
    width: 44px;
    height: 26px;
    flex-shrink: 0;
    margin-top: 2px;
}
.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
    position: absolute;
}
.toggle-track {
    position: absolute;
    inset: 0;
    background: var(--surface-3);
    border-radius: var(--radius-pill);
    cursor: pointer;
    transition: background var(--transition);
}
.toggle-switch input:checked + .toggle-track {
    background: var(--green);
}
.toggle-track::after {
    content: '';
    position: absolute;
    left: 3px;
    top: 3px;
    width: 20px;
    height: 20px;
    background: #fff;
    border-radius: 50%;
    transition: transform var(--transition);
}
.toggle-switch input:checked + .toggle-track::after {
    transform: translateX(18px);
}

/* Callback page */
#callback-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    text-align: center;
    gap: 20px;
    padding: 24px;
}
#callback-status {
    color: var(--text-muted);
    font-size: 16px;
}

/* ── Utilities ───────────────────────────────────────────────────────────────── */
.spacer { flex: 1; }
.mt-auto { margin-top: auto; }
.text-muted { color: var(--text-muted); }
.text-sm { font-size: 13px; }
.text-center { text-align: center; }
.full-width { width: 100%; }

/* ── Re-login notice banner ──────────────────────────────────────────────────── */
.relogin-notice {
    background: #2a1500;
    border: 1px solid #FF8C00;
    border-radius: var(--radius);
    color: #FFB347;
    font-size: 14px;
    line-height: 1.5;
    padding: 12px 16px;
    margin-bottom: 16px;
    text-align: center;
}

/* ── Safe area for notched phones ────────────────────────────────────────────── */
.screen { padding-bottom: max(40px, env(safe-area-inset-bottom)); }
