/*
 * Single source of truth for admin-portal styling. Every admin/*.html
 * template (and the navbar fragment) links this instead of declaring its
 * own inline <style> block — change a color/spacing/component here once and
 * it applies everywhere. New admin pages should link this file and reuse
 * these component classes rather than inventing new inline CSS.
 *
 * Served as a static resource at /admin/assets/theme.css. That path (and
 * any future admin static asset placed under the same folder) is explicitly
 * permitted, unauthenticated, in SecurityConfig — the login page itself
 * needs it before a session exists.
 */

:root {
    /* Neutrals */
    --color-bg: #f7f9f8;
    --color-surface: #fff;
    --color-surface-hover: #eef3f1;
    --color-border: #dde5e2;
    --color-text: #12201d;
    --color-text-muted: #4b5f5a;

    /* Brand / accent -- sampled from the app icon (assets/icon.png in
       appUIrepo): purple background, lime wordmark. Accent-2 is the lime,
       reserved for surfaces that need to read as a distinct module (see
       .sub-tabs) rather than duplicating the primary accent everywhere. */
    --color-accent: #5528ac;
    --color-accent-hover: #451f8c;
    --color-accent-focus-ring: rgba(85, 40, 172, 0.15);
    --color-accent-2: #dae727;
    --color-accent-2-text: #12201d;

    /* Motion */
    --transition-fast: 0.15s ease;

    /* Status: success (active users, confirmations) */
    --color-success-bg: #d1fae5;
    --color-success-bg-soft: #ecfdf5;
    --color-success-border: #a7f3d0;
    --color-success-text: #065f46;
    /* Solid button green (Approve, Filter, form submits) -- deliberately
       separate from --color-accent (purple, nav/links/brand) so the default
       primary action reads as "go/confirm" rather than a branded button. */
    --color-success-solid: #059669;
    --color-success-solid-hover: #047857;

    /* Status: danger (inactive/deactivated, destructive actions, errors) */
    --color-danger-bg: #fee2e2;
    --color-danger-bg-soft: #fef2f2;
    --color-danger-border: #f3c8c8;
    --color-danger-text: #991b1b;
    --color-danger-strong: #dc2626;
    --color-danger-strong-hover: #b91c1c;
    --color-danger-link: #b91c1c;

    /* Status: warning (pending/temporary states) */
    --color-warning-bg: #fef3c7;
    --color-warning-bg-soft: #fffbeb;
    --color-warning-border: #fde68a;
    --color-warning-text: #92400e;

    /* Status: elevated privilege (Super Admin / promote) */
    --color-purple-bg: #ede9fe;
    --color-purple-bg-soft: #f5f3ff;
    --color-purple-border: #ddd6fe;
    --color-purple-text: #5b21b6;

    --radius: 6px;
    --radius-sm: 4px;
    --font-family: -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
}

/* ---------- Base ---------- */

body {
    font-family: var(--font-family);
    background: var(--color-bg);
    margin: 0;
    padding: 32px;
    color: var(--color-text);
}

h1 {
    font-size: 20px;
    margin: 0 0 20px;
}

h2 {
    font-size: 15px;
    margin: 0 0 14px;
}

.subtitle {
    color: var(--color-text-muted);
    font-size: 13.5px;
    margin: 0 0 20px;
}

a.back {
    color: var(--color-text-muted);
    text-decoration: none;
    font-size: 13px;
}

a.back:hover {
    text-decoration: underline;
}

.top-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 18px;
}

.section-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.section-head a {
    font-size: 13px;
    color: var(--color-accent-hover);
    text-decoration: none;
}

.section-head a:hover {
    text-decoration: underline;
}

/* Page-level sub-navigation between sibling pages under one navbar entry
   (e.g. word-bank.html's Review Queue / Manage tabs, see
   admin/fragments/word-bank-tabs.html). Deliberately NOT styled like
   .navbar .primary-nav -- a segmented pill control in the lime accent-2
   instead of an underline in the primary accent, so it reads as its own
   contained submodule rather than a second copy of the top nav. */
