/* Admin page styling. Loaded only by admin.html, on top of styles/index.css.
 *
 * Tailwind is on the page via the CDN, so these are @apply-free plain classes
 * that bundle the long utility strings the forms would otherwise repeat on
 * every one of ~40 fields. Colours track the lab palette in
 * scripts/tailwind-config.js - emerald 700 primary, slate everywhere else. */

/* index.css defines .glass-nav for the light theme only, since no other page
 * puts it on a dark background. The admin header does. */
.dark .glass-nav {
    background: rgba(2, 6, 23, 0.92);
    border-bottom-color: rgba(255, 255, 255, 0.06);
}

/* ---------- Panel switcher ---------- */

/* One panel is shown at a time via the `hidden` attribute, and the others stay
 * in the DOM - so a half-filled form survives a trip to another tab and back.
 * The slide is cosmetic, applied to whichever panel has just become visible. */
.admin-panel[hidden] {
    display: none;
}

.admin-panel:not([hidden]) {
    animation: admin-slide-in 0.28s ease-out;
}

@keyframes admin-slide-in {
    from { opacity: 0; transform: translateX(12px); }
    to   { opacity: 1; transform: translateX(0); }
}

@media (prefers-reduced-motion: reduce) {
    .admin-panel:not([hidden]) { animation: none; }
}

.admin-tabs {
    display: flex;
    gap: 0.25rem;
    overflow-x: auto;
    scrollbar-width: none;
}

.admin-tabs::-webkit-scrollbar { display: none; }

.admin-tab {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    font-size: 0.8125rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    white-space: nowrap;
    color: #64748b;
    border-bottom: 2px solid transparent;
    transition: color 0.2s, border-color 0.2s;
}

