/*
    site.css
    UKGI Group Internal Resources: design system.

    Purpose: one stylesheet for the whole site. Tokens (colour, type, spacing,
    radius, shadow) on :root, a dark theme via prefers-color-scheme, the app
    shell (sidebar, top bar, content), and the handful of components every
    page uses. Pages carry no styling of their own beyond small layout tweaks.

    Brand: navy #0B2A45 / #004775 with the light-blue accent #28ABE3 carried
    over from the earlier site.
*/

@import url("https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap");

:root {
    --brand: #004775;
    --brand-deep: #0B2A45;
    --accent: #28ABE3;
    --accent-soft: rgba(40, 171, 227, 0.14);

    --bg: #F3F5F8;
    --surface: #FFFFFF;
    --surface-2: #F7F9FB;
    --ink: #14202B;
    --ink-2: #4A5866;
    --muted: #7B8794;
    --line: #E3E8EE;

    --ok: #1E7F4F;
    --ok-soft: #E4F5EC;
    --warn: #8A5B00;
    --warn-soft: #FFF3D6;
    --danger: #B3261E;
    --danger-soft: #FCE8E6;
    --info-soft: #E6F2FB;

    --sidebar-bg: #0B2A45;
    --sidebar-ink: #C9D6E2;
    --sidebar-ink-strong: #FFFFFF;
    --sidebar-hover: rgba(255, 255, 255, 0.06);
    --sidebar-active: rgba(40, 171, 227, 0.18);

    --radius: 12px;
    --radius-sm: 8px;
    --shadow: 0 1px 2px rgba(20, 32, 43, 0.06), 0 8px 24px rgba(20, 32, 43, 0.06);
    --shadow-lg: 0 12px 40px rgba(20, 32, 43, 0.18);
    --sidebar-w: 248px;
    --topbar-h: 64px;
    --font: "Inter", "Segoe UI", system-ui, sans-serif;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #0F171F;
        --surface: #161F29;
        --surface-2: #1C2733;
        --ink: #E8EEF3;
        --ink-2: #B4C0CC;
        --muted: #8593A0;
        --line: #26323E;
        --ok-soft: rgba(30, 127, 79, 0.22);
        --warn-soft: rgba(138, 91, 0, 0.24);
        --danger-soft: rgba(179, 38, 30, 0.22);
        --info-soft: rgba(40, 171, 227, 0.16);
        --sidebar-bg: #0A1520;
        --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px rgba(0, 0, 0, 0.3);
    }
}

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: var(--font); font-size: 15px; line-height: 1.5; color: var(--ink); background: var(--bg); }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -0.01em; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.05rem; }
h3 { font-size: 0.95rem; }
p { margin: 0 0 0.75rem; }
.muted { color: var(--muted); }
.empty { color: var(--muted); font-style: italic; }
.hidden { display: none !important; }

/* ---------- shell ---------- */
.shell { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100vh; }

