/* YT Relay — black theme matched to PodPrism Viewer */

:root {
    --bg-primary: #0a0a0a;
    --bg-secondary: #111111;
    --bg-card: #1a1a1a;
    --bg-hover: #1e1e1e;
    --bg-active: #252525;
    --text-primary: #ffffff;
    --text-secondary: #a0a0a0;
    --text-muted: #666666;
    --accent: #ffffff;
    --accent-hover: #d4d4d4;
    --accent-subtle: rgba(255, 255, 255, 0.1);
    --success: #22c55e;
    --error: #ef4444;
    --border: #2a2a2a;
    --radius: 6px;
    --radius-lg: 12px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
    height: 100%;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.hidden { display: none !important; }
[hidden] { display: none !important; }
.muted { color: var(--text-muted); font-size: 0.85rem; }
.job-mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.85rem; color: var(--text-secondary); }

/* ---------- AUTH GATE ---------- */

.auth-gate {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--bg-primary) 0%, #0f0f1a 100%);
    padding: 1rem;
}

.auth-box {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 3rem 2.5rem;
    text-align: center;
    max-width: 400px;
    width: 100%;
}

.auth-logo {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 64px;
    height: 64px;
    margin-bottom: 1rem;
    color: var(--text-primary);
}

.auth-box h1 {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    letter-spacing: -0.01em;
}

.auth-box p {
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
    font-size: 0.95rem;
}

.auth-box input {
    width: 100%;
    padding: 0.875rem 1rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-size: 1rem;
    margin-bottom: 1rem;
    outline: none;
    transition: border-color 0.2s;
    font-family: inherit;
}

.auth-box input:focus { border-color: var(--accent); }

.auth-box button {
    width: 100%;
    padding: 0.875rem;
    background: var(--accent);
    color: #000;
    border: none;
    border-radius: var(--radius);
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s;
    font-family: inherit;
}

.auth-box button:hover { background: var(--accent-hover); }

.auth-error {
    color: var(--error);
    font-size: 0.875rem;
    margin-top: 1rem;
}

/* ---------- APP SHELL ---------- */

.app {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.header {
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    padding: 1rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 10;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.header-left .logo {
    display: inline-flex;
    width: 24px;
    height: 24px;
    color: var(--text-primary);
}

.header-left h1 {
    font-size: 1.15rem;
    font-weight: 600;
    letter-spacing: -0.01em;
}

.content {
    flex: 1;
    width: 100%;
    max-width: 720px;
    margin: 0 auto;
    padding: 2rem 1.5rem 4rem;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

/* ---------- PANELS ---------- */

.panel {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
}

.panel.quiet {
    background: var(--bg-secondary);
}

.panel-title {
    font-size: 1.05rem;
    font-weight: 600;
    margin-bottom: 0.35rem;
}

.panel-title.small {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin-bottom: 0.75rem;
}

.panel-sub {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 1.25rem;
}

/* ---------- FORMS ---------- */

.url-form {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.url-form input[type="url"] {
    flex: 1 1 280px;
    padding: 0.75rem 0.9rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-size: 0.95rem;
    outline: none;
    transition: border-color 0.2s;
    font-family: inherit;
}

.url-form input[type="url"]:focus { border-color: var(--accent); }

.primary-btn,
.url-form button[type="submit"] {
    padding: 0.75rem 1.15rem;
    background: var(--accent);
    color: #000;
    border: none;
    border-radius: var(--radius);
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s, opacity 0.2s;
    font-family: inherit;
    white-space: nowrap;
}

.primary-btn:hover,
.url-form button[type="submit"]:hover { background: var(--accent-hover); }

.primary-btn:disabled,
.url-form button[type="submit"]:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.ghost-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem 0.85rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-secondary);
    font-size: 0.85rem;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.2s, border-color 0.2s, color 0.2s;
    font-family: inherit;
}

.ghost-btn:hover {
    background: var(--bg-hover);
    border-color: var(--accent);
    color: var(--text-primary);
}

.form-error {
    color: var(--error);
    font-size: 0.875rem;
    margin-top: 0.75rem;
}

/* ---------- JOB PANEL ---------- */

.job-row {
    display: flex;
    align-items: baseline;
    gap: 1rem;
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border);
}

.job-row-status {
    align-items: center;
}

.dismiss-btn {
    margin-left: auto;
    padding: 0.35rem 0.7rem;
    font-size: 0.75rem;
}

.job-row:last-of-type { border-bottom: none; }

.job-label {
    width: 80px;
    flex-shrink: 0;
    color: var(--text-muted);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-weight: 600;
}

.job-status {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-primary);
}

