/* TorrentMonitor web interface styles. The light and dark themes are defined by variables. */

:root {
    --bg: #f4f5f7;
    --surface: #ffffff;
    --surface-2: #f0f2f5;
    --border: #d9dde3;
    --text: #1c2128;
    --muted: #667080;
    --accent: #0b6e69;
    --accent-text: #ffffff;
    --accent-soft: #e2f1f0;
    --good: #1a7f4b;
    --bad: #c0392b;
    --bad-soft: #fbeae8;
    --warn: #9a6700;
    /* names of advanced settings: orange-red, as Sonarr marks its advanced settings */
    --advanced: #d9480f;
    --warn-soft: #fff4d6;
    --shadow: 0 1px 2px rgba(20, 30, 45, .06), 0 4px 16px rgba(20, 30, 45, .06);
    --radius: 8px;
    --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    color-scheme: light;
}

[data-theme="dark"] {
    --bg: #14171c;
    --surface: #1c2027;
    --surface-2: #242932;
    --border: #333a45;
    --text: #e4e7ec;
    --muted: #98a2b3;
    --accent: #3fb6ae;
    --accent-text: #0c1a19;
    --accent-soft: #1d3331;
    --good: #57c084;
    --bad: #f0796c;
    --bad-soft: #3a2220;
    --warn: #e0b040;
    --advanced: #ff8a50;
    --warn-soft: #3a3017;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 16px rgba(0, 0, 0, .25);
    color-scheme: dark;
}

* { box-sizing: border-box; }
[x-cloak] { display: none !important; }

html { font-size: 15px; }
body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font);
    line-height: 1.45;
}

h1 { font-size: 1.5rem; margin: 0; font-weight: 650; }
h2 { font-size: 1.05rem; margin: 0 0 .75rem; font-weight: 650; }
p { margin: .5rem 0; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code { font-family: var(--mono); font-size: .9em; background: var(--surface-2); padding: .05em .35em; border-radius: 4px; }
.muted { color: var(--muted); }
.spacer { flex: 1; }

/* ---- layout */
.layout { display: flex; min-height: 100vh; }

.nav {
    width: 220px;
    flex: none;
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 1rem .75rem;
    background: var(--surface);
    border-right: 1px solid var(--border);
    position: sticky;
    top: 0;
    height: 100vh;
}
.nav__brand { font-weight: 700; font-size: 1.1rem; padding: .25rem .6rem 1rem; }
.nav__link {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: .5rem .6rem;
    border-radius: 6px;
    color: var(--text);
}
.nav__link:hover { background: var(--surface-2); text-decoration: none; }
.nav__link--active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.nav__foot { margin-top: auto; display: flex; flex-direction: column; align-items: flex-start; gap: .4rem; padding: .6rem; font-size: .87rem; }

.count {
    min-width: 1.4em;
    padding: 0 .4em;
    border-radius: 999px;
    background: var(--bad);
    color: #fff;
    font-size: .75rem;
    font-weight: 600;
    text-align: center;
}

.main { flex: 1; min-width: 0; padding: 1rem 1.5rem 3rem; max-width: 1100px; }

.runbar { display: flex; align-items: center; justify-content: flex-end; gap: .75rem; font-size: .87rem; min-height: 2rem; margin-bottom: .5rem; }
.running { color: var(--accent); font-weight: 600; }
.running::before {
    content: "";
    display: inline-block;
    width: .6em;
    height: .6em;
    margin-right: .4em;
    border-radius: 50%;
    background: currentColor;
    animation: pulse 1s ease-in-out infinite;
}
@keyframes pulse { 50% { opacity: .25; } }

.banner { background: var(--accent-soft); border: 1px solid var(--accent); border-radius: var(--radius); padding: .6rem .9rem; margin-bottom: 1rem; }

.head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.head__actions { display: flex; gap: .5rem; flex-wrap: wrap; }

.center { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 1.5rem; }

/* ---- cards and lists */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.1rem 1.25rem;
    margin-bottom: 1rem;
}
.card--narrow { width: 100%; max-width: 34rem; box-shadow: var(--shadow); }
.card--login { width: 100%; max-width: 22rem; box-shadow: var(--shadow); }
.card--narrow h1, .card--login h1 { margin-bottom: .75rem; }
.card--narrow h2 { margin-top: 1.4rem; }
.card--accent { border-color: var(--accent); }
.card__head { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; margin-bottom: .5rem; }
.card__head h2 { margin: 0; }

