/* ═══════════════════════════════════════════════════════════════════════════
   ActiGenie's own look (design/ACTIGENIE_LOOK_PLAN.md, step 8 slice 5).
   Every page a customer can reach wears this; SuperAdmin-only pages keep Fekra's site.css look.
   Light only. Palette and type come from brand/README.md: warm Paper, Ink, Ember and
   Plus Jakarta Sans. No mono, no all-caps labels, bubble-shaped corners from the logo.

   Loaded after bootstrap and site.css. site.css still gives the library, billing and usage
   pages their structure; every colour, font and corner it uses is re-pointed here.
   ═══════════════════════════════════════════════════════════════════════════ */

:root.ag {
    /* ActiGenie tokens */
    --ag-page: #FAF8F4;          /* Paper */
    --ag-raised: #FFFFFF;
    --ag-sunk: #F2EEE7;
    --ag-line: #E6E2DA;          /* Sand */
    --ag-line-strong: #D6D0C5;
    --ag-ink: #1B1A1F;           /* Ink */
    --ag-ink-soft: #4A4750;
    --ag-muted: #6B6872;         /* Stone, 5.1:1 on Paper */
    --ag-ember: #EE4F2B;         /* brand colour: large shapes and marks only */
    --ag-ember-deep: #C73A1B;    /* text and filled buttons (white text 4.9:1) */
    --ag-ember-press: #A8301A;
    --ag-ember-wash: #FDE9E2;
    --ag-cream: #FFF6EE;
    --ag-night: #141317;
    --ag-mist: #9C99A3;
    --ag-ok: #2F7A4E;
    --ag-ok-wash: #E5F2EA;
    --ag-warn: #8A5300;
    --ag-warn-wash: #FBF0DC;
    --ag-bad: #B42318;
    --ag-bad-wash: #FCE8E6;
    --ag-font: "Plus Jakarta Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
    --ag-r-sm: 10px;
    --ag-r: 14px;
    --ag-r-lg: 20px;
    --ag-r-xl: 28px;
    /* The logo's speech bubble: round, with its tail curled at the bottom left. */
    --ag-bubble: 16px 16px 16px 4px;
    --ag-bubble-lg: 24px 24px 24px 8px;
    --ag-shadow: 0 1px 2px rgba(27, 26, 31, .04), 0 8px 28px rgba(27, 26, 31, .06);
    --ag-focus: 0 0 0 3px rgba(238, 79, 43, .22);
    --ag-dock: 76px;

    /* Fekra's tokens, re-pointed so the shared components follow ActiGenie */
    --bg-base: var(--ag-page);
    --bg-surface: var(--ag-raised);
    --bg-surface-hover: var(--ag-sunk);
    --border-subtle: var(--ag-line);
    --border-strong: var(--ag-line-strong);
    --text-primary: var(--ag-ink);
    --text-secondary: var(--ag-ink-soft);
    --text-muted: var(--ag-muted);
    --text-on-dark-muted: var(--ag-mist);
    --brand-accent: var(--ag-ember-deep);
    --brand-accent-strong: var(--ag-ember-press);
    --brand-accent-rgb: 199, 58, 27;
    --brand-muted: var(--ag-ember-deep);
    --brand-red: var(--ag-bad);
    --brand-green: var(--ag-ok);
    --brand-amber: #B87500;
    --brand-purple: #6E4BB5;
    --brand-purple-fill: #6E4BB5;
    --status-success-text: var(--ag-ok);
    --status-warning-text: var(--ag-warn);
    --status-danger-text: var(--ag-bad);
    --status-neutral-text: var(--ag-ink-soft);
    --on-accent: #FFFFFF;
    --card-shadow: var(--ag-shadow);
    --card-shadow-hover: 0 2px 4px rgba(27, 26, 31, .05), 0 14px 36px rgba(27, 26, 31, .09);
    --btn-shadow: none;
    --btn-shadow-hover: none;
    --btn-outline-hover: var(--ag-sunk);
    --btn-dark-brand-bg: var(--ag-raised);
    --btn-secondary-bg: var(--ag-sunk);
    --btn-secondary-hover: var(--ag-line);
    --btn-brand-hover-bg: var(--ag-ember-press);
    --input-bg: var(--ag-raised);
    --input-bg-focus: var(--ag-raised);
    --input-focus-shadow: var(--ag-focus);
    --upload-zone-bg: var(--ag-sunk);
    --chat-bubble-other-bg: var(--ag-sunk);
    --sidebar-active-bg: var(--ag-ember-wash);
    --topbar-bg: var(--ag-page);
    --topbar-height: 0px;
    --radius-sm: var(--ag-r-sm);
    --radius-md: var(--ag-r);
    --radius-lg: var(--ag-r-lg);
    --radius-xl: var(--ag-r-xl);

    /* Bootstrap */
    --bs-body-font-family: var(--ag-font);
    --bs-body-bg: var(--ag-page);
    --bs-body-color: var(--ag-ink);
    --bs-secondary-color: var(--ag-muted);
    --bs-emphasis-color: var(--ag-ink);
    --bs-border-color: var(--ag-line);
    --bs-link-color: var(--ag-ember-deep);
    --bs-link-color-rgb: 199, 58, 27;
    --bs-link-hover-color: var(--ag-ember-press);
    --bs-link-hover-color-rgb: 168, 48, 26;
    --bs-primary-rgb: 199, 58, 27;
    --bs-border-radius: var(--ag-r-sm);
    --bs-border-radius-lg: var(--ag-r);
    color-scheme: light;
}

