/* Tinseltown Admin: plain and readable, no framework. */

:root {
    color-scheme: light dark;
    --text: #1d1d1f;
    --muted: #6e6e73;
    --background: #ffffff;
    --stripe: #f3f3f5;
    --border: #d2d2d7;
    --accent: #0a62c9;
    --banner: #fde8e8;
    --banner-border: #c62828;
    --warning: #fff4d6;
    --flash: #e6f4ea;
    --danger: #c62828;
    --on-danger: #ffffff;
}

@media (prefers-color-scheme: dark) {
    :root {
        --text: #f5f5f7;
        --muted: #a1a1a6;
        --background: #1c1c1e;
        --stripe: #2a2a2d;
        --border: #3a3a3c;
        --accent: #64a8ff;
        --banner: #4a1c1c;
        --banner-border: #ef5350;
        --warning: #4a3d14;
        --flash: #1d3b26;
        --danger: #d32f2f;
        --on-danger: #ffffff;
    }
}

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
    line-height: 1.45;
    color: var(--text);
    background: var(--background);
}

header {
    border-bottom: 1px solid var(--border);
    padding: 0.5rem 1rem;
}

nav {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    align-items: center;
}

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

nav form {
    margin-left: auto;
}

main {
    padding: 1rem;
    max-width: 100%;
    overflow-x: auto;
}

h1 {
    margin-top: 0;
}

.banner {
    background: var(--banner);
    border: 1px solid var(--banner-border);
    padding: 0.5rem 1rem;
    margin-bottom: 1rem;
}

.banner h2 {
    font-size: 1rem;
    margin: 0.25rem 0;
}

.warning,
.flash {
    padding: 0.5rem 1rem;
    margin: 0 0 1rem;
}

.warning {
    background: var(--warning);
}

.flash {
    background: var(--flash);
}

table {
    border-collapse: collapse;
    width: 100%;
    margin-bottom: 1rem;
}

table.summary {
    width: auto;
}

th,
td {
    text-align: left;
    vertical-align: top;
    padding: 0.35rem 0.5rem;
    border-bottom: 1px solid var(--border);
}

tbody tr:nth-child(even) {
    background: var(--stripe);
}

form.inline {
    display: inline;
}

td.actions {
    white-space: nowrap;
}

.hint {
    display: block;
    color: var(--muted);
    font-size: 0.85em;
}

.tag {
    color: var(--muted);
    font-size: 0.85em;
    border: 1px solid var(--border);
    border-radius: 0.25rem;
    padding: 0 0.25rem;
}

form.bulk,
form.add {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem 1rem;
    align-items: center;
    margin-bottom: 1rem;
}

/* A canonical service only means something for an alias, so its field shows only while the row's (or the add
   form's) disposition is "alias". Browsers without :has() keep showing it, which is harmless: the server ignores
   it for any other disposition. */
:is(form, tr):has(select[name="disposition"]):not(:has(option[value="alias"]:checked)) .canonical-field {
    display: none;
}

/* The rules page's All / Customized / Default filter; the current one is bold and not a link-blue. */
nav.filters {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1rem;
}

nav.filters a {
    color: var(--accent);
    text-decoration: none;
}

nav.filters a[aria-current="page"] {
    color: var(--text);
    font-weight: bold;
}

/* A collapsible section whose heading is its toggle. */
details.section > summary {
    cursor: pointer;
}

details.section > summary > h2 {
    display: inline;
}

/* Removing a rules entry: the provider goes back to whatever the rule alone decides. */
button.destructive {
    background: var(--danger);
    color: var(--on-danger);
    border: 1px solid var(--danger);
    border-radius: 0.3rem;
    padding: 0.1rem 0.6rem;
    cursor: pointer;
}

/* A provider without a rules entry: "Customize" opens the form that adds one. */
details.customize {
    display: inline-block;
}

details.customize > summary {
    display: inline-block;
    list-style: none;
    cursor: pointer;
    border: 1px solid var(--border);
    border-radius: 0.3rem;
    padding: 0.1rem 0.6rem;
    background: var(--stripe);
}

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

details.customize[open] > summary {
    margin-right: 0.5rem;
}

/* A link that takes you somewhere to act, drawn like the Customize button. */
a.button {
    display: inline-block;
    color: var(--text);
    text-decoration: none;
    border: 1px solid var(--border);
    border-radius: 0.3rem;
    padding: 0.1rem 0.6rem;
    background: var(--stripe);
}

form.suffixes {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    align-items: flex-start;
}

textarea {
    font-family: ui-monospace, Menlo, monospace;
    white-space: pre;
}

input,
select,
textarea,
button {
    font: inherit;
}

pre.diff {
    font-family: ui-monospace, Menlo, monospace;
    font-size: 0.9em;
    background: var(--stripe);
    border: 1px solid var(--border);
    padding: 0.5rem 1rem;
    overflow-x: auto;
}
