/* ===========================================================================
   Zerro PlatOps - app.css
   ---------------------------------------------------------------------------
   Hand-written, on purpose. There is no bundler in this product: deployment is
   an FTP upload to cPanel, and a build step is what that costs. Cache-busting
   is handled by App\Support\Asset, which appends the file's mtime, so an
   upload invalidates the browser cache by itself.

   Conventions:
   - Tokens on :root, redefined once for dark. Nothing below the tokens block
     hard-codes a colour.
   - The accent is injected per install from settings (brand.accent), so it is
     declared as a variable with a fallback and never assumed.
   - No gradients, no decorative animation, no large cards. This is an
     operations tool: clarity, density and speed, per docs/mvp-scope.md.
   - Status is never conveyed by colour alone. Every badge carries text.
   =========================================================================== */

/* --------------------------------------------------------------- 1. tokens */

:root {
    /* Neutrals. A slightly cool grey: long tables are read for a long time,
       and a warm grey goes muddy at low contrast. */
    --c-bg:            #f7f8fa;
    --c-surface:       #ffffff;
    --c-surface-sunk:  #f0f2f5;
    --c-border:        #d8dce3;
    --c-border-strong: #b9c0cb;

    --c-text:          #1b1f26;
    --c-text-muted:    #5c6676;
    --c-text-faint:    #868f9e;
    --c-text-invert:   #ffffff;

    /* Set per install from brand.accent; the fallback is the product default. */
    --c-accent:        #2f5d8f;
    --c-accent-text:   #ffffff;
    --c-accent-sunk:   #26496f;
    --c-accent-wash:   #eaf0f7;

    /* Semantic status. Deliberately distinguishable without relying on
       red/green discrimination: lightness differs as well as hue. */
    --c-ok:            #1f7a4d;
    --c-ok-wash:       #e7f4ec;
    --c-notice:        #8a6a00;
    --c-notice-wash:   #fdf4dc;
    --c-warn:          #a35200;
    --c-warn-wash:     #fdeedd;
    --c-danger:        #b3261e;
    --c-danger-wash:   #fdeceb;
    --c-info:          #1f5f8a;
    --c-info-wash:     #e6f1f8;
    --c-idle:          #5c6676;
    --c-idle-wash:     #eef0f3;

    /* Type. System stack: no webfont to download, and it renders natively on
       the Windows machines this is mostly read on. */
    --font-ui: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
               "Helvetica Neue", Arial, sans-serif;
    --font-mono: ui-monospace, SFMono-Regular, "Cascadia Mono", Consolas,
                 "Liberation Mono", monospace;

    --fs-xs:   0.75rem;
    --fs-sm:   0.8125rem;
    --fs-base: 0.875rem;   /* 14px: denser than the web default, on purpose */
    --fs-md:   1rem;
    --fs-lg:   1.125rem;
    --fs-xl:   1.375rem;

    /* Space. A 4px scale; tables and forms both land on it. */
    --sp-1: 0.25rem;
    --sp-2: 0.5rem;
    --sp-3: 0.75rem;
    --sp-4: 1rem;
    --sp-5: 1.5rem;
    --sp-6: 2rem;
    --sp-7: 3rem;

    --radius:    4px;
    --radius-lg: 6px;

    --shadow-1: 0 1px 2px rgba(16, 20, 28, 0.06);
    --shadow-2: 0 4px 12px rgba(16, 20, 28, 0.10);

    --focus: 0 0 0 2px var(--c-surface), 0 0 0 4px var(--c-accent);

    --nav-w: 13rem;
    --measure: 68ch;
}

/* Dark mode. Follows the OS by default; [data-theme] wins when a person has
   chosen, which App\Support\Theme writes. Guarded so an explicit light choice
   is not overridden by the media query. */
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --c-bg:            #15181d;
        --c-surface:       #1c2027;
        --c-surface-sunk:  #23282f;
        --c-border:        #333a44;
        --c-border-strong: #475161;

        --c-text:          #e6e9ee;
        --c-text-muted:    #a3acba;
        --c-text-faint:    #7b8595;

        --c-accent-wash:   #1e2a38;

        /* Washes have to be rebuilt for dark: a pale tint that reads as a hint
           on white reads as a glare on near-black. */
        --c-ok:            #5fd39b;
        --c-ok-wash:       #15291f;
        --c-notice:        #e0bb55;
        --c-notice-wash:   #2b2616;
        --c-warn:          #f0a35e;
        --c-warn-wash:     #2e2117;
        --c-danger:        #f08a84;
        --c-danger-wash:   #2e1a1a;
        --c-info:          #78bde6;
        --c-info-wash:     #16242e;
        --c-idle:          #a3acba;
        --c-idle-wash:     #23282f;

        --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.4);
        --shadow-2: 0 4px 12px rgba(0, 0, 0, 0.5);
    }
}