/* ── Type: Plus Jakarta Sans everywhere, sentence case, no tracking games ── */
:root.ag { font-family: var(--ag-font); }
:root.ag body {
    font-family: var(--ag-font);
    font-size: 15px;
    line-height: 1.6;
    background: var(--ag-page);
    color: var(--ag-ink);
    -webkit-font-smoothing: antialiased;
}
:root.ag body *:not(code, pre, kbd, samp) { font-family: inherit; }
:root.ag * { text-transform: none; }
/* Tracking, heading weight and colour stay weak (zero-specificity :where) so component rules can set them. */
:where(:root.ag) * { letter-spacing: normal; }
:where(:root.ag) :is(h1, h2, h3, h4, .h1, .h2, .h3, .h4) { color: var(--ag-ink); font-weight: 800; line-height: 1.2; letter-spacing: -.025em; }
:where(:root.ag) :is(h5, h6, .h5, .h6) { color: var(--ag-ink); font-weight: 700; }
:where(:root.ag) a { color: var(--ag-ember-deep); text-underline-offset: .2em; }
:where(:root.ag) a:hover { color: var(--ag-ember-press); }
:root.ag ::selection { background: var(--ag-ember-wash); color: var(--ag-ink); }
:root.ag :focus-visible { outline: 2px solid var(--ag-ember); outline-offset: 2px; }
:root.ag .text-secondary { color: var(--ag-ink-soft) !important; }
:root.ag .text-muted { color: var(--ag-muted) !important; }
:root.ag .text-brand, :root.ag .text-primary { color: var(--ag-ember-deep) !important; }

