/* HRPC Scheduler status page. The look is HRPC-Podcast-Uploader's
   (uploader/static/style.css): the same colours, header, theme toggle,
   dashboard cards, steps and lists, so the two read as one system. Change a
   colour there and here together. Light and dark: the system setting picks
   one, and the header's toggle overrides it (saved in localStorage, applied as
   data-theme on <html> by status.js before the page paints). */

:root {
    color-scheme: light;
    --bg: #F7F8FA;
    --card-bg: #FFFFFF;
    --subtle: #F1F3F6;
    --border: #E3E6EB;
    --border-strong: #CDD2DA;
    --text: #111827;
    --text-light: #4B5563;
    --accent: #3451B2;
    --accent-text: #2C449A;
    --done: #15803D;
    --todo-bar: #E3E6EB;
    --todo-mark: #9AA3AF;
    --success: #166534;
    --success-bg: #E8F5EC;
    --error: #B91C1C;
    --error-bg: #FDECEC;
    --info: #2C449A;
    --info-bg: #EEF1FB;
    --warning: #9A3412;
    --warning-bg: #FDF0E6;
    --shadow: 0 1px 2px rgba(17, 24, 39, 0.05);
}

:root[data-theme="dark"] {
    color-scheme: dark;
    --bg: #0F1217;
    --card-bg: #171B22;
    --subtle: #1F242C;
    --border: #2A303A;
    --border-strong: #3A414D;
    --text: #E7EAF0;
    --text-light: #A3ABB8;
    --accent: #8EA4F2;
    --accent-text: #A9BAF5;
    --done: #4ADE80;
    --todo-bar: #2F3540;
    --todo-mark: #5B6472;
    --success: #86EFAC;
    --success-bg: #173022;
    --error: #FCA5A5;
    --error-bg: #3A1A1D;
    --info: #A9BAF5;
    --info-bg: #1E2640;
    --warning: #FDBA74;
    --warning-bg: #3A2614;
    --shadow: none;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        color-scheme: dark;
        --bg: #0F1217;
        --card-bg: #171B22;
        --subtle: #1F242C;
        --border: #2A303A;
        --border-strong: #3A414D;
        --text: #E7EAF0;
        --text-light: #A3ABB8;
        --accent: #8EA4F2;
        --accent-text: #A9BAF5;
        --done: #4ADE80;
        --todo-bar: #2F3540;
        --todo-mark: #5B6472;
        --success: #86EFAC;
        --success-bg: #173022;
        --error: #FCA5A5;
        --error-bg: #3A1A1D;
        --info: #A9BAF5;
        --info-bg: #1E2640;
        --warning: #FDBA74;
        --warning-bg: #3A2614;
        --shadow: none;
    }
}

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

body {
    font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
}

a {
    color: var(--accent-text);
}

code {
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 0.9em;
}

:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* ---- Header ---- */
.site-header {
    background: var(--card-bg);
    border-bottom: 1px solid var(--border);
}

.header-inner {
    max-width: 1120px;
    margin: 0 auto;
    padding: 10px 32px;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 8px 24px;
}

.nav-brand {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    font-weight: 600;
    font-size: 16px;
    color: var(--text);
    text-decoration: none;
    white-space: nowrap;
}

.nav-brand img {
    width: 40px;
    height: 40px;
    display: block;
}

.header-tools {
    display: flex;
    align-items: center;
    gap: 4px;
    min-width: 0;
}

.theme-toggle {
    flex: none;
    width: 44px;
    height: 44px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--card-bg);
    color: var(--text);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.theme-toggle:hover {
    background: var(--subtle);
}

/* Shows the theme it switches to: the moon in light mode, the sun in dark. */
.theme-toggle .icon-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-sun { display: block; }
:root[data-theme="dark"] .theme-toggle .icon-moon { display: none; }
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .theme-toggle .icon-sun { display: block; }
    :root:not([data-theme="light"]) .theme-toggle .icon-moon { display: none; }
}

/* ---- Page ---- */
main {
    max-width: 1120px;
    margin: 0 auto;
    padding: 32px 32px 72px;
}

.dashboard-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 32px;
}

.dashboard-header h1 {
    font-size: 28px;
    font-weight: 700;
    letter-spacing: -0.02em;
}

main > section {
    margin-bottom: 32px;
}

.section-head {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 6px 14px;
    margin-bottom: 14px;
}

.section-head-split {
    justify-content: space-between;
}

.section-head h2 {
    font-size: 18px;
    font-weight: 600;
}

.section-note {
    font-size: 13px;
    color: var(--text-light);
}

.section-link {
    font-size: 14px;
    font-weight: 500;
    text-decoration: none;
    white-space: nowrap;
}

.section-link:hover {
    text-decoration: underline;
}

.pill {
    padding: 3px 10px;
    border-radius: 999px;
    background: var(--subtle);
    color: var(--text-light);
    font-size: 12px;
    font-weight: 600;
}

.pill-warning {
    background: var(--warning-bg);
    color: var(--warning);
}

.badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
    white-space: nowrap;
}

.badge-detected { background: var(--info-bg); color: var(--info); }
.badge-error { background: var(--error-bg); color: var(--error); }
.badge-file { background: var(--subtle); color: var(--text-light); }
.badge-live { background: var(--success-bg); color: var(--success); }

.card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 16px;
}

