/* ==========================================================================
   Angel Finder admin dashboard (admin.html)
   Builds on style.css: same cream paper, white cards, sage accent and
   Playfair headings as the app.
   ========================================================================== */

.admin-page .header-logo { text-decoration: none; color: inherit; }
.admin-tag {
    font-size: var(--fs-xs);
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--sage);
    background: var(--sage-50);
    border: 1px solid rgba(79, 102, 80, 0.18);
    border-radius: 999px;
    padding: 3px 9px;
}
.admin-page .header-actions { display: flex; gap: 8px; align-items: center; }
.admin-page .header-actions a.btn { text-decoration: none; }

@media (min-width: 1100px) {
    .admin-container { max-width: 1240px; }
}

.admin-view { display: none; }
.admin-view.active { display: block; animation: admin-fade 0.25s ease; }
@keyframes admin-fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

.admin-message { max-width: 560px; margin: 40px auto; text-align: center; }
.admin-message h2 { margin-bottom: 10px; }
.admin-message code { background: var(--sage-50); padding: 1px 6px; border-radius: 6px; font-size: 0.9em; }
.admin-signin-card { max-width: 440px; margin: 40px auto; }
.admin-signin-card h2 { margin-bottom: 6px; }
.admin-signin-card > p { margin-bottom: 20px; }
.admin-wide { width: 100%; }
.admin-error { color: var(--error); font-size: var(--fs-sm); min-height: 1.2em; margin-bottom: 10px; }

/* Title row */
.admin-title {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 18px;
}
.admin-title h2 { font-size: var(--fs-2xl); }
.admin-title p { font-size: var(--fs-sm); margin-top: 2px; }

/* Tabs: same segmented look as the app's memorial tabs */
.admin-tabs {
    display: flex;
    gap: 4px;
    padding: 4px;
    background: rgba(122, 110, 96, 0.08);
    border-radius: 999px;
    margin-bottom: 20px;
    overflow-x: auto;
    scrollbar-width: none;
    position: sticky;
    top: calc(64px + var(--safe-top));
    z-index: 50;
    backdrop-filter: saturate(1.4) blur(14px);
    -webkit-backdrop-filter: saturate(1.4) blur(14px);
}
.admin-tabs::-webkit-scrollbar { display: none; }
.admin-tab {
    flex: 1 0 auto;
    border: none;
    background: transparent;
    font: 600 var(--fs-sm) var(--font-sans);
    color: var(--muted);
    padding: 10px 16px;
    min-height: 40px;
    border-radius: 999px;
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
}
.admin-tab:hover { color: var(--ink); }
.admin-tab.active { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(43, 37, 32, 0.08), 0 4px 10px -4px rgba(43, 37, 32, 0.15); }
.admin-tab:focus-visible, .chip:focus-visible { outline: 3px solid rgba(79, 102, 80, 0.35); outline-offset: 2px; }

.admin-panel { display: none; }
.admin-panel.active { display: block; animation: admin-fade 0.2s ease; }

.admin-cols { display: grid; gap: 16px; grid-template-columns: 1fr; }
.admin-cols > .card { margin-bottom: 0; }
.admin-cols + .admin-cols { margin-top: 16px; }
@media (min-width: 860px) { .admin-cols { grid-template-columns: 1fr 1fr; } }
.admin-panel .card h3 { margin-bottom: 2px; }
.admin-section-title { margin: 28px 0 12px; font-size: var(--fs-xl); }
.admin-note { margin-bottom: 14px; font-size: var(--fs-sm); }