:root[data-theme="dark"] {
    --c-bg:            #15181d;
    --c-surface:       #1c2027;
    --c-surface-sunk:  #23282f;
    --c-border:        #333a44;
    --c-border-strong: #475161;

    --c-text:          #e6e9ee;
    --c-text-muted:    #a3acba;
    --c-text-faint:    #7b8595;

    --c-accent-wash:   #1e2a38;

    --c-ok:            #5fd39b;
    --c-ok-wash:       #15291f;
    --c-notice:        #e0bb55;
    --c-notice-wash:   #2b2616;
    --c-warn:          #f0a35e;
    --c-warn-wash:     #2e2117;
    --c-danger:        #f08a84;
    --c-danger-wash:   #2e1a1a;
    --c-info:          #78bde6;
    --c-info-wash:     #16242e;
    --c-idle:          #a3acba;
    --c-idle-wash:     #23282f;

    --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow-2: 0 4px 12px rgba(0, 0, 0, 0.5);
}

/* ---------------------------------------------------------------- 2. reset */

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    background: var(--c-bg);
    color: var(--c-text);
    font: var(--fs-base)/1.5 var(--font-ui);
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, p, figure, blockquote, dl, dd { margin: 0; }

h1, h2, h3, h4 { font-weight: 600; line-height: 1.25; }
h1 { font-size: var(--fs-xl); }
h2 { font-size: var(--fs-lg); }
h3 { font-size: var(--fs-md); }

ul, ol { margin: 0; padding: 0; list-style: none; }

img, svg { display: block; max-width: 100%; }

a { color: var(--c-accent); text-decoration: none; }
a:hover { text-decoration: underline; }

button, input, select, textarea { font: inherit; color: inherit; }

code, kbd, .mono { font-family: var(--font-mono); font-size: 0.9em; }

/* One focus treatment everywhere. Keyboard navigation is a stated requirement,
   so focus must never be removed - only replaced with something better. */
:focus-visible {
    outline: none;
    box-shadow: var(--focus);
    border-radius: var(--radius);
}

/* Respect a request for less motion. There is little here to disable, which is
   the point, but transitions on hover still count. */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
}

/* ------------------------------------------------------------ 3. utilities */

.visually-hidden {
    position: absolute;
    width: 1px; height: 1px;
    margin: -1px; padding: 0;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
}

.skip-link {
    position: absolute;
    left: var(--sp-2);
    top: -3rem;
    z-index: 100;
    padding: var(--sp-2) var(--sp-3);
    background: var(--c-surface);
    border: 1px solid var(--c-border-strong);
    border-radius: var(--radius);
}
.skip-link:focus { top: var(--sp-2); }

.muted { color: var(--c-text-muted); }
.faint { color: var(--c-text-faint); }
.small { font-size: var(--fs-sm); }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.stack > * + * { margin-top: var(--sp-3); }
.row { display: flex; gap: var(--sp-3); align-items: center; }
.row-tight { display: flex; gap: var(--sp-2); align-items: center; }
.spread { display: flex; gap: var(--sp-3); align-items: center; justify-content: space-between; }
.wrap { flex-wrap: wrap; }
.grow { flex: 1 1 auto; min-width: 0; }

/* Long names and URLs in a fixed table cell. */
.truncate {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* --------------------------------------------------------------- 4. layout */

.app {
    display: grid;
    grid-template-columns: var(--nav-w) minmax(0, 1fr);
    min-height: 100vh;
}

.app-nav {
    background: var(--c-surface);
    border-right: 1px solid var(--c-border);
    padding: var(--sp-4) var(--sp-3);
    display: flex;
    flex-direction: column;
    gap: var(--sp-5);
}

.app-main { min-width: 0; padding: var(--sp-5) var(--sp-6); }

.page-head {
    display: flex;
    gap: var(--sp-3);
    align-items: baseline;
    justify-content: space-between;
    flex-wrap: wrap;
    margin-bottom: var(--sp-5);
}

.prose { max-width: var(--measure); }
.prose p + p { margin-top: var(--sp-3); }

@media (max-width: 60rem) {
    .app { grid-template-columns: minmax(0, 1fr); }
    .app-nav {
        border-right: 0;
        border-bottom: 1px solid var(--c-border);
        flex-direction: row;
        align-items: center;
        gap: var(--sp-4);
        overflow-x: auto;
    }
    .app-main { padding: var(--sp-4); }
}

/* ------------------------------------------------------------ 5. nav items */

.brand {
    display: flex;
    align-items: center;
    gap: var(--sp-2);
    font-weight: 600;
    font-size: var(--fs-md);
    color: var(--c-text);
}
.brand:hover { text-decoration: none; }

.nav-list { display: flex; flex-direction: column; gap: 1px; }

.nav-link {
    display: flex;
    align-items: center;
    gap: var(--sp-2);
    padding: var(--sp-2) var(--sp-3);
    border-radius: var(--radius);
    color: var(--c-text-muted);
    font-weight: 500;
}
.nav-link:hover { background: var(--c-surface-sunk); color: var(--c-text); text-decoration: none; }
.nav-link[aria-current="page"] { background: var(--c-accent-wash); color: var(--c-accent); }

.nav-group-label {
    font-size: var(--fs-xs);
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--c-text-faint);
    padding: 0 var(--sp-3) var(--sp-1);
}