.sub-tabs {
    display: inline-flex;
    gap: 4px;
    margin-bottom: 24px;
    padding: 4px;
    background: var(--color-surface-hover);
    border: 1px solid var(--color-border);
    border-radius: 999px;
}

.sub-tabs a {
    font-size: 13.5px;
    font-weight: 600;
    color: var(--color-text-muted);
    text-decoration: none;
    padding: 6px 16px;
    border-radius: 999px;
    transition: color var(--transition-fast), background-color var(--transition-fast);
}

.sub-tabs a:hover {
    color: var(--color-text);
}

.sub-tabs a.active {
    color: var(--color-accent-2-text);
    background: var(--color-accent-2);
}

/* ---------- Focus states ---------- */
/* :focus-visible (not plain :focus) so mouse clicks don't show a ring, only
   keyboard/assistive-tech navigation does. Buttons/links get an outline;
   text inputs get a border+glow instead since an outline would clip against
   their own border. Applies portal-wide — no per-page overrides needed. */

a:focus-visible,
button:focus-visible,
.btn:focus-visible,
.icon-btn:focus-visible {
    outline: 2px solid var(--color-accent);
    outline-offset: 2px;
}

input:focus-visible,
select:focus-visible,
textarea:focus-visible {
    outline: none;
    border-color: var(--color-accent);
    box-shadow: 0 0 0 3px var(--color-accent-focus-ring);
}

/* ---------- Auth (login) page ---------- */
/* The only page that isn't a normal signed-in admin page (no navbar, no
   session), so it gets its own full-viewport centered layout instead of the
   standard top-padded flow above. */

body.auth-page {
    margin: 0;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background:
        radial-gradient(circle at 50% 0%, rgba(13, 148, 136, 0.14) 0%, rgba(13, 148, 136, 0) 55%),
        linear-gradient(160deg, #eef7f5 0%, #f7f9f8 45%, #eef3f1 100%);
}

.auth-page .card {
    width: 320px;
    box-shadow: 0 12px 32px rgba(18, 32, 29, 0.08);
}

.auth-page .brand {
    margin: 0 0 4px;
}

.auth-page .brand img {
    height: 68px;
    width: auto;
    display: block;
}

.auth-page h1 {
    font-size: 14px;
    font-weight: 600;
    color: var(--color-text-muted);
    margin: 0 0 20px;
}

/* ---------- Cards ---------- */

.card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 24px;
    max-width: 480px;
    box-shadow: 0 1px 3px rgba(18, 32, 29, 0.06);
}

/* Full-width sibling of .card -- for a page built from stacked control-panel
   sections (e.g. word-bank-manage.html) rather than one narrow auth/profile
   card, where .card's 480px cap would squash a table or a wide checkbox
   grid down to a single column. */
.card.wide {
    max-width: none;
    box-sizing: border-box;
    margin-bottom: 20px;
}

.card.wide:last-child {
    margin-bottom: 0;
}

.card.wide .section-head {
    margin-bottom: 4px;
}

.card.wide h2 {
    margin-bottom: 4px;
}

dl {
    margin: 0 0 20px;
}

dt {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--color-text-muted);
    margin-top: 12px;
}

dt:first-child {
    margin-top: 0;
}

dd {
    margin: 2px 0 0;
    font-size: 15px;
}

.danger-zone {
    margin-top: 28px;
    padding-top: 20px;
    border-top: 1px dashed var(--color-border);
}

.danger-zone p {
    font-size: 12.5px;
    color: var(--color-text-muted);
    margin: 0 0 10px;
}

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

label {
    display: block;
    font-size: 13px;
    color: var(--color-text-muted);
    margin-bottom: 4px;
}