.list { list-style: none; margin: 0; padding: 0; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.list:empty { display: none; }
.list--plain { border: 0; background: none; }
.list > li + li { border-top: 1px solid var(--border); }

.row { display: flex; gap: .75rem; padding: .75rem 1rem; align-items: flex-start; }
.list--plain .row { padding-left: 0; padding-right: 0; }
.row--dim .row__title, .row--dim .row__meta { opacity: .6; }
.row__icon { margin-top: .25rem; flex: none; }
.row__body { flex: 1; min-width: 0; }
.row__title { font-weight: 550; overflow-wrap: anywhere; }
.row__title a { color: var(--text); }
.row__title a:hover { color: var(--accent); }
.row__meta { display: flex; flex-wrap: wrap; gap: .15rem .9rem; color: var(--muted); font-size: .87rem; margin-top: .15rem; }
.row__meta span:empty { display: none; }
.row__flags { display: flex; flex-wrap: wrap; gap: 0 .35rem; }
.row__flags .tag { margin-top: .35rem; }
.row__error { color: var(--bad); font-size: .87rem; margin-top: .25rem; }
.row__actions { display: flex; gap: .35rem; justify-content: flex-end; flex: none; }
.row .row__more { display: none; flex: none; }
.list--compact .row .row__more { display: inline-flex; }

/* compact list of topics: one line per topic */
.row--compact { padding-top: .35rem; padding-bottom: .35rem; align-items: center; }
.row--compact .row__icon { margin-top: 0; }
.row--compact .row__body { display: flex; align-items: center; gap: .75rem; }
.row--compact .row__title { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; overflow-wrap: normal; }
.row--compact .row__meta { flex: none; flex-wrap: nowrap; white-space: nowrap; margin-top: 0; }
.row--compact .row__meta span:not(.row__keep) { display: none; }
.row--compact .row__flags { flex: none; flex-wrap: nowrap; }
.row--compact .row__flags .tag { margin-top: 0; }
.row--compact .row__error { display: none; }
.check--inline { margin: 0; align-items: center; white-space: nowrap; }
/* a setting that rarely needs changing: shown when «Показать расширенные» is on */
.field.field--advanced > span { color: var(--advanced); }
.check--inline input { margin-top: 0; }

.tag { display: inline-block; padding: .05rem .5rem; border-radius: 999px; font-size: .78rem; background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.tag--bad { background: var(--bad-soft); color: var(--bad); }
.tag--warn { background: var(--warn-soft); color: var(--warn); }
.tag--good { background: var(--accent-soft); color: var(--accent); }

.empty { padding: 2rem 1rem; text-align: center; max-width: 40rem; margin: 0 auto; }

.filters { display: flex; gap: .5rem; flex-wrap: wrap; margin-bottom: .75rem; }
.filters input { flex: 1; min-width: 12rem; }
.filters select { width: auto; }
.card__head select { width: auto; }
.journal { max-height: 26rem; overflow-y: auto; font-size: .9rem; }
.journal__line { padding: .3rem 0; border-top: 1px solid var(--border); overflow-wrap: anywhere; }
.journal__line:first-child { border-top: 0; }
.journal__time { display: inline-block; min-width: 8.5rem; }
.small { font-size: .85rem; }
.pager { display: flex; align-items: center; justify-content: center; gap: 1rem; margin-top: .75rem; }

.inline { display: flex; gap: .5rem; flex-wrap: wrap; margin: 1rem 0; }
.inline select { width: auto; }
.inline input { flex: 1; min-width: 12rem; }

/* ---- trackers */
.tracker__head {
    display: flex;
    align-items: center;
    gap: .75rem;
    width: 100%;
    padding: .7rem 1rem;
    background: none;
    border: 0;
    color: inherit;
    font: inherit;
    text-align: left;
    cursor: pointer;
    flex-wrap: wrap;
}
.tracker__head:hover { background: var(--surface-2); }
.tracker__name { font-weight: 550; min-width: 10rem; }
.tracker__form { padding: .5rem 1rem 1rem 2.75rem; border-top: 1px dashed var(--border); }
.tracker--open { background: var(--surface); }

/* ---- forms */
.field { display: grid; grid-template-columns: 13rem 1fr; gap: .25rem 1rem; align-items: center; margin: .6rem 0; }
.field > span { color: var(--muted); }
.field > small, .field > datalist { grid-column: 2; }
small { color: var(--muted); font-size: .85rem; }
.dialog .field, .card--narrow .field, .card--login .field { grid-template-columns: 1fr; }
.dialog .field > small, .card--narrow .field > small { grid-column: 1; }

input[type="text"], input[type="url"], input[type="password"], input[type="number"], input[type="search"], select, textarea {
    width: 100%;
    padding: .45rem .6rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--surface);
    color: var(--text);
    font: inherit;
}
input[type="number"] { max-width: 12rem; }
textarea { font-family: var(--mono); font-size: .85rem; resize: vertical; }
input:focus-visible, select:focus-visible, textarea:focus-visible, button:focus-visible, a:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 1px;
}
input[readonly] { background: var(--surface-2); font-family: var(--mono); font-size: .85rem; }

