@import "./fonts/anonymouspro.css";

/*
 * One stylesheet for the whole admin, CMS included.
 *
 * The admin had drifted into two visual languages: a Bootstrap-ish one
 * (#007bff pills, 8px radii, drop shadows) inherited from the directory app,
 * and a flat monospace one (square, 2px #333, uppercase) that the Chivo
 * templates reached for. Components were redefined per template — .stat-card
 * four times, .badge three — so the same widget looked different depending on
 * which page you were standing on, which is what read as "the CSS isn't
 * loading". The flat language wins here because it matches the body font and
 * the .btn that every page already shares.
 *
 * Anything a second template needs belongs in this file, not in a page's
 * <style> block. A page-local block is for something genuinely used once.
 */

:root {
    --ink: #333;
    --paper: #fff;
    --ground: #f8f9fa;
    --rule: #ddd;          /* hairline: table rows, insets */
    --rule-strong: #333;   /* structural: panels, controls, tabs */
    --muted: #777;
    --accent: #007bff;
    --danger: #c00;
    --badge-draft: #ffe9a8;
    --badge-published: #d7f5d3;
    --space: 8px;
}

/* ---------- Shell ---------- */

.admin-body {
    padding: 0;
    max-width: none;
    margin: 0;
    font-family: "Anonymous Pro", monospace;
    background-color: var(--ground);
    color: var(--ink);
}

.admin-header {
    background: #343a40;
    color: #fff;
    padding: 1rem 0;
    margin-bottom: 2rem;
}

.admin-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    padding: 0 1rem;
}

