/**
 * public/assets/css/app.css
 * NEDC PMRS design system. Every colour is a CSS variable defined once
 * below — re-theming the whole app is a one-file change. Mobile-first;
 * see the breakpoints and print rules at the bottom of the file.
 */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&family=Lora:ital,wght@0,600;1,500&display=swap');

:root {
    /* --- Brand palette: deep Nigerian-flag green as the primary (the
       identity colour of a Nigerian federal commission), a ceremonial gold
       accent (coat-of-arms trim), navy demoted to a secondary tone for
       contrast in charts/print. Deliberately deep and desaturated, not the
       bright flag green, to read as mature/official rather than loud. */
    --color-primary: #0b5c34;
    --color-primary-dark: #073b21;
    --color-primary-light: #12784a;
    --color-accent: #c9971f;
    --color-accent-light: #e0b23f;
    --color-secondary: #0b1f3a;
    --color-secondary-light: #16305a;

    --color-bg: #f5f6f8;
    --color-surface: #ffffff;
    --color-surface-alt: #f9f7f1;
    --color-border: #e3e6ec;
    --color-border-strong: #c7cddb;

    --color-text: #1b2431;
    --color-text-muted: #5c6579;
    --color-text-faint: #8991a3;
    --color-text-on-primary: #f4f6fa;
    --color-text-on-accent: #241a02;

    --color-success: #0e7d6b;
    --color-success-bg: #e5f4f1;
    --color-warning: #b5651d;
    --color-warning-bg: #fbeee0;
    --color-danger: #a3283c;
    --color-danger-bg: #fbe9ec;
    --color-info: #2456a6;
    --color-info-bg: #e8eff9;

    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-serif: 'Lora', Georgia, serif;

    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --shadow-sm: 0 1px 2px rgba(11, 31, 58, 0.06);
    --shadow-md: 0 4px 16px rgba(11, 31, 58, 0.08);
    --shadow-lg: 0 12px 32px rgba(11, 31, 58, 0.14);

    --sidebar-width: 264px;
    --topbar-height: 68px;
    --transition: 160ms ease;
}

/* ------------------------------------------------------------------ */
/* Reset / base                                                       */
/* ------------------------------------------------------------------ */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
    margin: 0;
    font-family: var(--font-sans);
    background: var(--color-bg);
    color: var(--color-text);
    font-size: 14.5px;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4, h5, h6 { margin: 0 0 .5em; font-weight: 700; color: var(--color-primary); letter-spacing: -0.01em; }
a { color: var(--color-primary); text-decoration: none; }
a:hover { color: var(--color-accent); }
img { max-width: 100%; }
.icon { width: 1.1em; height: 1.1em; vertical-align: -0.18em; flex-shrink: 0; }
.icon-sm { width: .95em; height: .95em; }
.icon-lg { width: 1.8em; height: 1.8em; }
::selection { background: var(--color-accent-light); color: var(--color-text-on-accent); }

/* ------------------------------------------------------------------ */
/* Layout shell: sidebar + topbar                                     */
/* ------------------------------------------------------------------ */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
    width: var(--sidebar-width);
    background: linear-gradient(180deg, var(--color-primary) 0%, var(--color-primary-dark) 100%);
    color: var(--color-text-on-primary);
    display: flex;
    flex-direction: column;
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 40;
    transition: transform var(--transition);
    border-right: 1px solid rgba(255,255,255,0.06);
}
.sidebar-brand {
    display: flex;
    align-items: center;
    gap: .65rem;
    padding: 1.25rem 1.25rem 1rem;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}
.sidebar-brand .mark {
    width: 38px; height: 38px; border-radius: 10px;
    background: var(--color-accent);
    display: flex; align-items: center; justify-content: center;
    color: var(--color-text-on-accent); font-weight: 800; font-family: var(--font-serif);
    flex-shrink: 0;
}
.sidebar-brand .name { font-weight: 700; font-size: .98rem; line-height: 1.2; }
.sidebar-brand .sub { font-size: .72rem; color: rgba(244,246,250,0.6); letter-spacing: .04em; text-transform: uppercase; }