input,
select {
    padding: 8px 10px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    font-size: 14px;
    background: var(--color-surface);
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

input[type="text"],
input[type="password"],
input[type="search"] {
    width: 100%;
    margin-bottom: 14px;
    box-sizing: border-box;
}

input[type="search"] {
    width: 260px;
    margin-bottom: 0;
}

textarea.reason-field {
    display: block;
    width: 100%;
    box-sizing: border-box;
    margin-bottom: 10px;
    padding: 8px 10px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-family: inherit;
    resize: vertical;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

form.search {
    margin-bottom: 18px;
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.hint {
    color: var(--color-text-muted);
    font-size: 13px;
    margin: 0 0 18px;
}

.hint.tight {
    margin: -8px 0 14px;
    font-size: 12px;
}

/* Word-bank "generate now" category picker -- a grid of checkbox labels
   rather than a <select multiple>, since ticking several plain checkboxes is
   easier to scan/select from at a glance than a scrollbox multi-select. */
.checkbox-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 8px 16px;
    margin-bottom: 16px;
}

.checkbox-grid label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    color: var(--color-text);
    margin-bottom: 0;
}

/* Pill-styled variant of a .checkbox-grid label -- word-bank's "generate
   now" category picker uses this instead of a bare checkbox+text pair, so a
   selected category reads as a distinct, tappable chip rather than blending
   into the row. :has() is fine here (2026, evergreen-browser admin tool). */
.category-chip {
    padding: 7px 14px;
    border: 1px solid var(--color-border);
    border-radius: 999px;
    background: var(--color-surface);
    transition: background-color var(--transition-fast), border-color var(--transition-fast), color var(--transition-fast);
}

.category-chip:hover {
    background: var(--color-surface-hover);
}

.category-chip:has(input:checked) {
    background: var(--color-success-bg-soft);
    border-color: var(--color-accent);
    color: var(--color-accent-hover);
    font-weight: 600;
}

.category-chip input {
    margin: 0;
}

/* Word-bank settings table's per-category phrase-count input -- narrow on
   purpose, it only ever holds a small number, not free text. */
.tier-input {
    width: 70px;
}

/* Tier distribution table (word-bank-manage.html) -- a 0 count gets a
   warning tint so a category with nothing servable at some tier is visible
   at a glance, not something you'd have to notice by scanning numbers. */
.tier-empty {
    color: var(--color-danger-text);
    background: var(--color-danger-bg-soft);
    font-weight: 600;
}

.total-col {
    font-weight: 600;
}

/* Word-bank manage page's schedule-interval field -- a labeled number input
   sitting inline rather than stacked, since "Run automatically every [ 36 ]
   hours" reads as one sentence, not a form field with a separate label row. */
.interval-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 16px;
}

.interval-row label,
.interval-row span {
    margin-bottom: 0;
}

.interval-row input {
    width: 80px;
    margin-bottom: 0;
}

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

button,
.btn {
    padding: 9px 16px;
    background: var(--color-success-solid);
    color: #fff;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 14px;
    cursor: pointer;
    text-decoration: none;
    display: inline-block;
    transition: background-color var(--transition-fast), border-color var(--transition-fast), color var(--transition-fast);
}

button:hover,
.btn:hover {
    background: var(--color-success-solid-hover);
}

button:disabled,
.btn:disabled {
    background: var(--color-surface-hover);
    color: var(--color-text-muted);
    cursor: not-allowed;
}

.btn-full {
    display: block;
    width: 100%;
    box-sizing: border-box;
    text-align: center;
}

.btn.secondary {
    background: var(--color-surface);
    color: var(--color-accent-hover);
    border: 1px solid var(--color-border);
}

.btn.secondary:hover {
    background: var(--color-surface-hover);
}

.btn.danger {
    background: var(--color-surface);
    color: var(--color-danger-link);
    border: 1px solid var(--color-danger-border);
}

.btn.danger:hover {
    background: var(--color-danger-bg-soft);
}

.btn.promote {
    background: var(--color-surface);
    color: var(--color-purple-text);
    border: 1px solid var(--color-purple-border);
}

.btn.promote:hover {
    background: var(--color-purple-bg-soft);
}

.deactivate {
    background: var(--color-danger-strong);
    color: #fff;
}

.deactivate:hover {
    background: var(--color-danger-strong-hover);
}

.reactivate {
    background: var(--color-accent);
    color: #fff;
}

.reactivate:hover {
    background: var(--color-accent-hover);
}