/* KPI tiles */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    margin-bottom: 16px;
}
@media (min-width: 700px) { .kpi-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (min-width: 1100px) { .kpi-grid { grid-template-columns: repeat(6, minmax(0, 1fr)); } }
.kpi-tile {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 16px 18px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
}
.kpi-label { font-size: var(--fs-xs); font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.kpi-value { font-family: var(--font-serif); font-size: var(--fs-2xl); font-weight: 600; color: var(--ink); line-height: 1.1; font-variant-numeric: tabular-nums; }
.kpi-sub { font-size: var(--fs-xs); color: var(--muted); }

/* Bar charts: one series, sage, recessive grid */
.chart-card .bar-chart { margin-top: 12px; }
.bar-chart svg { width: 100%; height: auto; display: block; overflow: visible; }
.chart-grid { stroke: rgba(60, 53, 45, 0.08); stroke-width: 1; }
.chart-baseline { stroke: rgba(60, 53, 45, 0.25); stroke-width: 1; }
.chart-axis { fill: var(--muted); font: 500 11px var(--font-sans); font-variant-numeric: tabular-nums; }
.chart-bar path { fill: var(--sage); transition: fill 0.15s ease; }
.chart-bar.hover path { fill: var(--sage-600); }
.chart-bar.hover .chart-hit { fill: rgba(79, 102, 80, 0.07); }
.chart-hit { fill: transparent; cursor: crosshair; }
.chart-total { font-size: var(--fs-sm); color: var(--ink-2); margin-top: 6px; }
.chart-tip {
    position: fixed;
    z-index: 1200;
    pointer-events: none;
    background: var(--ink);
    color: #fff;
    font-size: var(--fs-xs);
    font-weight: 500;
    padding: 6px 10px;
    border-radius: 8px;
    box-shadow: 0 6px 16px -6px rgba(0, 0, 0, 0.4);
    opacity: 0;
    transition: opacity 0.12s ease;
    white-space: nowrap;
}
.chart-tip.visible { opacity: 1; }

/* Share-of-total meters */
.meter-list { display: flex; flex-direction: column; gap: 14px; margin-top: 14px; }
.meter-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; font-size: var(--fs-sm); color: var(--ink-2); margin-bottom: 6px; }
.meter-num { font-weight: 600; color: var(--ink); font-variant-numeric: tabular-nums; }
.meter-num small { color: var(--muted); font-weight: 500; margin-left: 4px; }
.meter-track { height: 8px; background: rgba(122, 110, 96, 0.1); border-radius: 999px; overflow: hidden; }
.meter-fill { height: 100%; background: var(--sage); border-radius: 999px; transition: width 0.5s ease; }

/* Status and role pills: text label plus symbol, never colour alone */
.status-pill, .role-pill {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: var(--fs-xs);
    font-weight: 600;
    padding: 4px 10px;
    border-radius: 999px;
    border: 1px solid var(--line);
    background: rgba(122, 110, 96, 0.08);
    color: var(--ink-2);
    white-space: nowrap;
}
.status-open { background: #fdf3e2; color: #8a5a12; border-color: rgba(183, 121, 31, 0.25); }
.status-accepted { background: #eaf0f6; color: #34536f; border-color: rgba(52, 83, 111, 0.2); }
.status-completed { background: var(--sage-50); color: var(--sage-600); border-color: rgba(79, 102, 80, 0.22); }
.status-cancelled { background: rgba(122, 110, 96, 0.08); color: var(--muted); }
.role-waiting { background: #fdf3e2; color: #8a5a12; border-color: rgba(183, 121, 31, 0.25); }
.role-admin { background: var(--sage-50); color: var(--sage-600); border-color: rgba(79, 102, 80, 0.22); }
.privacy-public { background: #fdf3e2; color: #8a5a12; border-color: rgba(183, 121, 31, 0.25); }
.privacy-private { background: #f7ebe9; color: #8c4b42; border-color: rgba(201, 139, 130, 0.3); }

/* Toolbars and filters */
.admin-toolbar { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 14px; align-items: center; }
.admin-search { max-width: 360px; }
.chip-row { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
    border: 1px solid var(--line);
    background: var(--surface);
    color: var(--ink-2);
    font: 600 var(--fs-sm) var(--font-sans);
    padding: 8px 14px;
    min-height: 38px;
    border-radius: 999px;
    cursor: pointer;
    transition: var(--transition);
}
.chip:hover { border-color: rgba(79, 102, 80, 0.35); }
.chip.active { background: var(--sage); border-color: var(--sage); color: #fff; }

.btn-danger-soft { background: #fbefed; color: #9a4a3f; border: 1px solid rgba(200, 107, 93, 0.3); }
.btn-danger-soft:hover { background: #f6e0dc; }

/* Lists of cards */
.admin-list { display: grid; gap: 12px; grid-template-columns: 1fr; }
@media (min-width: 900px) { .admin-list { grid-template-columns: 1fr 1fr; } }
.admin-list > .card { margin-bottom: 0; padding: 18px 20px; }
.admin-empty { text-align: center; color: var(--muted); grid-column: 1 / -1; }

.job-head { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; margin-bottom: 12px; }
.job-head h4 { font-size: var(--fs-lg); }
.job-head p { font-size: var(--fs-sm); }
.job-facts { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 16px; margin: 0; }
.job-facts dt { font-size: var(--fs-xs); color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; }
.job-facts dd { margin: 2px 0 0; font-size: var(--fs-sm); color: var(--ink-2); overflow-wrap: anywhere; }
.job-facts a, .admin-table a { color: var(--sage-600); }
.job-notes { margin-top: 12px; font-size: var(--fs-sm); font-style: italic; color: var(--ink-2); background: var(--paper); border-radius: var(--radius-sm); padding: 10px 12px; }
.job-photos { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 12px; }
.job-photos a { position: relative; display: block; border-radius: var(--radius-sm); overflow: hidden; aspect-ratio: 4 / 3; background: var(--sage-50); }
.job-photos img { width: 100%; height: 100%; object-fit: cover; display: block; }
.job-photos span { position: absolute; left: 8px; bottom: 8px; background: rgba(43, 37, 32, 0.7); color: #fff; font-size: var(--fs-xs); font-weight: 600; padding: 2px 8px; border-radius: 999px; }
.job-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line); }

.story-meta { display: flex; flex-direction: column; gap: 2px; font-size: var(--fs-sm); color: var(--ink-2); }
.story-meta .text-secondary { font-size: var(--fs-xs); }
.story-body { font-family: var(--font-serif); font-size: var(--fs-base); color: var(--ink); margin: 10px 0 12px; white-space: pre-wrap; overflow-wrap: anywhere; }
.story-foot { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }

/* Tables: rows on tablets and desktops, stacked cards on phones */
.table-card { padding: 4px 0; overflow: hidden; }
.admin-table { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
.admin-table th {
    text-align: left;
    font-size: var(--fs-xs);
    font-weight: 600;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--muted);
    padding: 12px 14px;
    border-bottom: 1px solid var(--line);
    white-space: nowrap;
}
.admin-table td { padding: 12px 14px; border-bottom: 1px solid var(--line); color: var(--ink-2); vertical-align: middle; overflow-wrap: anywhere; }
.admin-table tbody tr:last-child td { border-bottom: none; }
.admin-table tbody tr:hover td { background: rgba(238, 242, 236, 0.5); }
.admin-table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.admin-table small { color: var(--muted); }
.row-actions { text-align: right; white-space: nowrap; }
.admin-empty-cell { text-align: center; color: var(--muted); padding: 28px 14px !important; }

@media (max-width: 760px) {
    .admin-table thead { display: none; }
    .admin-table, .admin-table tbody, .admin-table tr, .admin-table td { display: block; width: 100%; }
    .admin-table tr { padding: 12px 16px; border-bottom: 1px solid var(--line); }
    .admin-table tbody tr:last-child { border-bottom: none; }
    .admin-table td { border: none; padding: 3px 0; display: flex; justify-content: space-between; gap: 12px; text-align: right; }
    .admin-table td[data-label]::before { content: attr(data-label); color: var(--muted); font-size: var(--fs-xs); font-weight: 600; text-align: left; flex-shrink: 0; }
    .admin-table td:first-child { display: block; text-align: left; font-size: var(--fs-base); padding-bottom: 6px; }
    .admin-table td:first-child::before { display: none; }
    .admin-table .num { text-align: right; }
    .row-actions { padding-top: 8px !important; justify-content: flex-start !important; }
    .admin-table tbody tr:hover td { background: none; }
    .admin-title h2 { font-size: var(--fs-xl); }
    .admin-tabs { top: calc(60px + var(--safe-top)); }
}
@media (max-width: 420px) {
    .job-facts { grid-template-columns: 1fr; }
    .admin-page .header-actions a.btn { display: none; }
    .admin-page .header-logo h1 { font-size: 1.05rem; }
}

@media (prefers-reduced-motion: reduce) {
    .admin-view.active, .admin-panel.active { animation: none; }
    .meter-fill { transition: none; }
}

/* People: profile picture and username */
.person-cell { display: flex; align-items: center; gap: 10px; }
.person-avatar {
    flex: none; width: 34px; height: 34px; border-radius: 999px; object-fit: cover;
    background: var(--sage-50, #eef2ec); color: var(--sage, #5a6e5b);
    display: inline-flex; align-items: center; justify-content: center; font-weight: 700;
}

/* Second sign-in step: QR code for the authenticator app */
.admin-mfa-setup { text-align: center; margin-bottom: 16px; }
.admin-mfa-qr { width: 200px; height: 200px; background: #fff; border-radius: 12px; padding: 8px; }
.admin-mfa-setup code { word-break: break-all; }

/* "Show more" under a list that loads one page at a time. */
.admin-more {
    display: block;
    margin: 12px auto 0;
}
.admin-more[hidden] {
    display: none;
}