.sidebar-nav { flex: 1; overflow-y: auto; padding: .75rem .6rem; }
.sidebar-group { margin-bottom: .75rem; }
.sidebar-group-label {
    font-size: .68rem; text-transform: uppercase; letter-spacing: .08em;
    color: rgba(244,246,250,0.4); padding: .5rem .75rem .3rem;
}
.sidebar-link {
    display: flex; align-items: center; gap: .7rem;
    padding: .58rem .75rem; border-radius: var(--radius-sm);
    color: rgba(244,246,250,0.82); font-size: .875rem; font-weight: 500;
    transition: background var(--transition), color var(--transition);
    min-height: 44px;
}
.sidebar-link:hover { background: rgba(255,255,255,0.06); color: #fff; }
.sidebar-link.active { background: rgba(184,134,11,0.18); color: #fff; box-shadow: inset 3px 0 0 var(--color-accent); }
.sidebar-link .icon { color: var(--color-accent-light); }
.sidebar-link.active .icon { color: var(--color-accent); }

.sidebar-user {
    padding: .9rem 1rem; border-top: 1px solid rgba(255,255,255,0.08);
    display: flex; align-items: center; gap: .6rem;
}
.sidebar-user .avatar {
    width: 36px; height: 36px; border-radius: 50%; background: var(--color-accent);
    display: flex; align-items: center; justify-content: center; font-weight: 700; color: var(--color-text-on-accent);
    flex-shrink: 0; text-transform: uppercase;
}
.sidebar-user .who { flex: 1; min-width: 0; }
.sidebar-user .who .name { font-size: .82rem; font-weight: 600; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user .who .role { font-size: .72rem; color: rgba(244,246,250,0.55); }
.sidebar-user a.logout { color: rgba(244,246,250,0.6); flex-shrink: 0; }
.sidebar-user a.logout:hover { color: var(--color-accent-light); }

.sidebar-overlay {
    position: fixed; inset: 0; background: rgba(7,21,40,0.55); z-index: 39;
    opacity: 0; pointer-events: none; transition: opacity var(--transition);
}
.sidebar-overlay.show { opacity: 1; pointer-events: auto; }

.main-area { flex: 1; margin-left: var(--sidebar-width); display: flex; flex-direction: column; min-width: 0; }

.topbar {
    height: var(--topbar-height);
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    display: flex; align-items: center; gap: 1rem;
    padding: 0 1.25rem;
    position: sticky; top: 0; z-index: 30;
}
.topbar .menu-toggle {
    display: none; background: none; border: 1px solid var(--color-border); border-radius: var(--radius-sm);
    width: 40px; height: 40px; align-items: center; justify-content: center; color: var(--color-primary); cursor: pointer;
}
.topbar-title { font-weight: 700; font-size: 1.05rem; color: var(--color-primary); flex: 1; min-width: 0; }
.topbar-title .crumbs { display: block; font-size: .74rem; font-weight: 500; color: var(--color-text-faint); }
.topbar-clock { font-size: .78rem; color: var(--color-text-muted); white-space: nowrap; }
.topbar-icon-btn {
    position: relative; width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--color-border);
    background: var(--color-surface); display: flex; align-items: center; justify-content: center; color: var(--color-primary); cursor: pointer;
}
.topbar-icon-btn .dot {
    position: absolute; top: 6px; right: 7px; width: 8px; height: 8px; border-radius: 50%; background: var(--color-danger); border: 1.5px solid #fff;
}
.topbar-user { display: flex; align-items: center; gap: .5rem; cursor: pointer; }
.topbar-user .avatar {
    width: 34px; height: 34px; border-radius: 50%; background: var(--color-primary); color: #fff;
    display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: .8rem; text-transform: uppercase;
}

.main-content { flex: 1; padding: 1.5rem; max-width: 1440px; width: 100%; margin: 0 auto; }

/* ------------------------------------------------------------------ */
/* Cards, stat tiles, badges                                          */
/* ------------------------------------------------------------------ */
.card {
    background: var(--color-surface); border: 1px solid var(--color-border);
    border-radius: var(--radius-lg); box-shadow: var(--shadow-sm);
}
.card-header {
    padding: 1rem 1.25rem; border-bottom: 1px solid var(--color-border);
    display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap;
}
.card-header h2, .card-header h3 { margin: 0; font-size: 1rem; }
.card-body { padding: 1.25rem; }
.card-body.tight { padding: 0; }

.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; margin-bottom: 1.5rem; }
.stat-grid > * { min-width: 0; }
.stat-card {
    background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-lg);
    padding: 1.1rem 1.25rem; box-shadow: var(--shadow-sm); position: relative; overflow: hidden;
}
.stat-card::before {
    content: ''; position: absolute; inset: 0 auto 0 0; width: 4px; background: var(--color-accent);
}
.stat-card .label { font-size: .74rem; text-transform: uppercase; letter-spacing: .05em; color: var(--color-text-muted); font-weight: 600; }
.stat-card .value { font-size: 1.65rem; font-weight: 800; color: var(--color-primary); font-family: var(--font-serif); margin-top: .15rem; }
.stat-card .delta { font-size: .78rem; margin-top: .3rem; color: var(--color-text-faint); }
.stat-card .stat-icon {
    position: absolute; top: 1rem; right: 1rem; width: 38px; height: 38px; border-radius: 10px;
    background: var(--color-surface-alt); display: flex; align-items: center; justify-content: center; color: var(--color-accent);
}
.stat-card.tone-success::before { background: var(--color-success); }
.stat-card.tone-danger::before { background: var(--color-danger); }
.stat-card.tone-info::before { background: var(--color-info); }