.admin-tab:hover { color: #047857; }

.admin-tab[aria-selected="true"] {
    color: #047857;
    border-bottom-color: #047857;
}

.dark .admin-tab { color: #94a3b8; }
.dark .admin-tab:hover,
.dark .admin-tab[aria-selected="true"] { color: #34d399; }
.dark .admin-tab[aria-selected="true"] { border-bottom-color: #34d399; }

.admin-count {
    font-size: 0.625rem;
    font-weight: 700;
    padding: 0.125rem 0.375rem;
    border-radius: 9999px;
    background: #f1f5f9;
    color: #64748b;
}

.dark .admin-count { background: #1e293b; color: #94a3b8; }

.admin-tab[aria-selected="true"] .admin-count {
    background: #f0fdf4;
    color: #047857;
}

.dark .admin-tab[aria-selected="true"] .admin-count {
    background: rgba(16, 185, 129, 0.12);
    color: #34d399;
}

/* ---------- Surfaces ---------- */

.admin-card {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 0.75rem;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

.dark .admin-card {
    background: rgba(15, 23, 42, 0.7);
    border-color: #1e293b;
}

.admin-h2 {
    font-family: Merriweather, serif;
    font-size: 1.125rem;
    font-weight: 700;
    color: #0f172a;
}

.dark .admin-h2 { color: #f1f5f9; }

.admin-hint {
    font-size: 0.8125rem;
    line-height: 1.6;
    color: #64748b;
    padding: 0.75rem;
    border-left: 2px solid #047857;
    background: #f8fafc;
    border-radius: 0 0.375rem 0.375rem 0;
}

.dark .admin-hint {
    color: #94a3b8;
    background: rgba(30, 41, 59, 0.5);
    border-left-color: #34d399;
}

/* ---------- Form controls ---------- */

.admin-label {
    display: block;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #475569;
    margin-bottom: 0.375rem;
}

.dark .admin-label { color: #cbd5e1; }

.admin-label-sm {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    font-size: 0.75rem;
    font-weight: 600;
    color: #475569;
    margin-bottom: 0.375rem;
}

.dark .admin-label-sm { color: #cbd5e1; }

.admin-req { color: #dc2626; font-weight: 700; }
.dark .admin-req { color: #f87171; }

.admin-input {
    display: block;
    width: 100%;
    padding: 0.5rem 0.75rem;
    font-size: 0.875rem;
    color: #0f172a;
    background: #ffffff;
    border: 1px solid #cbd5e1;
    border-radius: 0.5rem;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.admin-input::placeholder { color: #94a3b8; }

.admin-input:focus {
    outline: none;
    border-color: #047857;
    box-shadow: 0 0 0 3px rgba(4, 120, 87, 0.12);
}

/* :user-invalid rather than :invalid, so a required field is not flagged red
 * before it has been touched. */
.admin-input:user-invalid {
    border-color: #dc2626;
}

.dark .admin-input {
    color: #f1f5f9;
    background: rgba(2, 6, 23, 0.6);
    border-color: #334155;
}

.dark .admin-input:focus {
    border-color: #34d399;
    box-shadow: 0 0 0 3px rgba(52, 211, 153, 0.15);
}

select.admin-input {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='%2364748b'%3E%3Cpath d='M4.5 6.5 8 10l3.5-3.5z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.5rem center;
    background-size: 1rem;
    padding-right: 2rem;
}

textarea.admin-input { resize: vertical; min-height: 4rem; }

.admin-sub {
    font-size: 0.6875rem;
    line-height: 1.5;
    color: #94a3b8;
    margin-top: 0.3125rem;
}

.dark .admin-sub { color: #64748b; }

.admin-sub-warn {
    display: flex;
    align-items: flex-start;
    gap: 0.375rem;
    color: #b45309;
}

.dark .admin-sub-warn { color: #fbbf24; }

.admin-sub-inline {
    font-size: 0.6875rem;
    font-weight: 500;
    text-transform: none;
    letter-spacing: 0;
    color: #94a3b8;
}

.admin-code {
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 0.9em;
    padding: 0.0625rem 0.25rem;
    border-radius: 0.25rem;
    background: #f1f5f9;
    color: #475569;
}

.dark .admin-code { background: #1e293b; color: #cbd5e1; }

.admin-pre {
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 0.8125rem;
    text-align: left;
    padding: 0.75rem 1rem;
    border-radius: 0.5rem;
    background: #0f172a;
    color: #34d399;
    overflow-x: auto;
}

.admin-check {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.8125rem;
    color: #475569;
    cursor: pointer;
}

.dark .admin-check { color: #cbd5e1; }

.admin-check input[type="checkbox"] {
    width: 1rem;
    height: 1rem;
    accent-color: #047857;
    cursor: pointer;
    flex-shrink: 0;
}

.admin-consent {
    padding: 0.875rem 1rem;
    border-radius: 0.5rem;
    border: 1px dashed #fbbf24;
    background: #fffbeb;
}

.dark .admin-consent {
    border-color: rgba(251, 191, 36, 0.4);
    background: rgba(251, 191, 36, 0.06);
}

.admin-file {
    width: 100%;
    font-size: 0.75rem;
    color: #64748b;
}

.admin-file::file-selector-button {
    margin-right: 0.75rem;
    padding: 0.375rem 0.75rem;
    font-size: 0.75rem;
    font-weight: 600;
    color: #047857;
    background: #f0fdf4;
    border: 1px solid rgba(4, 120, 87, 0.2);
    border-radius: 0.375rem;
    cursor: pointer;
}

.dark .admin-file { color: #94a3b8; }

.dark .admin-file::file-selector-button {
    color: #34d399;
    background: rgba(16, 185, 129, 0.1);
    border-color: rgba(52, 211, 153, 0.25);
}

.admin-details {
    border: 1px solid #e2e8f0;
    border-radius: 0.5rem;
    padding: 0.625rem 0.875rem;
}

.dark .admin-details { border-color: #1e293b; }

.admin-details > summary {
    font-size: 0.8125rem;
    font-weight: 600;
    color: #475569;
    cursor: pointer;
}

.dark .admin-details > summary { color: #cbd5e1; }

/* ---------- Area / tag toggles ---------- */

/* A styled checkbox rather than a multi-select: the areas are few and all
 * worth seeing at once, and a <select multiple> is miserable on a phone. */
.admin-chip {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.3125rem 0.75rem;
    font-size: 0.75rem;
    font-weight: 600;
    border-radius: 9999px;
    border: 1px solid #cbd5e1;
    color: #475569;
    cursor: pointer;
    user-select: none;
    transition: all 0.15s;
}

.admin-chip:hover { border-color: #047857; color: #047857; }

/* The checkbox is hidden but has to stay focusable, so it is taken out of flow
 * rather than display:none'd. `position: relative` on the chip is what keeps it
 * pinned here - without it the input anchors to whatever ancestor happens to be
 * positioned, and all six of them pile up in the same corner of the page. */
.admin-chip input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.admin-chip:has(input:checked) {
    background: #047857;
    border-color: #047857;
    color: #ffffff;
}

.admin-chip:has(input:focus-visible) {
    box-shadow: 0 0 0 3px rgba(4, 120, 87, 0.25);
}

.dark .admin-chip { border-color: #334155; color: #cbd5e1; }
.dark .admin-chip:hover { border-color: #34d399; color: #34d399; }

.dark .admin-chip:has(input:checked) {
    background: #047857;
    border-color: #047857;
    color: #ffffff;
}

/* Without :has() the checked state would have no visual at all, leaving the
 * area picker looking inert. Show the real checkbox instead - plainer, but it
 * tells the truth about what is selected. */
@supports not selector(:has(*)) {
    .admin-chip input {
        position: static;
        opacity: 1;
        pointer-events: auto;
        width: 0.875rem;
        height: 0.875rem;
        accent-color: #047857;
    }
}

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

.admin-btn-primary {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1.25rem;
    font-size: 0.875rem;
    font-weight: 600;
    color: #ffffff;
    background: #047857;
    border-radius: 9999px;
    box-shadow: 0 1px 3px rgba(4, 120, 87, 0.3);
    transition: background 0.2s, transform 0.2s;
}

.admin-btn-primary:hover:not(:disabled) {
    background: #064e3b;
    transform: translateY(-1px);
}

.admin-btn-primary:disabled { opacity: 0.55; cursor: progress; }

.admin-btn-ghost {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.5rem 0.875rem;
    font-size: 0.8125rem;
    font-weight: 500;
    color: #64748b;
    border-radius: 9999px;
    transition: background 0.15s, color 0.15s;
}

.admin-btn-ghost:hover { background: #f1f5f9; color: #0f172a; }

.dark .admin-btn-ghost { color: #94a3b8; }
.dark .admin-btn-ghost:hover { background: #1e293b; color: #f1f5f9; }

.admin-icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.75rem;
    height: 1.75rem;
    border-radius: 0.375rem;
    font-size: 0.875rem;
    color: #94a3b8;
    transition: background 0.15s, color 0.15s;
}

.admin-icon-btn:hover { background: #f1f5f9; color: #047857; }
.admin-icon-btn:disabled { opacity: 0.3; cursor: default; }
.admin-icon-btn:disabled:hover { background: none; color: #94a3b8; }

.admin-icon-btn--danger:hover { background: #fef2f2; color: #dc2626; }

.dark .admin-icon-btn:hover { background: #1e293b; color: #34d399; }
.dark .admin-icon-btn--danger:hover { background: rgba(220, 38, 38, 0.12); color: #f87171; }

/* ---------- Existing-entry lists ---------- */

/* Capped and scrolled: team.json is already 20-odd entries and publications
 * 40-odd, which would otherwise push the form off the screen entirely. */
.admin-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    max-height: 70vh;
    overflow-y: auto;
    padding-right: 0.25rem;
}

.admin-row {
    display: flex;
    align-items: flex-start;
    gap: 0.625rem;
    padding: 0.625rem 0.75rem;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 0.5rem;
    transition: border-color 0.15s;
}

.admin-row:hover { border-color: rgba(4, 120, 87, 0.4); }

.dark .admin-row {
    background: rgba(15, 23, 42, 0.6);
    border-color: #1e293b;
}

.dark .admin-row:hover { border-color: rgba(52, 211, 153, 0.35); }

.admin-row__body { flex: 1; min-width: 0; }

.admin-row__title {
    font-size: 0.8125rem;
    font-weight: 600;
    color: #0f172a;
    line-height: 1.4;
    /* Two lines, then ellipsis - a paper title can run to 20 words. */
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.dark .admin-row__title { color: #f1f5f9; }

.admin-row__meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.375rem;
    margin-top: 0.25rem;
    font-size: 0.6875rem;
    color: #94a3b8;
}

.admin-row__pill {
    font-size: 0.625rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 0.0625rem 0.375rem;
    border-radius: 0.25rem;
    background: #f0fdf4;
    color: #047857;
}

.dark .admin-row__pill { background: rgba(16, 185, 129, 0.12); color: #34d399; }

.admin-row__pill--muted { background: #f1f5f9; color: #64748b; }
.dark .admin-row__pill--muted { background: #1e293b; color: #94a3b8; }

.admin-row__pill--warn { background: #fffbeb; color: #b45309; }
.dark .admin-row__pill--warn { background: rgba(251, 191, 36, 0.12); color: #fbbf24; }

.admin-row__actions {
    display: flex;
    align-items: center;
    gap: 0.125rem;
    flex-shrink: 0;
}

.admin-row--editing {
    border-color: #047857;
    box-shadow: 0 0 0 3px rgba(4, 120, 87, 0.1);
}

.admin-empty {
    padding: 2rem 1rem;
    text-align: center;
    font-size: 0.8125rem;
    color: #94a3b8;
}

/* ---------- Avatars and thumbnails ---------- */

.admin-avatar,
.admin-thumb {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    overflow: hidden;
    background: #f1f5f9;
    color: #cbd5e1;
    font-size: 1.5rem;
}

.dark .admin-avatar,
.dark .admin-thumb { background: #1e293b; color: #475569; }

.admin-avatar {
    width: 4.5rem;
    height: 4.5rem;
    border-radius: 9999px;
    border: 2px solid #e2e8f0;
}

.dark .admin-avatar { border-color: #334155; }

.admin-thumb {
    width: 6rem;
    height: 4.5rem;
    border-radius: 0.5rem;
    border: 1px solid #e2e8f0;
}

.dark .admin-thumb { border-color: #334155; }

.admin-avatar img,
.admin-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* ---------- Toast ---------- */

.admin-toast {
    position: fixed;
    left: 50%;
    bottom: 1.5rem;
    transform: translateX(-50%);
    z-index: 60;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    max-width: min(90vw, 32rem);
    padding: 0.75rem 1.25rem;
    font-size: 0.875rem;
    font-weight: 500;
    border-radius: 9999px;
    box-shadow: 0 10px 25px rgba(15, 23, 42, 0.15);
    animation: admin-toast-in 0.2s ease-out;
}

@keyframes admin-toast-in {
    from { opacity: 0; transform: translate(-50%, 0.75rem); }
    to   { opacity: 1; transform: translate(-50%, 0); }
}

.admin-toast--ok { background: #047857; color: #ffffff; }
.admin-toast--error { background: #b91c1c; color: #ffffff; }
.admin-toast--busy { background: #334155; color: #ffffff; }

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

/* ---------- Backend banner ---------- */

/* Which store a save goes to is the one thing worth stating on every screen:
 * local leaves a diff to review, GitHub commits straight to the branch. The
 * colour carries the distinction even before the sentence is read. */
.admin-banner {
    display: flex;
    align-items: flex-start;
    gap: 0.625rem;
    max-width: 72rem;
    margin: 1rem auto 0;
    padding: 0.75rem 1rem;
    font-size: 0.8125rem;
    line-height: 1.55;
    border-radius: 0.5rem;
    border: 1px solid transparent;
}

.admin-banner > i { font-size: 1.125rem; flex-shrink: 0; margin-top: 0.0625rem; }

.admin-banner--local {
    color: #475569;
    background: #f8fafc;
    border-color: #e2e8f0;
}

.dark .admin-banner--local {
    color: #cbd5e1;
    background: rgba(30, 41, 59, 0.5);
    border-color: #1e293b;
}

/* Amber, not green: a save here is live-ish and unreviewed, which is worth a
 * second's hesitation rather than reassurance. */
.admin-banner--live {
    color: #92400e;
    background: #fffbeb;
    border-color: #fcd34d;
}

.dark .admin-banner--live {
    color: #fbbf24;
    background: rgba(251, 191, 36, 0.08);
    border-color: rgba(251, 191, 36, 0.35);
}

/* Smaller thumbnail for the unused-files list, where the path matters more
 * than the picture. */
.admin-thumb--sm {
    width: 3rem;
    height: 3rem;
    font-size: 1.125rem;
}