.sidebar {
    background: var(--sidebar-bg); color: var(--sidebar-ink);
    display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh;
}
.sidebar .brand { display: flex; align-items: center; gap: 0.75rem; padding: 1.25rem 1.25rem 1rem; color: var(--sidebar-ink-strong); text-decoration: none; }
.sidebar .brand .mark { width: 36px; height: 36px; border-radius: 10px; background: linear-gradient(135deg, var(--accent), #1B7FC1); display: grid; place-items: center; font-weight: 700; font-size: 0.85rem; color: #fff; letter-spacing: 0.02em; }
.sidebar .brand .name { font-weight: 600; font-size: 0.95rem; line-height: 1.2; }
.sidebar .brand .name small { display: block; font-weight: 400; font-size: 0.75rem; color: var(--sidebar-ink); }

.nav { padding: 0.5rem 0.75rem; flex: 1; overflow-y: auto; }
.nav .label { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); padding: 0.75rem 0.75rem 0.35rem; }
.nav a { display: flex; align-items: center; gap: 0.7rem; padding: 0.55rem 0.75rem; border-radius: var(--radius-sm); color: var(--sidebar-ink); font-weight: 500; font-size: 0.92rem; text-decoration: none; transition: background 0.12s, color 0.12s; }
.nav a:hover { background: var(--sidebar-hover); color: var(--sidebar-ink-strong); text-decoration: none; }
.nav a.active { background: var(--sidebar-active); color: var(--sidebar-ink-strong); }
.nav a.active svg { color: var(--accent); }
.nav svg { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.sidebar .user { border-top: 1px solid rgba(255, 255, 255, 0.08); padding: 0.9rem 1.25rem; display: flex; align-items: center; gap: 0.7rem; }
.sidebar .avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; font-weight: 600; font-size: 0.8rem; flex: none; }
.sidebar .user .who { min-width: 0; flex: 1; }
.sidebar .user .who strong { display: block; color: var(--sidebar-ink-strong); font-weight: 600; font-size: 0.88rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar .user .who span { font-size: 0.75rem; color: var(--sidebar-ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; }
.sidebar .user a.signout { color: var(--sidebar-ink); display: grid; place-items: center; padding: 0.35rem; border-radius: var(--radius-sm); }
.sidebar .user a.signout:hover { background: var(--sidebar-hover); color: var(--sidebar-ink-strong); }
.sidebar .user a.signout svg { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.content { min-width: 0; }
.topbar { height: var(--topbar-h); display: flex; align-items: center; gap: 1rem; padding: 0 2rem; background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.topbar .crumbs { font-size: 0.85rem; color: var(--muted); }
.topbar .crumbs a { color: var(--muted); }
.topbar h1 { font-size: 1.15rem; }
.topbar .spacer { flex: 1; }
.topnav { display: flex; gap: 0.4rem; }
.topnav a { display: inline-flex; align-items: center; gap: 0.35rem; padding: 0.4rem 0.75rem; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface); color: var(--ink); font-size: 0.85rem; font-weight: 500; text-decoration: none; }
.topnav a:hover { background: var(--surface-2); text-decoration: none; }
.topnav svg { width: 15px; height: 15px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.menu-btn { display: none; background: none; border: 0; padding: 0.4rem; color: var(--ink); cursor: pointer; }
.menu-btn svg { width: 22px; height: 22px; stroke: currentColor; fill: none; stroke-width: 2; }

main { padding: 1.75rem 2rem 3rem; }  /* full width; tables are the main content and benefit from the room */

/* ---------- components ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.25rem 1.5rem; box-shadow: var(--shadow); }
.card + .card, .section + .section { margin-top: 1.25rem; }
.section-title { display: flex; align-items: baseline; gap: 0.75rem; margin: 1.75rem 0 0.75rem; }
.section-title h2 { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); font-weight: 600; }

.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 0.9rem; }
.tile { display: flex; flex-direction: column; gap: 0.6rem; padding: 1.1rem 1.2rem; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); color: var(--ink); text-decoration: none; transition: transform 0.12s, box-shadow 0.12s, border-color 0.12s; }
.tile:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); border-color: var(--accent); text-decoration: none; }
.tile .icon { width: 38px; height: 38px; border-radius: 10px; background: var(--accent-soft); color: var(--brand); display: grid; place-items: center; }
.tile .icon svg { width: 20px; height: 20px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.tile strong { font-weight: 600; }
.tile span { font-size: 0.82rem; color: var(--muted); }
.tile.disabled { opacity: 0.55; pointer-events: none; }

.hero { background: linear-gradient(135deg, var(--brand-deep), var(--brand) 60%, #1B7FC1); color: #fff; border-radius: var(--radius); padding: 1.75rem 2rem; box-shadow: var(--shadow); }
.hero h1 { color: #fff; font-size: 1.6rem; margin-bottom: 0.25rem; }
.hero p { color: rgba(255, 255, 255, 0.8); margin: 0; }

.toolbar { display: flex; gap: 0.6rem; align-items: center; margin: 0 0 1rem; flex-wrap: wrap; }
input, select, textarea { padding: 0.55rem 0.7rem; border: 1px solid var(--line); border-radius: var(--radius-sm); font: inherit; color: var(--ink); background: var(--surface); }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
textarea { width: 100%; min-height: 5rem; resize: vertical; }
label { display: block; margin: 0.7rem 0 0.25rem; font-size: 0.85rem; font-weight: 500; color: var(--ink-2); }
button, .btn { background: var(--brand); color: #fff; border: 0; border-radius: var(--radius-sm); padding: 0.55rem 1rem; cursor: pointer; font: inherit; font-weight: 500; transition: background 0.12s, transform 0.08s; }
button:hover, .btn:hover { background: #0A5A93; text-decoration: none; }
button:active { transform: translateY(1px); }
button.secondary { background: var(--surface-2); color: var(--ink); border: 1px solid var(--line); }
button.secondary:hover { background: var(--line); }
button.danger { background: var(--danger); }
button.danger:hover { background: #8F1E17; }
button:disabled { background: var(--line); color: var(--muted); cursor: default; transform: none; }
/* Action buttons in a table row. Kept as a table cell (never flex, which
   would pull the cell out of the row) and aligned with the first line of
   the row's text. */
.row-actions { white-space: nowrap; }
.row-actions button, .row-actions a.pill { padding: 0.3rem 0.7rem; font-size: 0.82rem; vertical-align: top; }
.row-actions button + button, .row-actions button + a, .row-actions a + button { margin-left: 0.4rem; }

.message { margin: 0 0 1rem; padding: 0.7rem 1rem; border-radius: var(--radius-sm); font-size: 0.92rem; }
.message.error { background: var(--danger-soft); color: var(--danger); }
.message.success { background: var(--ok-soft); color: var(--ok); }
.message.info { background: var(--info-soft); color: var(--brand); }

.table-wrap { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow: auto; }
table { border-collapse: collapse; width: 100%; }
th, td { padding: 0.7rem 0.9rem; text-align: left; vertical-align: top; font-size: 0.88rem; border-bottom: 1px solid var(--line); }
th { background: var(--surface-2); font-weight: 600; color: var(--ink-2); font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.05em; position: sticky; top: 0; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: var(--surface-2); }

.pill { display: inline-block; white-space: nowrap; padding: 0.15rem 0.6rem; border-radius: 999px; font-size: 0.75rem; font-weight: 500; background: var(--surface-2); color: var(--ink-2); border: 1px solid var(--line); }
.pill.active, .pill.succeeded, .pill.redeemed, .pill.approved, .pill.sent { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.pill.leaver, .pill.failed, .pill.rejected { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.pill.dry_run, .pill.would_send, .pill.pending, .pill.running, .pill.pending_redemption, .pill.suspended { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.pill.open { background: var(--info-soft); color: var(--brand); border-color: transparent; }

#modal-overlay { display: none; position: fixed; inset: 0; background: rgba(11, 42, 69, 0.45); backdrop-filter: blur(2px); align-items: flex-start; justify-content: center; padding: 4rem 1rem; overflow-y: auto; z-index: 20; }
#modal-overlay.open { display: flex; }
.modal { background: var(--surface); border-radius: var(--radius); padding: 1.5rem 1.75rem; width: 36rem; max-width: 100%; box-shadow: var(--shadow-lg); }
.modal h2 { margin-bottom: 0.25rem; }
.modal h3 { margin: 1.25rem 0 0.25rem; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.actions { margin-top: 1.25rem; display: flex; gap: 0.6rem; flex-wrap: wrap; }
pre { background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 0.9rem; overflow: auto; font-size: 0.8rem; max-height: 26rem; }

/* ---------- IT request pages (assets/requests.js) ---------- */
.id-col { width: 4.5rem; white-space: nowrap; font-variant-numeric: tabular-nums; }
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: var(--surface-2); }
.request-head { display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap; }
.request-head h2 { margin: 0; flex: 1; }
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr)); gap: 0.9rem 1.5rem; margin: 0.75rem 0 0; }
.facts dt { font-size: 0.78rem; color: var(--muted); margin-bottom: 0.15rem; }
.facts dd { margin: 0; font-weight: 500; }
.assign { display: flex; gap: 0.4rem; flex-wrap: wrap; align-items: center; }
.assign select { min-width: 12rem; }
.hint { font-size: 0.78rem; color: var(--muted); margin-top: 0.25rem; }
.modal input, .modal textarea, .modal select { width: 100%; }
/* Thread: messages as cards, IT's to the right; workflow events as single centred lines. */
.thread { display: flex; flex-direction: column; gap: 0.75rem; margin: 1.25rem 0; }
.entry { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 0.9rem 1.1rem; box-shadow: var(--shadow); max-width: 52rem; }
.entry.staff { margin-left: auto; border-left: 3px solid var(--accent); }
.entry header { display: flex; gap: 0.5rem; align-items: baseline; margin-bottom: 0.4rem; font-size: 0.85rem; }
.entry header strong { font-weight: 600; }
.entry .body { white-space: pre-wrap; overflow-wrap: anywhere; }
.entry .files { display: flex; gap: 0.4rem; flex-wrap: wrap; margin-top: 0.6rem; }
.entry .files button { padding: 0.25rem 0.6rem; font-size: 0.8rem; }
.event { text-align: center; font-size: 0.82rem; color: var(--muted); }
.event .body { display: block; white-space: pre-wrap; color: var(--ink-2); margin-top: 0.2rem; }
.event.approved { color: var(--ok); }
.event.rejected { color: var(--danger); }
/* Raise modal parts shared by purchase requests: two-up rows, the people picker. */
.two-up { display: grid; grid-template-columns: 1fr 1fr; gap: 0 0.75rem; }
.chips { display: flex; flex-wrap: wrap; gap: 0.35rem; margin: 0.35rem 0; }
.chip { display: inline-flex; align-items: center; gap: 0.3rem; padding: 0.2rem 0.3rem 0.2rem 0.65rem; border-radius: 999px; background: var(--accent-soft); color: var(--brand); font-size: 0.82rem; }
.chip button { background: none; color: inherit; padding: 0 0.35rem; font-size: 0.9rem; line-height: 1; }
.chip button:hover { background: rgba(0, 0, 0, 0.08); }
.people-results { border: 1px solid var(--line); border-radius: var(--radius-sm); max-height: 12rem; overflow-y: auto; margin-top: 0.25rem; }
.people-results button { display: block; width: 100%; text-align: left; background: var(--surface); color: var(--ink); border-radius: 0; padding: 0.45rem 0.7rem; font-weight: 400; }
.people-results button:hover { background: var(--surface-2); }
.people-results small { color: var(--muted); margin-left: 0.4rem; }
.modal .check { display: flex; align-items: center; gap: 0.45rem; font-weight: 400; margin-top: 0.9rem; }
.modal .check input { width: auto; }
@media (max-width: 600px) { .two-up { grid-template-columns: 1fr; } }

/* ---------- sign-in page ---------- */
.auth { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.auth .panel { background: linear-gradient(160deg, var(--brand-deep), var(--brand) 55%, #1B7FC1); color: #fff; padding: 3rem; display: flex; flex-direction: column; justify-content: space-between; }
.auth .panel h1 { color: #fff; font-size: 2rem; max-width: 22ch; line-height: 1.15; }
.auth .panel p { color: rgba(255, 255, 255, 0.78); max-width: 42ch; }
.auth .form { display: grid; place-items: center; padding: 2rem; }
.auth .form > div { width: 100%; max-width: 26rem; }
.auth .form h2 { font-size: 1.25rem; margin-bottom: 0.5rem; }
.auth .form .btn { display: block; text-align: center; width: 100%; padding: 0.8rem; font-size: 0.95rem; }
.auth details { margin-top: 1.5rem; border-top: 1px solid var(--line); padding-top: 1rem; }
.auth summary { cursor: pointer; font-weight: 500; color: var(--brand); }

/* ---------- responsive ---------- */
@media (max-width: 900px) {
    .shell { grid-template-columns: 1fr; }
    .sidebar { position: fixed; inset: 0 auto 0 0; width: var(--sidebar-w); transform: translateX(-100%); transition: transform 0.2s; z-index: 30; box-shadow: var(--shadow-lg); }
    .sidebar.open { transform: none; }
    .menu-btn { display: inline-flex; }
    .topbar { padding: 0 1rem; }
    main { padding: 1.25rem 1rem 3rem; }
    .auth { grid-template-columns: 1fr; }
    .auth .panel { padding: 2rem 1.5rem; min-height: 40vh; }
}