.badge {
    display: inline-flex; align-items: center; gap: .3rem; padding: .22rem .6rem; border-radius: 999px;
    font-size: .72rem; font-weight: 700; letter-spacing: .02em; text-transform: uppercase; white-space: nowrap;
}
.badge-success { background: var(--color-success-bg); color: var(--color-success); }
.badge-warning { background: var(--color-warning-bg); color: var(--color-warning); }
.badge-danger { background: var(--color-danger-bg); color: var(--color-danger); }
.badge-info { background: var(--color-info-bg); color: var(--color-info); }
.badge-neutral { background: var(--color-surface-alt); color: var(--color-text-muted); }

/* ------------------------------------------------------------------ */
/* Buttons                                                            */
/* ------------------------------------------------------------------ */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: .45rem;
    padding: .55rem 1.05rem; border-radius: var(--radius-sm); font-size: .85rem; font-weight: 600;
    border: 1px solid transparent; cursor: pointer; transition: all var(--transition); min-height: 40px; line-height: 1;
}
.btn-primary { background: var(--color-primary); color: #fff; }
.btn-primary:hover { background: var(--color-primary-light); color: #fff; }
.btn-accent { background: var(--color-accent); color: var(--color-text-on-accent); }
.btn-accent:hover { background: var(--color-accent-light); }
.btn-outline { background: transparent; border-color: var(--color-border-strong); color: var(--color-primary); }
.btn-outline:hover { background: var(--color-surface-alt); }
.btn-danger { background: var(--color-danger); color: #fff; }
.btn-danger:hover { opacity: .9; }
.btn-ghost { background: transparent; color: var(--color-text-muted); }
.btn-ghost:hover { background: var(--color-surface-alt); color: var(--color-text); }
.btn-sm { padding: .35rem .7rem; font-size: .78rem; min-height: 32px; }
.btn-block { width: 100%; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

/* ------------------------------------------------------------------ */
/* Forms                                                              */
/* ------------------------------------------------------------------ */
.form-group { margin-bottom: 1.1rem; }
.form-label { display: block; font-size: .82rem; font-weight: 600; color: var(--color-text); margin-bottom: .35rem; }
.form-label .req { color: var(--color-danger); }
.form-hint { font-size: .76rem; color: var(--color-text-faint); margin-top: .3rem; }
.form-error { font-size: .76rem; color: var(--color-danger); margin-top: .3rem; font-weight: 600; }
.form-control, select.form-control, textarea.form-control {
    width: 100%; padding: .58rem .75rem; border: 1px solid var(--color-border-strong); border-radius: var(--radius-sm);
    font-family: inherit; font-size: .875rem; background: var(--color-surface); color: var(--color-text);
    transition: border-color var(--transition), box-shadow var(--transition); min-height: 42px;
}
textarea.form-control { min-height: 96px; resize: vertical; }
.form-control:focus {
    outline: none; border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(11,31,58,0.12);
}
.form-control.is-invalid { border-color: var(--color-danger); }
.form-row { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1rem; }
.form-row.cols-3 { grid-template-columns: repeat(3, 1fr); }
/* Grid items default to min-width:auto, which refuses to shrink below the
   content's own natural width — a wide SVG chart or an un-scrolled table
   inside a column then forces the whole row to overflow horizontally
   instead of the column shrinking to fit. min-width:0 opts back into
   normal shrink behaviour. */
.form-row > * { min-width: 0; }
.form-check { display: flex; align-items: center; gap: .5rem; }
.form-check input { width: 18px; height: 18px; }

/* Password fields: an eye toggle sitting inside the input's right edge. */
.password-field { position: relative; }
.password-field .form-control { padding-right: 2.6rem; }
.password-toggle {
    position: absolute; top: 50%; right: .35rem; transform: translateY(-50%);
    width: 32px; height: 32px; border: none; background: transparent; border-radius: var(--radius-sm);
    display: flex; align-items: center; justify-content: center; color: var(--color-text-faint); cursor: pointer;
    transition: background var(--transition), color var(--transition);
}
.password-toggle:hover { background: var(--color-surface-alt); color: var(--color-primary); }
.password-toggle:focus-visible { outline: 2px solid var(--color-primary); outline-offset: 1px; }

/* File uploads: a styled button + filename readout, replacing the native
   file input's inconsistent browser chrome. The real <input> stays in the
   render tree (visually hidden, not display:none) so required-field
   validation still anchors and works correctly. */
.file-upload { display: flex; align-items: center; gap: .75rem; flex-wrap: wrap; }
.file-upload-input {
    position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}
.file-upload-btn { flex-shrink: 0; }
.file-upload-name { font-size: .82rem; color: var(--color-text-faint); overflow-wrap: anywhere; }
.file-upload-preview {
    width: 44px; height: 44px; border-radius: var(--radius-sm); object-fit: cover;
    border: 1px solid var(--color-border); flex-shrink: 0;
}

/* ------------------------------------------------------------------ */
/* Tables                                                              */
/* ------------------------------------------------------------------ */
.table-toolbar { display: flex; align-items: center; gap: .75rem; padding: 1rem 1.25rem; flex-wrap: wrap; border-bottom: 1px solid var(--color-border); }
.table-toolbar .search-box { position: relative; flex: 1; min-width: 200px; }
.table-toolbar .search-box .icon { position: absolute; left: .7rem; top: 50%; transform: translateY(-50%); color: var(--color-text-faint); }
.table-toolbar .search-box input { padding-left: 2.1rem; }
.table-scroll { overflow-x: auto; }
table.data-table { width: 100%; border-collapse: collapse; font-size: .84rem; }
/* The 640px floor only makes sense for a many-column list table meant to
   scroll horizontally within .table-scroll — applying it to every table
   (e.g. a small 2-column fact table dropped straight into a card) forced
   pages that don't wrap their table in .table-scroll to overflow. */
.table-scroll table.data-table { min-width: 640px; }
table.data-table th {
    text-align: left; padding: .7rem 1rem; background: var(--color-surface-alt); color: var(--color-text-muted);
    font-size: .72rem; text-transform: uppercase; letter-spacing: .04em; font-weight: 700; border-bottom: 1px solid var(--color-border);
    white-space: nowrap;
}
table.data-table td { padding: .75rem 1rem; border-bottom: 1px solid var(--color-border); vertical-align: middle; }
table.data-table tbody tr:hover { background: var(--color-surface-alt); }
table.data-table tbody tr:last-child td { border-bottom: none; }
.pagination { display: flex; align-items: center; justify-content: space-between; padding: 1rem 1.25rem; flex-wrap: wrap; gap: .75rem; }
.pagination .pages { display: flex; gap: .3rem; flex-wrap: wrap; }
.pagination a, .pagination span.current {
    display: inline-flex; align-items: center; justify-content: center; min-width: 34px; height: 34px; padding: 0 .5rem;
    border-radius: var(--radius-sm); border: 1px solid var(--color-border); font-size: .8rem; color: var(--color-text);
}
.pagination span.current { background: var(--color-primary); border-color: var(--color-primary); color: #fff; font-weight: 700; }
.empty-state { text-align: center; padding: 3rem 1.5rem; color: var(--color-text-faint); }
.empty-state .icon { width: 48px; height: 48px; color: var(--color-border-strong); margin-bottom: .75rem; }

/* ------------------------------------------------------------------ */
/* Alerts / flash / toasts                                            */
/* ------------------------------------------------------------------ */
.alert {
    display: flex; align-items: flex-start; gap: .6rem; padding: .8rem 1rem; border-radius: var(--radius-md);
    font-size: .85rem; margin-bottom: .85rem; border: 1px solid transparent;
}
.alert-success { background: var(--color-success-bg); color: var(--color-success); border-color: rgba(15,107,76,0.25); }
.alert-danger { background: var(--color-danger-bg); color: var(--color-danger); border-color: rgba(163,40,60,0.25); }
.alert-warning { background: var(--color-warning-bg); color: #7a3d0a; border-color: rgba(181,101,29,0.3); }
.alert-info { background: var(--color-info-bg); color: var(--color-info); border-color: rgba(36,86,166,0.25); }
.alert .close { margin-left: auto; cursor: pointer; opacity: .6; background: none; border: none; }
.alert .close:hover { opacity: 1; }

/* ------------------------------------------------------------------ */
/* Modals                                                              */
/* ------------------------------------------------------------------ */
.modal-backdrop { position: fixed; inset: 0; background: rgba(7,21,40,0.5); display: none; align-items: center; justify-content: center; z-index: 100; padding: 1rem; }
.modal-backdrop.show { display: flex; }
.modal { background: var(--color-surface); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); width: 100%; max-width: 480px; max-height: 90vh; overflow-y: auto; }
.modal-header { padding: 1.1rem 1.25rem; border-bottom: 1px solid var(--color-border); display: flex; align-items: center; justify-content: space-between; }
.modal-body { padding: 1.25rem; }
.modal-footer { padding: 1rem 1.25rem; border-top: 1px solid var(--color-border); display: flex; justify-content: flex-end; gap: .6rem; }

/* ------------------------------------------------------------------ */
/* Tabs, progress                                                      */
/* ------------------------------------------------------------------ */
.tabs { display: flex; gap: .25rem; border-bottom: 1px solid var(--color-border); padding: 0 1.25rem; overflow-x: auto; }
.tabs a { padding: .8rem .3rem; margin-right: 1.25rem; font-size: .85rem; font-weight: 600; color: var(--color-text-muted); border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs a.active { color: var(--color-primary); border-bottom-color: var(--color-accent); }

.progress { height: 8px; border-radius: 999px; background: var(--color-border); overflow: hidden; }
.progress > span { display: block; height: 100%; background: linear-gradient(90deg, var(--color-secondary), var(--color-secondary-light)); }
.progress.accent > span { background: linear-gradient(90deg, var(--color-accent), var(--color-accent-light)); }

/* Login / installer centered card layout */
.center-screen { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 1.5rem; background: radial-gradient(circle at top, var(--color-primary-light) 0%, var(--color-primary-dark) 60%); }
.auth-card { width: 100%; max-width: 420px; background: var(--color-surface); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); overflow: hidden; }
.auth-card .brand-strip { background: var(--color-primary); padding: 2rem 1.75rem; text-align: center; color: #fff; }
.auth-card .brand-strip .mark { width: 92px; height: 92px; margin: 0 auto .85rem; border-radius: 20px; background: var(--color-accent); display: flex; align-items: center; justify-content: center; font-family: var(--font-serif); font-weight: 800; font-size: 2.4rem; color: var(--color-text-on-accent); }
.auth-card .brand-strip .logo-img { width: 92px; height: 92px; border-radius: 20px; object-fit: cover; margin: 0 auto .85rem; display: block; box-shadow: 0 4px 14px rgba(0,0,0,0.2); }
.auth-card .brand-strip h1 { color: #fff; font-size: 1.1rem; margin: 0; }
.auth-card .brand-strip p { margin: .2rem 0 0; font-size: .76rem; color: rgba(244,246,250,0.65); }
.auth-card .auth-body { padding: 1.75rem; }

.install-shell { max-width: 720px; margin: 2.5rem auto; padding: 0 1rem; }
.install-steps { display: flex; justify-content: space-between; margin-bottom: 1.5rem; }
.install-steps .step { flex: 1; text-align: center; font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: rgba(244,246,250,0.45); position: relative; }
.install-steps .step .dot { width: 30px; height: 30px; margin: 0 auto .4rem; border-radius: 50%; background: rgba(255,255,255,0.12); color: #fff; display: flex; align-items: center; justify-content: center; font-family: var(--font-serif); }
.install-steps .step.active .dot, .install-steps .step.done .dot { background: var(--color-accent); color: var(--color-text-on-accent); }
.install-steps .step.active { color: #fff; }
.req-list { list-style: none; padding: 0; margin: 0; }
.req-list li { display: flex; align-items: center; gap: .6rem; padding: .6rem 0; border-bottom: 1px solid var(--color-border); font-size: .87rem; }
.req-list li:last-child { border-bottom: none; }
.req-list .icon { color: var(--color-success); }
.req-list li.fail .icon { color: var(--color-danger); }

/* Print */
.chart-card canvas, .chart-wrap { max-width: 100%; }

/* ------------------------------------------------------------------ */
/* Responsive                                                          */
/* ------------------------------------------------------------------ */
@media (max-width: 1180px) {
    .stat-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 1024px) {
    .form-row, .form-row.cols-3 { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    .main-area { margin-left: 0; }
    .topbar .menu-toggle { display: flex; }
    .sidebar-overlay.show { display: block; }
}
@media (max-width: 640px) {
    .stat-grid { grid-template-columns: 1fr; }
    .main-content { padding: 1rem; }
    .topbar { padding: 0 .85rem; gap: .6rem; }
    .topbar-clock { display: none; }
    .card-header { padding: .9rem 1rem; }
    .card-body { padding: 1rem; }
    table.data-table th, table.data-table td { padding: .6rem .75rem; }
}

@media print {
    .sidebar, .topbar, .table-toolbar, .pagination, .btn, .no-print { display: none !important; }
    .main-area { margin-left: 0 !important; }
    body { background: #fff; font-size: 11pt; }
    .card { box-shadow: none; border: 1px solid #ccc; }
    .main-content { padding: 0; max-width: 100%; }
}