/* ---------------------------------------------------------------- 6. cards */

.panel {
    background: var(--c-surface);
    border: 1px solid var(--c-border);
    border-radius: var(--radius-lg);
}

.panel-head {
    padding: var(--sp-3) var(--sp-4);
    border-bottom: 1px solid var(--c-border);
    display: flex;
    gap: var(--sp-3);
    align-items: center;
    justify-content: space-between;
}

.panel-body { padding: var(--sp-4); }

.panel-title { font-size: var(--fs-base); font-weight: 600; }

/* --------------------------------------------------------------- 7. tables */

/* The register and the operations list are the product's core surfaces. Dense,
   quiet rules, and a sticky header, because these get scrolled. */

.table-wrap {
    overflow-x: auto;
    border: 1px solid var(--c-border);
    border-radius: var(--radius-lg);
    background: var(--c-surface);
}

table.data {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--fs-sm);
}

table.data th,
table.data td {
    padding: var(--sp-2) var(--sp-3);
    text-align: left;
    vertical-align: top;
    border-bottom: 1px solid var(--c-border);
}

table.data thead th {
    position: sticky;
    top: 0;
    z-index: 1;
    background: var(--c-surface-sunk);
    font-size: var(--fs-xs);
    font-weight: 600;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    color: var(--c-text-muted);
    white-space: nowrap;
}

table.data tbody tr:last-child td { border-bottom: 0; }
table.data tbody tr:hover { background: var(--c-surface-sunk); }

/* A sortable header is a button, so it is reachable by keyboard. */
table.data th button {
    all: unset;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: var(--sp-1);
    font: inherit;
    color: inherit;
}
table.data th button:hover { color: var(--c-text); }
table.data th[aria-sort] button { color: var(--c-text); }

table.data td.numeric { text-align: right; font-variant-numeric: tabular-nums; }

/* -------------------------------------------------------------- 8. badges */

/* Status always carries its own text. Colour is reinforcement, never the
   message - a stated requirement, and the only way this works for a colour
   blind reader or a printed page. */

.badge {
    display: inline-flex;
    align-items: center;
    gap: var(--sp-1);
    padding: 0.1rem var(--sp-2);
    border-radius: 999px;
    border: 1px solid transparent;
    font-size: var(--fs-xs);
    font-weight: 600;
    white-space: nowrap;
}

.badge-ok     { background: var(--c-ok-wash);     color: var(--c-ok);     border-color: var(--c-ok); }
.badge-notice { background: var(--c-notice-wash); color: var(--c-notice); border-color: var(--c-notice); }
.badge-warn   { background: var(--c-warn-wash);   color: var(--c-warn);   border-color: var(--c-warn); }
.badge-danger { background: var(--c-danger-wash); color: var(--c-danger); border-color: var(--c-danger); }
.badge-info   { background: var(--c-info-wash);   color: var(--c-info);   border-color: var(--c-info); }
.badge-idle   { background: var(--c-idle-wash);   color: var(--c-idle);   border-color: var(--c-border-strong); }

/* A quiet tag for a version string or an environment name. */
.tag {
    display: inline-block;
    padding: 0.05rem var(--sp-2);
    border-radius: var(--radius);
    background: var(--c-surface-sunk);
    border: 1px solid var(--c-border);
    font-family: var(--font-mono);
    font-size: var(--fs-xs);
    color: var(--c-text-muted);
}

/* -------------------------------------------------------------- 9. buttons */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--sp-2);
    padding: var(--sp-2) var(--sp-3);
    border: 1px solid var(--c-border-strong);
    border-radius: var(--radius);
    background: var(--c-surface);
    color: var(--c-text);
    font-size: var(--fs-sm);
    font-weight: 500;
    cursor: pointer;
    transition: background 0.1s ease;
}
.btn:hover { background: var(--c-surface-sunk); text-decoration: none; }
.btn:disabled, .btn[aria-disabled="true"] { opacity: 0.55; cursor: not-allowed; }