.empty-note {
    padding: 20px 22px;
    color: var(--text-light);
    font-size: 14px;
}

/* ---- Service cards, one per row as in the uploader ---- */
.service-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 16px;
}

.service-card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 16px;
    box-shadow: var(--shadow);
    padding: 20px 22px;
    display: flex;
    flex-direction: column;
    gap: 18px;
    min-width: 0;
    container-type: inline-size;
}

.service-card-head {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: baseline;
    gap: 6px 12px;
}

.service-card h3 {
    font-size: 16px;
    font-weight: 600;
}

.service-status {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-light);
}

.service-card.is-live .service-status {
    color: var(--success);
}

.service-card.has-problem {
    border-color: var(--error);
}

.service-card.has-problem .service-status {
    color: var(--error);
}

.service-card.is-off {
    background: var(--subtle);
    box-shadow: none;
}

.service-title {
    margin-top: -10px;
    font-size: 14px;
    color: var(--text-light);
    overflow-wrap: anywhere;
}

.service-title a {
    font-weight: 500;
    text-decoration: none;
    white-space: nowrap;
}

.service-title a:hover {
    text-decoration: underline;
}

.steps {
    list-style: none;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
    gap: 12px 6px;
}

.step {
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-width: 0;
}

.step-bar {
    height: 4px;
    border-radius: 2px;
    background: var(--todo-bar);
}

.step-label {
    display: flex;
    align-items: flex-start;
    gap: 6px;
    font-size: 12px;
    line-height: 1.3;
    color: var(--text-light);
}

.step-label svg {
    flex: none;
    margin-top: 1px;
    color: var(--todo-mark);
}

/* Under each label, what it's waiting for or what went wrong */
.step-detail {
    display: block;
    margin-top: 2px;
    font-weight: 400;
    color: var(--text-light);
}

.step-done .step-bar { background: var(--done); }
.step-done .step-label { color: var(--text); }
.step-done .step-label svg { color: var(--done); }

.step-current .step-bar { background: var(--accent); }
.step-current .step-label { color: var(--text); font-weight: 600; }
.step-current .step-label svg { color: var(--accent); }

.step-problem .step-bar { background: var(--error); }
.step-problem .step-label { color: var(--error); font-weight: 600; }
.step-problem .step-label svg { color: var(--error); }
.step-problem .step-detail { color: var(--error); }

.step-unknown .step-bar {
    background: repeating-linear-gradient(90deg, var(--todo-bar) 0 6px, transparent 6px 10px);
}

@container (max-width: 520px) {
    .step-label {
        flex-direction: column;
        gap: 4px;
    }
}

/* ---- Lists: jobs and services.json ---- */
.list-card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 16px;
    box-shadow: var(--shadow);
    overflow: hidden;
}

.list-card > * + * {
    border-top: 1px solid var(--border);
}

.list-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 20px;
    padding: 14px 22px;
    color: var(--text);
    text-decoration: none;
}

.list-service {
    width: 120px;
    flex: none;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-light);
}

.list-main {
    flex: 999 1 220px;
    min-width: 0;
}

.list-title {
    display: block;
    font-size: 15px;
    font-weight: 600;
    overflow-wrap: anywhere;
}

.list-meta {
    display: block;
    margin-top: 2px;
    font-size: 13px;
    color: var(--text-light);
    overflow-wrap: anywhere;
}

.list-meta:empty {
    display: none;
}

.job-name {
    margin-left: 4px;
    font-weight: 400;
    color: var(--text-light);
}

/* A job's row opens to show its last run's output */
.list-row-details > summary {
    list-style: none;
    cursor: pointer;
}

.list-row-details > summary::-webkit-details-marker {
    display: none;
}

.list-row-details > summary:hover,
.list-row-details[open] > summary {
    background: var(--subtle);
}

.list-row-details > summary .list-title::after {
    content: "›";
    display: inline-block;
    margin-left: 8px;
    color: var(--text-light);
    transition: transform 0.15s;
}

.list-row-details[open] > summary .list-title::after {
    transform: rotate(90deg);
}

.log {
    padding: 0 22px 18px;
    background: var(--subtle);
}

.log-head {
    padding-bottom: 8px;
    font-size: 12px;
    color: var(--text-light);
}

.log pre {
    max-height: 320px;
    overflow: auto;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--card-bg);
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 12px;
    line-height: 1.5;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

/* ---- Needs attention ---- */
.attention {
    padding: 18px 22px;
    border-radius: 16px;
    background: var(--error-bg);
    color: var(--error);
}

.attention h2 {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 6px;
}

.attention ul {
    margin: 0 0 8px 20px;
    font-size: 14px;
}

.attention li + li {
    margin-top: 4px;
}

.attention p {
    font-size: 13px;
}

.page-foot {
    max-width: 70ch;
    font-size: 12px;
    color: var(--text-light);
}

/* ---- Phones ---- */
@media (max-width: 768px) {
    .header-inner {
        padding: 8px 16px;
    }

    .nav-brand {
        min-height: 44px;
    }

    main {
        padding: 20px 16px 48px;
    }

    .dashboard-header {
        margin-bottom: 20px;
    }

    .service-card {
        padding: 16px;
    }

    .list-row,
    .log,
    .attention {
        padding-left: 16px;
        padding-right: 16px;
    }

    .list-service {
        width: auto;
        flex-basis: 100%;
    }
}