.hard-delete {
    background: var(--color-surface);
    color: var(--color-danger-text);
    border: 1.5px solid var(--color-danger-text);
}

.hard-delete:hover {
    background: var(--color-danger-text);
    color: #fff;
}

.icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--color-border);
    color: var(--color-accent-hover);
    background: var(--color-surface);
    text-decoration: none;
    transition: background-color var(--transition-fast);
}

.icon-btn:hover {
    background: var(--color-surface-hover);
}

.icon-btn svg {
    width: 16px;
    height: 16px;
}

/* ---------- Alerts (error / success / notice) ---------- */
/* One consistent "alert panel" look everywhere, whether it's a full-page
   flash message (Admins page) or a single line under a form (login,
   password reset). */

.error,
.success,
.notice {
    border-radius: var(--radius);
    padding: 12px 16px;
    font-size: 14px;
    margin-bottom: 18px;
    max-width: 480px;
    border: 1px solid transparent;
}

.error {
    background: var(--color-danger-bg-soft);
    color: var(--color-danger-text);
    border-color: var(--color-danger-border);
}

.success {
    background: var(--color-success-bg-soft);
    color: var(--color-success-text);
    border-color: var(--color-success-border);
}

.notice {
    background: var(--color-success-bg-soft);
    color: var(--color-success-text);
    border-color: var(--color-success-border);
}

.forced-notice {
    background: var(--color-warning-bg-soft);
    color: var(--color-warning-text);
    border: 1px solid var(--color-warning-border);
    border-radius: var(--radius);
    padding: 12px 16px;
    font-size: 14px;
    margin-bottom: 18px;
    max-width: 480px;
}

.credential {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 8px;
}

.credential code {
    background: var(--color-surface);
    border: 1px solid var(--color-success-border);
    border-radius: var(--radius-sm);
    padding: 6px 10px;
    font-size: 14px;
    letter-spacing: 0.02em;
}

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

table {
    width: 100%;
    border-collapse: collapse;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(18, 32, 29, 0.06);
}

th,
td {
    text-align: left;
    padding: 10px 14px;
    border-bottom: 1px solid var(--color-border);
    font-size: 14px;
}

th {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--color-text-muted);
    background: var(--color-surface-hover);
}

tr:last-child td {
    border-bottom: none;
}

tbody tr {
    transition: background-color var(--transition-fast);
}

tbody tr:hover {
    background: var(--color-surface-hover);
}

td.sno {
    color: var(--color-text-muted);
    width: 48px;
}

/* users.html's single icon-link column — not the same thing as .actions
   below (admins.html's multi-button row); kept as a distinct class so the
   two don't collide now that both pages share one stylesheet. */
td.col-icon {
    width: 48px;
}

.actions {
    display: flex;
    gap: 8px;
}

/* Word-bank review table's bulk approve/reject bar -- sits above the table,
   same idea as .actions' row-level button group but for a whole selection
   rather than one row. */
.bulk-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 14px;
}

.actions form {
    margin: 0;
}

td.when {
    color: var(--color-text-muted);
    white-space: nowrap;
}

.you {
    color: var(--color-text-muted);
    font-size: 12px;
}

.empty {
    color: var(--color-text-muted);
    font-size: 14px;
    padding: 20px;
    text-align: center;
}

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

.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    background: var(--color-surface-hover);
    color: var(--color-text);
    margin-right: 6px;
}

.badge:last-child {
    margin-right: 0;
}

.badge.active {
    background: var(--color-success-bg);
    color: var(--color-success-text);
}

.badge.inactive {
    background: var(--color-danger-bg);
    color: var(--color-danger-text);
}

.badge.super {
    background: var(--color-purple-bg);
    color: var(--color-purple-text);
}

.badge.pending {
    background: var(--color-warning-bg);
    color: var(--color-warning-text);
}

/* ---------- Pagination ---------- */

.pagination {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 16px;
    font-size: 13px;
    color: var(--color-text-muted);
}

.pagination .pager-controls {
    display: flex;
    align-items: center;
    gap: 10px;
}