.btn-primary {
    background: var(--c-accent);
    border-color: var(--c-accent);
    color: var(--c-accent-text);
}
.btn-primary:hover { background: var(--c-accent-sunk); border-color: var(--c-accent-sunk); }

.btn-quiet { border-color: transparent; background: transparent; color: var(--c-text-muted); }
.btn-quiet:hover { background: var(--c-surface-sunk); color: var(--c-text); }

.btn-danger { border-color: var(--c-danger); color: var(--c-danger); }
.btn-danger:hover { background: var(--c-danger-wash); }

.btn-sm { padding: var(--sp-1) var(--sp-2); font-size: var(--fs-xs); }

/* --------------------------------------------------------------- 10. forms */

.field { display: flex; flex-direction: column; gap: var(--sp-1); }
.field + .field { margin-top: var(--sp-4); }

.field label { font-size: var(--fs-sm); font-weight: 600; }

.field .help { font-size: var(--fs-xs); color: var(--c-text-muted); }

input[type="text"], input[type="email"], input[type="password"],
input[type="url"], input[type="number"], input[type="date"],
input[type="datetime-local"], input[type="search"], select, textarea {
    padding: var(--sp-2) var(--sp-3);
    border: 1px solid var(--c-border-strong);
    border-radius: var(--radius);
    background: var(--c-surface);
    color: var(--c-text);
    width: 100%;
}

textarea { min-height: 6rem; resize: vertical; }

.field-error input, .field-error select, .field-error textarea { border-color: var(--c-danger); }

.error {
    color: var(--c-danger);
    font-size: var(--fs-xs);
    font-weight: 600;
}

fieldset { border: 0; margin: 0; padding: 0; }

/* ------------------------------------------------------------- 11. notices */

.notice {
    display: flex;
    gap: var(--sp-3);
    padding: var(--sp-3) var(--sp-4);
    border: 1px solid var(--c-border);
    border-left-width: 3px;
    border-radius: var(--radius);
    background: var(--c-surface);
    font-size: var(--fs-sm);
}

.notice-ok     { border-left-color: var(--c-ok);     background: var(--c-ok-wash); }
.notice-notice { border-left-color: var(--c-notice); background: var(--c-notice-wash); }
.notice-warn   { border-left-color: var(--c-warn);   background: var(--c-warn-wash); }
.notice-danger { border-left-color: var(--c-danger); background: var(--c-danger-wash); }
.notice-info   { border-left-color: var(--c-info);   background: var(--c-info-wash); }

/* --------------------------------------------------------- 12. empty state */

/* A clean empty state is a stated requirement. An empty register is the first
   thing a new install shows, so it has to say what to do next rather than just
   being blank. */

.empty {
    padding: var(--sp-7) var(--sp-5);
    text-align: center;
    color: var(--c-text-muted);
}
.empty h3 { color: var(--c-text); margin-bottom: var(--sp-2); }
.empty p { max-width: 44ch; margin: 0 auto var(--sp-4); }

/* ----------------------------------------------------------- 13. print */

@media print {
    .app { grid-template-columns: minmax(0, 1fr); }
    .app-nav, .btn, .skip-link { display: none; }
    body { background: #fff; color: #000; }
    .panel, .table-wrap { border-color: #999; }
    table.data thead th { position: static; }
}

/* --------------------------------------------------- 14. sign-in and invite */

/* The two pages someone sees before they are anybody. Deliberately plain: a
   centred card, the install's own branding, and nothing else to read. */

body.centred {
    display: grid;
    place-items: center;
    min-height: 100vh;
    padding: var(--sp-4);
}

.auth-card {
    width: 100%;
    max-width: 24rem;
    padding: var(--sp-5);
    background: var(--c-surface);
    border: 1px solid var(--c-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-1);
}

.auth-head {
    margin-bottom: var(--sp-5);
    text-align: center;
}
.auth-head h1 { font-size: var(--fs-lg); }
.auth-head p { margin-top: var(--sp-1); font-size: var(--fs-sm); }

/* A readonly input used to show a one-time link for copying. */
.auth-card input[readonly],
input[readonly].mono {
    background: var(--c-surface-sunk);
    cursor: text;
}

/* Pagination, as rendered by Laravel's simple default. */
.pagination { display: flex; gap: var(--sp-1); flex-wrap: wrap; list-style: none; }
.pagination a, .pagination span {
    display: inline-block;
    padding: var(--sp-1) var(--sp-2);
    border: 1px solid var(--c-border);
    border-radius: var(--radius);
    font-size: var(--fs-sm);
}
.pagination .active span { background: var(--c-accent); border-color: var(--c-accent); color: var(--c-accent-text); }
.pagination .disabled span { color: var(--c-text-faint); }