.admin-nav h1 { margin: 0; font-size: 22px; }
.admin-nav h1 a { color: #fff; text-decoration: none; }
.admin-nav h1 a:hover { text-decoration: underline; }

.admin-nav .user-info {
    display: flex;
    gap: 4px;
    align-items: center;
    flex-wrap: wrap;
}

/* Nav items were solid blue pills, the only rounded blue thing left in the
   admin. Flat and quiet lets the page content carry the visual weight. */
.admin-nav .nav-link {
    color: #fff;
    text-decoration: none;
    padding: 6px 10px;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    border: 1px solid transparent;
}

.admin-nav .nav-link:hover { border-color: #fff; }

/* aria-current="page" marks where you are; it needs no extra class. */
.admin-nav .nav-link[aria-current="page"] { background: #fff; color: #343a40; }

.admin-nav .nav-link.secondary { color: #c9ced3; }
.admin-nav .nav-link.secondary:hover { border-color: #c9ced3; }

/* A <details> menu, so the grouping needs no JavaScript to work: strip all of
   this CSS and the browser still renders a native disclosure, closed, that
   opens on its summary. The parked directory app and the account items each
   collapse into one, which leaves the top row to Chivo — the product that
   actually gets worked on. */
.nav-menu { position: relative; }

.nav-menu > summary {
    list-style: none;
    cursor: pointer;
    user-select: none;
}

.nav-menu > summary::-webkit-details-marker { display: none; }
.nav-menu > summary::after { content: " \25BE"; opacity: .7; }

/* Marks the whole group when the page you are on lives inside it. */
.nav-menu > summary.is-active { background: #fff; color: #343a40; }

.nav-menu-items {
    position: absolute;
    right: 0;
    top: calc(100% + 4px);
    z-index: 20;
    min-width: 170px;
    /* Anchored to its summary's right edge, so it grows leftward and can run
       off the viewport once the nav wraps on a narrow screen. */
    max-width: calc(100vw - 32px);
    display: flex;
    flex-direction: column;
    background: #343a40;
    border: 1px solid #565d64;
    padding: 4px;
}

.nav-menu-item {
    display: block;
    color: #fff;
    text-decoration: none;
    padding: 7px 10px;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    white-space: nowrap;
}

.nav-menu-item:hover { background: #4a5057; }
.nav-menu-item[aria-current="page"] { background: #fff; color: #343a40; }

.admin-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1rem 4rem;
}

/* ---------- Buttons ---------- */

.btn {
    padding: 8px 16px;
    border: 2px solid var(--rule-strong);
    background: var(--paper);
    cursor: pointer;
    font-family: inherit;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 1px;
    transition: background .15s, color .15s;
    text-decoration: none;
    color: var(--ink);
    display: inline-block;
    line-height: 1.4;
}

.btn:hover { background: var(--ink); color: #fff; }

.btn-primary { border-color: var(--accent); color: var(--accent); }
.btn-primary:hover { background: var(--accent); color: #fff; }

.btn-secondary { border-color: var(--muted); color: var(--muted); background: var(--paper); }
.btn-secondary:hover { background: var(--muted); color: #fff; }

/* Delete used to be a filled red slab, which made the most destructive
   control the loudest thing in every table row. Outlined at rest, filled on
   hover: still unmistakably red, no longer shouting. */
.btn-danger { border-color: var(--danger); color: var(--danger); background: var(--paper); }
.btn-danger:hover { background: var(--danger); color: #fff; }

.btn-sm { padding: 4px 10px; font-size: 11px; letter-spacing: .04em; }

/* Guestbook and Sites both moderate a queue, and both had their own copy of
   these. Outlined at rest like every other button here; the fill is the
   confirmation, not the invitation. */
.btn-approve { border-color: #2f7d32; color: #2f7d32; background: var(--paper); }
.btn-approve:hover { background: #2f7d32; color: #fff; }

.btn-reject { border-color: var(--danger); color: var(--danger); background: var(--paper); }
.btn-reject:hover { background: var(--danger); color: #fff; }

/* ---------- Forms ---------- */

.form-container {
    max-width: 600px;
    margin: 0 auto;
    background: var(--paper);
    border: 2px solid var(--rule-strong);
    padding: 2rem;
}

.form-group { margin-bottom: 1.5rem; }

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: bold;
}

.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 0.6rem;
    border: 1px solid var(--rule-strong);
    font-size: 1rem;
    font-family: inherit;
    box-sizing: border-box;
}

.form-group textarea { resize: vertical; min-height: 100px; }

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: 2px solid var(--accent);
    outline-offset: -2px;
}

.checkbox-group { display: flex; align-items: center; gap: 0.5rem; }
.checkbox-group input[type="checkbox"] { width: auto; margin: 0; }

.form-actions { display: flex; gap: 1rem; margin-top: 2rem; }

.help-text, .muted { color: var(--muted); font-size: 13px; }
.help-text { margin-top: 0.25rem; }

/* ---------- Messages ---------- */

/* Scoped to block elements on purpose. These class names are used two ways:
   as a standalone message box (<div class="error">) and as the colour of a
   word inside a line of text (<span class="success"> in the crawl log). When
   the box styling matched both, a one-word status span rendered as a padded,
   bordered block in the middle of a table row. */
div.error, div.success, p.error, p.success,
.security-note, .build-note, .build-problem, .notice, .problems {
    padding: 0.75rem;
    margin-bottom: 1rem;
    border: 1px solid;
}

/* Colour is safe on any element; the fill belongs only to the box form. */
.error { color: #721c24; }
.success { color: #155724; }
div.error, p.error { background: #f8d7da; border-color: #f5c6cb; }
div.success, p.success { background: #d4edda; border-color: #c3e6cb; }
.security-note { background: #e9ecef; border-color: #ced4da; font-size: 0.9rem; }
.build-note, .notice { background: #fff8dc; border-color: #e0c96a; }
/* A build that failed is not a queued build in a warmer colour: it needs the
   same red as the other things asking to be acted on. */
.build-problem { background: #ffecec; border-color: var(--danger); color: #721c24; }
.problems { border: 2px solid var(--danger); background: #ffecec; }
.problems ul { margin: 6px 0 0; padding-left: 20px; }

/* ---------- Tables ---------- */

/* .post-table, .trash-table and .feeds-table were three names for one thing. */
.data-table, .post-table, .trash-table, .feeds-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--paper);
    border: 1px solid var(--rule);
}

.data-table th, .data-table td,
.post-table th, .post-table td,
.trash-table th, .trash-table td,
.feeds-table th, .feeds-table td {
    padding: 10px;
    border-bottom: 1px solid var(--rule);
    text-align: left;
    vertical-align: middle;
}

.data-table th, .post-table th, .trash-table th, .feeds-table th {
    background: var(--ground);
    font-weight: bold;
    text-transform: uppercase;
    font-size: 12px;
    letter-spacing: 0.04em;
}

.data-table tr:hover td, .post-table tr:hover td,
.trash-table tr:hover td, .feeds-table tr:hover td { background: #fcfcfd; }

.revision-table { width: 100%; border-collapse: collapse; }
.revision-table td { padding: 6px 8px; border-bottom: 1px solid #eee; font-size: 13px; }

.no-feeds, .empty-state {
    text-align: center;
    padding: 2rem;
    color: var(--muted);
    background: var(--paper);
    border: 1px solid var(--rule);
}

.actions { display: flex; gap: 0.5rem; align-items: center; }

/* ---------- Record list ---------- */

/* Feeds, guestbook entries, sites and crawl-log rows are four hand-rolled
   copies of one idea: a bordered stack of rows, each with a block of detail on
   the left and its actions on the right. They had drifted to four names
   (.feed-item, .entry-item, .site-item, .log-entry) and four sets of numbers.
   This is the one they are being moved onto, a page at a time. */
.record-list {
    background: var(--paper);
    border: 1px solid var(--rule);
}

.record-item {
    display: flex;
    gap: 16px;
    align-items: flex-start;
    justify-content: space-between;
    padding: 14px 16px;
    border-bottom: 1px solid var(--rule);
}

.record-item:last-child { border-bottom: none; }
.record-item:hover { background: #fcfcfd; }

/* min-width:0 lets a long unbroken URL shrink instead of pushing the actions
   off the row, which flexbox will otherwise happily do. */
.record-info { flex: 1; min-width: 0; }

.record-title { font-weight: bold; margin-bottom: 4px; }

.record-url {
    display: block;
    font-size: 13px;
    color: var(--accent);
    overflow-wrap: anywhere;
    margin-bottom: 4px;
    /* The lists these replaced underlined a URL on hover, not at rest. A row
       of permanently underlined URLs reads as noise when every row has one. */
    text-decoration: none;
}

.record-url:hover { text-decoration: underline; }

.record-body { margin: 6px 0; overflow-wrap: anywhere; }
.record-meta { font-size: 12px; color: var(--muted); }

.record-actions {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-shrink: 0;
}

/* Actions under the detail rather than beside it, before the two columns get
   too narrow to read. */
@media (max-width: 700px) {
    .record-item { flex-direction: column; }
}

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

/* The row already centres its children, so the heading's default block margins
   only add slack the layout has provided. */
.page-header h2 { margin: 0; }

/* A smaller sibling of .stat-value, for the inline counts the moderation pages
   put above their lists rather than on a dashboard card. */
.stat-number { font-size: 32px; font-weight: bold; color: var(--ink); }

/* ---------- Badges ---------- */

.badge, .status-badge {
    display: inline-block;
    padding: 2px 8px;
    font-size: 12px;
    border: 1px solid var(--rule-strong);
    white-space: nowrap;
}

.badge-draft, .status-inactive, .status-pending { background: var(--badge-draft); }
.status-rejected { background: #f8d7da; }
.badge-published, .status-active, .status-approved { background: var(--badge-published); }

/* ---------- Posts list (Chivo) ---------- */

.type-tabs { display: flex; flex-wrap: wrap; gap: var(--space); margin: 20px 0; }

.type-tab {
    padding: 6px 14px;
    border: 2px solid var(--rule-strong);
    background: var(--paper);
    text-decoration: none;
    color: var(--ink);
}

.type-tab:hover { background: var(--ground); }
.type-tab.is-active { background: var(--ink); color: #fff; }

.toolbar {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 20px 0;
    flex-wrap: wrap;
}

.search { margin-left: auto; display: flex; gap: 6px; }

.search input[type="search"] {
    padding: 6px 10px;
    border: 2px solid var(--rule-strong);
    min-width: 220px;
    font: inherit;
}

select {
    padding: 6px 10px;
    border: 2px solid var(--rule-strong);
    border-radius: 0;
    background: var(--paper);
    color: var(--ink);
    font: inherit;
    cursor: pointer;
}

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

.search-summary { margin: 16px 0; }
.snippet { color: #555; font-size: 13px; }
mark { background: var(--badge-draft); }

/* ---------- Composer ---------- */

.composer {
    display: grid;
    grid-template-columns: minmax(0, 2fr) minmax(0, 1fr);
    gap: 24px;
    align-items: start;
}

@media (max-width: 900px) { .composer { grid-template-columns: 1fr; } }

.panel {
    border: 2px solid var(--rule-strong);
    background: var(--paper);
    padding: 16px;
    margin-bottom: 24px;
}

.panel h3 {
    margin-top: 0;
    font-size: 16px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.composer label { display: block; margin-bottom: 4px; font-weight: 600; }

.composer input[type=text],
.composer input[type=date],
.composer textarea,
.composer select {
    width: 100%;
    padding: 8px;
    border: 1px solid var(--rule-strong);
    font-family: inherit;
    font-size: 14px;
    box-sizing: border-box;
}

.composer input:focus, .composer textarea:focus, .composer select:focus {
    outline: 2px solid var(--accent);
    outline-offset: -2px;
}

.field { margin-bottom: 16px; }

.body-toolbar { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 6px; }

.body-toolbar button {
    padding: 4px 10px;
    border: 1px solid var(--rule-strong);
    background: #f4f4f4;
    cursor: pointer;
    font-family: inherit;
    font-size: 13px;
}

.body-toolbar button:hover { background: var(--ink); color: #fff; }

#body {
    min-height: 380px;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    line-height: 1.5;
}

#body.is-dragover { outline: 3px dashed var(--accent); outline-offset: -3px; }

.preview {
    border: 1px solid var(--rule);
    padding: 12px;
    min-height: 120px;
    overflow-wrap: anywhere;
}

.preview img { max-width: 100%; height: auto; }

.media-slot { display: flex; gap: 10px; align-items: flex-start; }
.media-slot img { width: 96px; height: 96px; object-fit: cover; border: 1px solid var(--rule); }

.is-featured {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--accent);
}

/* ---------- Media picker ---------- */

/* The composer's "reuse an image" dialog. It lives here rather than in
   cms_edit.html because the rest of the composer already does, and because a
   <dialog> that only styles itself on one page is the kind of thing that gets
   forgotten when the tokens move. */
#media-picker {
    width: min(900px, 92vw);
    border: 2px solid var(--rule-strong);
    padding: 16px;
}

#media-picker::backdrop { background: rgba(0, 0, 0, 0.4); }

.picker-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.picker-search input {
    width: 100%;
    padding: 6px 10px;
    border: 2px solid var(--rule-strong);
    font: inherit;
    margin-bottom: 12px;
}

.picker-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: 10px;
    max-height: 60vh;
    overflow-y: auto;
}

.picker-item {
    border: 1px solid var(--rule);
    background: var(--paper);
    padding: 4px;
    cursor: pointer;
    font: inherit;
    text-align: left;
}

/* Same treatment for hover and focus, so keyboard traversal of the grid is as
   legible as moving a mouse over it. */
.picker-item:hover,
.picker-item:focus {
    border-color: var(--rule-strong);
    outline: none;
}

.picker-item img { width: 100%; height: 90px; object-fit: cover; }
.picker-item span { font-size: 11px; word-break: break-all; color: #555; }

/* ---------- Dashboard cards ---------- */

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

.dashboard-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 20px;
    margin-bottom: 40px;
}

.stat-card {
    background: var(--paper);
    border: 2px solid var(--rule-strong);
    padding: 20px;
    text-align: center;
}

.stat-value { font-size: 40px; font-weight: bold; color: var(--ink); margin-bottom: 10px; }

.stat-label {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--muted);
    margin-bottom: 10px;
}

.stat-link { display: inline-block; margin-top: 10px; color: var(--accent); font-size: 13px; }

.quick-actions {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.action-card { background: var(--paper); border: 2px solid var(--rule-strong); padding: 20px; }

.action-card h3 {
    font-size: 18px;
    margin-bottom: 15px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.action-card p { color: var(--muted); margin-bottom: 15px; line-height: 1.6; }

.action-links { display: flex; gap: 10px; flex-wrap: wrap; }

/* ---------- Utility ---------- */

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}