.job-status::before {
    content: "";
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-muted);
    box-shadow: 0 0 0 0 currentColor;
}

.job-status[data-state="queued"]::before,
.job-status[data-state="downloading"]::before,
.job-status[data-state="uploading"]::before {
    background: var(--accent);
    animation: pulse 1.4s ease-in-out infinite;
}

.job-status[data-state="done"]::before { background: var(--success); }
.job-status[data-state="error"]::before { background: var(--error); }

@keyframes pulse {
    0%, 100% { opacity: 0.4; }
    50% { opacity: 1; }
}

.progress {
    margin-top: 1rem;
    height: 2px;
    background: var(--border);
    border-radius: 999px;
    overflow: hidden;
    position: relative;
}

.progress-bar {
    position: absolute;
    inset: 0;
    background: var(--accent);
    transform: translateX(-100%);
    animation: indeterminate 1.6s ease-in-out infinite;
}

.progress.is-done .progress-bar {
    animation: none;
    transform: translateX(0);
    background: var(--success);
}

.progress.is-error .progress-bar {
    animation: none;
    transform: translateX(0);
    background: var(--error);
}

@keyframes indeterminate {
    0% { transform: translateX(-100%); }
    50% { transform: translateX(0%); }
    100% { transform: translateX(100%); }
}

.job-result {
    margin-top: 1.25rem;
    padding-top: 1.25rem;
    border-top: 1px solid var(--border);
}

.result-row {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.5rem;
    flex-wrap: wrap;
}

.result-row input {
    flex: 1 1 240px;
    padding: 0.65rem 0.85rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-size: 0.9rem;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    outline: none;
}

.result-row input:focus { border-color: var(--accent); }

.job-note {
    margin-top: 0.75rem;
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* ---------- ACTIVE QUEUE ---------- */

.queue-count {
    color: var(--text-secondary);
    font-weight: 500;
    letter-spacing: 0;
    text-transform: none;
    font-size: 0.75rem;
    margin-left: 0.4rem;
}

.queue-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.queue-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.6rem 0.8rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.85rem;
}

.queue-item.is-mine {
    border-color: var(--accent-subtle);
    background: var(--bg-hover);
}

.q-status {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    color: var(--text-secondary);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    min-width: 96px;
    flex-shrink: 0;
}

.q-status::before {
    content: "";
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--accent);
    animation: pulse 1.4s ease-in-out infinite;
}

.q-status[data-state="queued"]::before {
    background: var(--text-muted);
    animation: none;
}

.q-title {
    flex: 1;
    min-width: 0;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.q-age {
    color: var(--text-muted);
    font-size: 0.75rem;
    font-variant-numeric: tabular-nums;
    flex-shrink: 0;
}

/* ---------- HISTORY ---------- */

.history {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.history-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.6rem 0.8rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.85rem;
}

.history-item .h-title {
    flex: 1;
    min-width: 0;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.history-item a {
    color: var(--text-primary);
    text-decoration: none;
    border-bottom: 1px dashed var(--text-muted);
}

.history-item a:hover { border-bottom-color: var(--accent); }

/* ---------- FOOTER ---------- */

.footer {
    padding: 1rem 1.5rem 2rem;
    text-align: center;
    border-top: 1px solid var(--border);
    background: var(--bg-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.footer-sep {
    color: var(--text-muted);
    font-size: 0.85rem;
}

.footer-link {
    color: var(--text-secondary);
    text-decoration: none;
    border-bottom: 1px dashed var(--text-muted);
    transition: color 0.2s, border-color 0.2s;
}

.footer-link:hover {
    color: var(--text-primary);
    border-bottom-color: var(--accent);
}

.footer-attrib {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
}

.footer-logo-link {
    display: inline-flex;
    align-items: center;
    line-height: 0;
    opacity: 0.7;
    transition: opacity 0.2s;
}

.footer-logo-link:hover {
    opacity: 1;
}

.footer-logo {
    height: 14px;
    width: auto;
    display: block;
    /* SAW logo ships as solid black; brightness(0) flattens any color to
       black, then invert(1) turns it pure white to match the dark theme. */
    filter: brightness(0) invert(1);
}

/* ---------- RESPONSIVE ---------- */

@media (max-width: 480px) {
    .header { padding: 0.85rem 1rem; }
    .content { padding: 1.25rem 1rem 2.5rem; }
    .panel { padding: 1.15rem; }
    .auth-box { padding: 2rem 1.5rem; }
    .job-label { width: 64px; font-size: 0.7rem; }
}