.pagination a.page-btn,
.pagination span.page-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--color-border);
    color: var(--color-text);
    text-decoration: none;
    transition: background-color var(--transition-fast);
}

.pagination a.page-btn:hover {
    background: var(--color-surface-hover);
}

.pagination span.page-btn.disabled {
    color: #b7c2be;
    cursor: default;
}

.pagination .page-btn svg {
    width: 16px;
    height: 16px;
}

/* ---------- Dashboard stat cards ---------- */
/* Reusable beyond the dashboard for any future "at a glance" summary row. */

.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 14px;
    margin-bottom: 32px;
}

.stat-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 18px;
    box-shadow: 0 1px 3px rgba(18, 32, 29, 0.06);
}

.stat-card .value {
    font-size: 26px;
    font-weight: 800;
    color: var(--color-text);
}

.stat-card .value.active {
    color: var(--color-success-text);
}

.stat-card .value.inactive {
    color: var(--color-danger-text);
}

.stat-card .label {
    font-size: 12.5px;
    color: var(--color-text-muted);
    margin-top: 4px;
}

/* ---------- Navbar ---------- */
/* Shared top bar included via admin/fragments/navbar.html on every
   signed-in page. */

.navbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 32px;
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    margin: -32px -32px 28px;
    position: relative;
}

.navbar .left {
    display: flex;
    align-items: center;
    gap: 28px;
}

.navbar .brand {
    display: flex;
    align-items: center;
    text-decoration: none;
}

.navbar .brand img {
    height: 52px;
    width: auto;
    display: block;
}

.navbar .primary-nav {
    display: flex;
    align-items: center;
    gap: 18px;
}

.navbar .primary-nav a {
    font-size: 13.5px;
    font-weight: 600;
    color: var(--color-text-muted);
    text-decoration: none;
    padding: 4px 0;
    border-bottom: 2px solid transparent;
    transition: color var(--transition-fast), border-color var(--transition-fast);
}

.navbar .primary-nav a:hover {
    color: var(--color-text);
}

.navbar .primary-nav a.active {
    color: var(--color-accent);
    border-bottom-color: var(--color-accent);
}

.navbar .account {
    position: relative;
}

.navbar .account-trigger {
    display: flex;
    align-items: center;
    gap: 6px;
    background: none;
    border: none;
    padding: 6px 8px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 13.5px;
    color: var(--color-text);
    font-weight: 600;
    transition: background-color var(--transition-fast);
}

.navbar .account-trigger:hover {
    background: var(--color-surface-hover);
}

.navbar .account-trigger svg.person {
    width: 15px;
    height: 15px;
    color: var(--color-text-muted);
}

.navbar .account-trigger svg.chevron {
    width: 12px;
    height: 12px;
    color: var(--color-text-muted);
    transition: transform 0.15s ease;
}

.navbar .account-trigger[aria-expanded="true"] svg.chevron {
    transform: rotate(180deg);
}

.navbar .account-menu {
    display: none;
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    box-shadow: 0 8px 20px rgba(18, 32, 29, 0.10);
    min-width: 200px;
    overflow: hidden;
    z-index: 20;
}

.navbar .account-menu.open {
    display: block;
}

.navbar .account-menu-form {
    margin: 0;
}

.navbar .account-menu-item {
    display: flex;
    align-items: center;
    gap: 9px;
    width: 100%;
    box-sizing: border-box;
    padding: 10px 14px;
    font-size: 13.5px;
    color: var(--color-text);
    text-decoration: none;
    background: none;
    border: none;
    text-align: left;
    cursor: pointer;
    font-family: inherit;
    transition: background-color var(--transition-fast);
}

.navbar .account-menu-item:hover {
    background: var(--color-surface-hover);
}

.navbar .account-menu-item svg {
    width: 15px;
    height: 15px;
    color: var(--color-text-muted);
    flex-shrink: 0;
}

.navbar .account-menu-item.logout {
    color: var(--color-danger-link);
    border-top: 1px solid var(--color-border);
}

.navbar .account-menu-item.logout svg {
    color: var(--color-danger-link);
}