/* ── Buttons: the bubble corner marks every primary action ── */
:root.ag :is(.btn-brand, .ag-btn--primary) {
    background: var(--ag-ember-deep); border: 1px solid var(--ag-ember-deep); color: #fff;
    border-radius: var(--ag-bubble); font-weight: 700; padding: 10px 20px; transform: none; box-shadow: none;
}
:root.ag :is(.btn-brand, .ag-btn--primary):hover,
:root.ag :is(.btn-brand, .ag-btn--primary):focus-visible { background: var(--ag-ember-press); border-color: var(--ag-ember-press); color: #fff; transform: none; }
:root.ag :is(.btn-brand-outline, .btn-dark-brand, .btn-outline-primary, .btn-outline-secondary, .btn-secondary, .btn-light) {
    background: var(--ag-raised); border: 1px solid var(--ag-line-strong); color: var(--ag-ink);
    border-radius: var(--ag-r); font-weight: 600; box-shadow: none;
}
:root.ag :is(.btn-brand-outline, .btn-dark-brand, .btn-outline-primary, .btn-outline-secondary, .btn-secondary, .btn-light):hover {
    background: var(--ag-sunk); border-color: var(--ag-ink); color: var(--ag-ink);
}
:root.ag .btn { border-radius: var(--ag-r); font-weight: 600; }
:root.ag .btn-primary { background: var(--ag-ember-deep); border-color: var(--ag-ember-deep); color: #fff; border-radius: var(--ag-bubble); }
:root.ag .btn-primary:hover { background: var(--ag-ember-press); border-color: var(--ag-ember-press); }
:root.ag .btn-close { filter: none !important; }

.ag-btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    min-height: 44px; padding: 10px 20px; border: 1px solid transparent; border-radius: var(--ag-r);
    font: inherit; font-weight: 700; line-height: 1.3; text-decoration: none; cursor: pointer;
    transition: background-color .16s, border-color .16s, color .16s;
}
.ag-btn svg { width: 18px; height: 18px; }
.ag-btn--quiet { background: var(--ag-raised); border-color: var(--ag-line-strong); color: var(--ag-ink); }
.ag-btn--quiet:hover { background: var(--ag-sunk); border-color: var(--ag-ink); color: var(--ag-ink); }
.ag-btn--ink { background: var(--ag-ink); color: var(--ag-cream); border-radius: var(--ag-bubble); }
.ag-btn--ink:hover { background: #000; color: var(--ag-cream); }
.ag-btn:disabled { opacity: .6; cursor: default; }

/* ── Forms ── */
:root.ag :is(.form-control, .form-select) {
    background-color: var(--ag-raised); border: 1px solid var(--ag-line-strong); color: var(--ag-ink);
    border-radius: var(--ag-r); padding: 11px 14px; min-height: 46px;
}
:root.ag :is(.form-control, .form-select):focus { border-color: var(--ag-ember); box-shadow: var(--ag-focus); outline: none; }
:root.ag .form-label { color: var(--ag-ink); font-weight: 600; font-size: .9rem; }
:root.ag .form-check-input:checked { background-color: var(--ag-ember-deep); border-color: var(--ag-ember-deep); }
:root.ag .form-check-input:focus { box-shadow: var(--ag-focus); border-color: var(--ag-ember); }
:root.ag .text-danger { color: var(--ag-bad) !important; }
:root.ag .validation-summary-valid { display: none; }

/* ── Surfaces ── */
:root.ag .card { background: var(--ag-raised); border: 1px solid var(--ag-line); border-radius: var(--ag-r-lg); box-shadow: none; }
:root.ag .card.shadow-sm { box-shadow: var(--ag-shadow) !important; }
:root.ag .card-header { background: transparent; border-bottom: 1px solid var(--ag-line); border-radius: var(--ag-r-lg) var(--ag-r-lg) 0 0 !important; font-size: 1rem; }
:root.ag .modal-content { background: var(--ag-raised); border: 1px solid var(--ag-line); border-radius: var(--ag-r-xl); box-shadow: 0 30px 80px rgba(27, 26, 31, .18); }
:root.ag .modal-header, :root.ag .modal-footer { border-color: var(--ag-line); }
:root.ag .modal-backdrop.show { opacity: .4; }
:root.ag .dropdown-menu { border: 1px solid var(--ag-line); border-radius: var(--ag-r); box-shadow: var(--ag-shadow); }

:root.ag .table { --bs-table-color: var(--ag-ink) !important; }
:root.ag .table thead th { color: var(--ag-muted) !important; font-size: .82rem; font-weight: 700; padding: 12px 14px; letter-spacing: 0; }
:root.ag .table tbody td { padding: 14px; }
:root.ag .badge { border-radius: 999px; font-weight: 700; padding: .35em .75em; letter-spacing: 0; }

:root.ag .alert { border-radius: var(--ag-r); border: 1px solid var(--ag-line); color: var(--ag-ink); padding: 12px 16px; }
:root.ag .alert-success { background: var(--ag-ok-wash); border-color: #CDE5D6; border-left: 0; }
:root.ag .alert-danger { background: var(--ag-bad-wash); border-color: #F4CCC7; border-left: 0; }
:root.ag .alert-warning { background: var(--ag-warn-wash); border-color: #F0DDB8; border-left: 0; }
:root.ag .alert-info { background: var(--ag-raised); border-color: var(--ag-line); border-left: 0; }

:root.ag .progress { background: var(--ag-sunk); border-radius: 999px; }
:root.ag :is(.text-bg-primary, .text-bg-info) { background-color: var(--ag-ember-wash) !important; color: var(--ag-ember-deep) !important; border-color: transparent !important; }
:root.ag .asset-tag-chip { border-radius: 999px; padding: 2px 9px; background: var(--ag-ember-wash); border-color: transparent; color: var(--ag-ember-deep); }
:root.ag .asset-tag-chip.active { background: var(--ag-ink); color: var(--ag-cream); }
:root.ag .upload-zone { border: 1.5px dashed var(--ag-line-strong); border-radius: var(--ag-r-lg); background: var(--ag-page); }
:root.ag .upload-zone:hover, :root.ag .upload-zone.dragover { border-color: var(--ag-ember); background: var(--ag-ember-wash); }

:root.ag .loading-overlay { background: rgba(250, 248, 244, .86); backdrop-filter: blur(6px); color: var(--ag-ink); }
:root.ag .loading-spinner { border-color: var(--ag-line); border-top-color: var(--ag-ember); border-right-color: var(--ag-ember); }
:root.ag .loading-text { font-weight: 700; letter-spacing: 0; }

:root.ag .skip-link { background: var(--ag-ink); color: var(--ag-cream); border-radius: var(--ag-r-sm); }

/* ── App shell: a slim dock replaces Fekra's header and production rail ── */
.ag-shell { display: grid; grid-template-columns: var(--ag-dock) minmax(0, 1fr); min-height: 100vh; min-height: 100dvh; }
.ag-dock {
    position: sticky; top: 0; z-index: 1000; height: 100vh; height: 100dvh;
    display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 16px 0 14px;
    border-right: 1px solid var(--ag-line); background: var(--ag-page);
}
.ag-dock__mark { display: grid; place-items: center; width: 44px; height: 44px; margin-bottom: 14px; border-radius: 14px; }
.ag-dock__mark img { width: 36px; height: 36px; }
.ag-dock__link {
    display: grid; justify-items: center; gap: 3px; width: 62px; padding: 8px 0 7px; border-radius: 16px;
    color: var(--ag-muted); text-decoration: none; font-size: .7rem; font-weight: 700; line-height: 1.1;
}
.ag-dock__link svg { width: 22px; height: 22px; stroke-width: 1.8; }
.ag-dock__link:hover { background: var(--ag-sunk); color: var(--ag-ink); }
.ag-dock__link[aria-current="page"] { background: var(--ag-ember-wash); color: var(--ag-ember-deep); }
.ag-dock__spacer { flex: 1; }
.ag-dock__me {
    display: grid; place-items: center; width: 38px; height: 38px; margin-top: 6px; padding: 0;
    border: 0; border-radius: 50%; background: var(--ag-ink); color: var(--ag-cream);
    font: inherit; font-weight: 800; font-size: .9rem; cursor: pointer;
}
.ag-dock__me:hover { background: var(--ag-ember-deep); }

.ag-menu {
    position: fixed; inset: auto auto 14px calc(var(--ag-dock) + 8px); margin: 0;
    width: 260px; padding: 8px; border: 1px solid var(--ag-line); border-radius: 20px 20px 20px 6px;
    background: var(--ag-raised); color: var(--ag-ink); box-shadow: 0 20px 50px rgba(27, 26, 31, .16);
}
.ag-menu__who { padding: 8px 10px 10px; border-bottom: 1px solid var(--ag-line); margin-bottom: 6px; }
.ag-menu__who small { display: block; color: var(--ag-muted); font-size: .78rem; }
.ag-menu__who strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ag-menu a, .ag-menu button {
    display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 10px; border: 0; border-radius: 12px;
    background: none; color: var(--ag-ink); font: inherit; font-weight: 600; text-align: left; text-decoration: none; cursor: pointer;
}
.ag-menu a:hover, .ag-menu button:hover { background: var(--ag-sunk); color: var(--ag-ink); }
.ag-menu svg { width: 18px; height: 18px; color: var(--ag-muted); }
.ag-menu form { margin: 0; }

.ag-main { position: relative; min-width: 0; }
.ag-page { max-width: 1120px; margin: 0 auto; padding: 40px 40px 64px; }
.ag-page > .page-header, .ag-page .page-header { border-bottom: 0; padding-bottom: 0; margin-bottom: 28px; }
:root.ag .page-header h1 { font-size: 2rem; font-weight: 800; letter-spacing: -.03em; }
:root.ag .page-header h1 svg { color: var(--ag-ember) !important; }
.ag-flash { margin-bottom: 20px; }
.ag-narrow { max-width: 520px; margin: 0 auto; }
/* Cut-out artwork (a white logo on transparency) stays visible on a checkerboard. */
.ag-checker { background: repeating-conic-gradient(#BDB7AE 0% 25%, #DCD7CF 0% 50%) 50% / 14px 14px !important; }
/* Credits and billing */
.ag-credits { display: flex; flex-wrap: wrap; gap: 12px; margin-bottom: 20px; }
.ag-credits > div { display: grid; gap: 2px; min-width: 180px; padding: 16px 20px; border: 1px solid var(--ag-line); border-radius: var(--ag-r-lg); background: var(--ag-raised); }
.ag-credits span { color: var(--ag-muted); font-size: .84rem; font-weight: 700; }
.ag-credits strong { font-size: 1.3rem; font-weight: 800; letter-spacing: -.02em; }
.ag-credits .ag-credits__main { background: var(--ag-ember-wash); border-color: transparent; }
.ag-credits__main strong { font-size: 2.2rem; color: var(--ag-ember-deep); line-height: 1.1; }
.ag-credits__main small { color: var(--ag-muted); font-weight: 600; }
.ag-credits__more { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 8px; }
.ag-credits__more h2 { margin: 0 0 4px; font-size: 1.15rem; }
.ag-credits__more p { margin: 0; color: var(--ag-ink-soft); max-width: 60ch; }
.ag-chip {
    display: inline-flex; align-items: center; gap: 6px; padding: 7px 14px; border: 1px solid var(--ag-line-strong); border-radius: 999px;
    background: var(--ag-raised); color: var(--ag-ink-soft); font-size: .86rem; font-weight: 700; text-decoration: none;
}
.ag-chip svg { width: 14px; height: 14px; }
.ag-chip:hover { border-color: var(--ag-ink); color: var(--ag-ink); }
.ag-chip.is-active { background: var(--ag-ink); border-color: var(--ag-ink); color: var(--ag-cream); }
.ag-panel { padding: 28px; border: 1px solid var(--ag-line); border-radius: var(--ag-bubble-lg); background: var(--ag-raised); }

/* Credit authorisation strip (shared partial) */
:root.ag .credit-authorization { border: 1px solid var(--ag-line); border-radius: var(--ag-r-lg); background: var(--ag-raised); padding: 14px 18px; }
:root.ag .credit-authorization__balance { color: var(--ag-ember-deep); }

@media (max-width: 760px) {
    :root.ag { --ag-dock: 0px; }
    .ag-shell { grid-template-columns: minmax(0, 1fr); }
    .ag-dock {
        position: fixed; inset: auto 0 0 0; top: auto; height: auto; z-index: 1100;
        flex-direction: row; justify-content: space-around; padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
        border-right: 0; border-top: 1px solid var(--ag-line); background: rgba(250, 248, 244, .96); backdrop-filter: blur(8px);
    }
    .ag-dock__mark, .ag-dock__spacer { display: none; }
    .ag-dock__me { margin: 0; }
    .ag-main { padding-bottom: 72px; }
    .ag-menu { inset: auto 8px 74px auto; width: min(280px, calc(100vw - 16px)); border-radius: 20px 20px 6px 20px; }
    .ag-page { padding: 24px 16px 40px; }
    :root.ag .page-header h1 { font-size: 1.6rem; }
}

@media (prefers-reduced-motion: reduce) {
    :root.ag *, :root.ag *::before, :root.ag *::after { transition: none !important; animation: none !important; }
}