.check { display: flex; align-items: flex-start; gap: .5rem; margin: .5rem 0; cursor: pointer; }
.check input { margin-top: .25rem; accent-color: var(--accent); }

fieldset { border: 0; border-top: 1px solid var(--border); margin: .75rem 0 0; padding: .5rem 0 0; }

.actions { display: flex; gap: .5rem; flex-wrap: wrap; margin-top: 1rem; }

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: .45rem .9rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--surface);
    color: var(--text);
    font: inherit;
    cursor: pointer;
    white-space: nowrap;
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn:disabled { opacity: .55; cursor: default; }
.btn--primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); font-weight: 600; }
.btn--primary:hover { background: var(--accent); filter: brightness(1.08); }
.btn--danger { color: var(--bad); }
.btn--danger:hover { background: var(--bad-soft); }
.dialog .btn--danger { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn--small { padding: .2rem .6rem; font-size: .85rem; }

.link { background: none; border: 0; padding: 0; color: var(--accent); font: inherit; cursor: pointer; }
.link:hover { text-decoration: underline; }

/* ---- dialogs */
.overlay {
    position: fixed;
    inset: 0;
    z-index: 20;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 5vh 1rem;
    background: rgba(10, 15, 22, .5);
    overflow-y: auto;
}
.dialog { width: 100%; max-width: 34rem; background: var(--surface); border-radius: var(--radius); padding: 1.25rem 1.4rem; box-shadow: var(--shadow); }
.dialog--small { max-width: 26rem; }

/* ---- messages */
.toasts { position: fixed; right: 1rem; bottom: 1rem; z-index: 30; display: flex; flex-direction: column; gap: .5rem; max-width: min(26rem, calc(100vw - 2rem)); }
.toast { background: var(--text); color: var(--bg); padding: .6rem .9rem; border-radius: 6px; box-shadow: var(--shadow); cursor: pointer; }
.toast--error { background: var(--bad); color: #fff; }

/* ---- status */
.group { margin: .75rem 0; }
.group__title { display: flex; gap: .75rem; align-items: baseline; margin-bottom: .2rem; }
.line { padding: .15rem 0 .15rem 1.4rem; position: relative; overflow-wrap: anywhere; }
.line::before { content: "·"; position: absolute; left: .45rem; color: var(--muted); }
.line--good::before { content: "✓"; left: .2rem; color: var(--good); }
.line--bad { color: var(--bad); }
.line--bad::before { content: "✕"; left: .2rem; color: var(--bad); }

.log, .notes {
    margin: .5rem 0 0;
    padding: .75rem;
    background: var(--surface-2);
    border-radius: 6px;
    font-family: var(--mono);
    font-size: .8rem;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    max-height: 26rem;
    overflow-y: auto;
}
.notes { font-family: var(--font); font-size: .93rem; white-space: normal; }
.notes > :first-child { margin-top: 0; }
.notes > :last-child { margin-bottom: 0; }
.notes h3 { font-size: 1.05rem; margin: 1rem 0 .4rem; }
.notes h4 { font-size: .95rem; margin: .9rem 0 .3rem; }
.notes p { margin: .4rem 0; }
.notes ul { margin: .3rem 0; padding-left: 1.25rem; }
.notes li { margin: .15rem 0; }
.notes b { font-weight: 650; }
.notes code { font-family: var(--mono); font-size: .85em; background: var(--surface); padding: .05rem .3rem; border-radius: 4px; }


/* ---- narrow screens */
@media (max-width: 800px) {
    .layout { flex-direction: column; }
    .nav {
        width: auto;
        height: auto;
        position: sticky;
        top: 0;
        z-index: 10;
        flex-direction: row;
        align-items: center;
        gap: 0;
        padding: .25rem .5rem;
        border-right: 0;
        border-bottom: 1px solid var(--border);
        overflow-x: auto;
    }
    .nav__brand, .nav__foot .muted { display: none; }
    .nav__link { white-space: nowrap; gap: .35rem; }
    .nav__foot { margin: 0 0 0 auto; flex-direction: row; align-items: center; white-space: nowrap; gap: .75rem; }
    .main { padding: .75rem .75rem 3rem; }
    .row { flex-wrap: wrap; }
    .row__actions { width: 100%; flex-wrap: wrap; justify-content: flex-start; padding-left: 1.75rem; }
    /* compact on a narrow screen: the name and the labels only */
    .row--compact { flex-wrap: nowrap; }
    .row--compact .row__actions, .row--compact .row__meta { display: none; }
    .field { grid-template-columns: 1fr; }
    .field > small, .field > datalist { grid-column: 1; }
    .tracker__form { padding-left: 1rem; }
    .tracker__name { min-width: 0; }
}

@media (prefers-reduced-motion: reduce) {
    .running::before { animation: none; }
}

/* the log of the last check run, folded under the journal */
.runlog { margin-top: .75rem; }
.runlog summary { cursor: pointer; color: var(--muted); font-size: .9rem; }
.runlog[open] summary { color: inherit; }
.runlog__bar { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin-top: .5rem; }
.runlog__bar select { width: auto; max-width: 100%; }

/* the page of the log: the log takes the height the window has left */
.logpage { display: flex; flex-direction: column; height: calc(100vh - 6.5rem); min-height: 28rem; }
.logbar { display: flex; flex-wrap: wrap; gap: .5rem 1rem; align-items: center; margin-bottom: .5rem; }
.logbar select, .logbar input[type=search] { width: auto; max-width: 100%; }
.logbar .check { margin: 0; }
.logbox { flex: 1; min-height: 12rem; overflow: auto; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: .5rem .75rem; font-size: .88rem; }
.logline { padding: .2rem 0; border-top: 1px solid var(--border); overflow-wrap: anywhere; }
.logline:first-child { border-top: 0; }
.logline__time { display: inline-block; min-width: 10.5rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.logline--detail { border-top: 0; padding: 0; font-family: var(--mono); font-size: .8rem; color: var(--muted); white-space: pre-wrap; }
.logline--detail .logline__time { min-width: 10.5rem; }
.updates { display: flex; flex-wrap: wrap; gap: .5rem .75rem; align-items: center; margin: .25rem 0 .75rem; }

/* the torrent client does not answer: said once above the list of topics */
.clientdown { margin: 0 0 .75rem; padding: .5rem .75rem; border-radius: 6px; background: var(--warn-soft); color: var(--warn); }
/* compact list: what the client is doing stands in a column of one width, as a sign and the percent */
.row--compact .tag--client { min-width: 4.6rem; text-align: center; font-variant-numeric: tabular-nums; }
.tag--none { visibility: hidden; }
