/* ── Tokens ───────────────────────────────────────────────── */
:root {
    --green: #0A6616;
    --green-bright: #16E831;
    --tint: #E5FCE5;
    --pale: #f1fcf1;
    --white: #FFFFFF;
    --bg: #F7F7F7;
    --ink: #1A1A1A;
    --grey: #6B6B6B;
    --grey-light: #9B9B9B;
    --border: #E4E4E4;
    --disabled: #E8E8E8;
    --red: #CD2020;
    --red-border: #FECACA;
    --red-bg: #FEF2F2;
    --r-sm: 8px;
    --r-md: 14px;
    --r-lg: 18px;
    --r-xl: 22px;
    --r-pill: 50px;
}

/* ── Reset ────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
/* margin/padding reset intentionally omitted — Blazor component defaults are relied on */

/* Focus rings — sidebar uses white (high contrast on dark green),
   everything else uses dark green (visible on white/light backgrounds). */
button:focus-visible,
a:focus-visible,
select:focus-visible,
[role="button"]:focus-visible {
    outline: 2px solid var(--green);
    outline-offset: 2px;
    border-radius: var(--r-sm);
}

.sidebar button:focus-visible,
.sidebar a:focus-visible {
    outline-color: rgba(255,255,255,0.85);
}


/* ── Base ─────────────────────────────────────────────────── */
body {
    font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
    font-size: 15px;
    font-weight: 400;
    background: var(--white);
    color: var(--ink);
    height: 100vh; height: 100dvh;
    overflow: hidden;
}

/* ── Scrollbar ────────────────────────────────────────────── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(0,82,0,0.2); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(0,82,0,0.4); }
::-webkit-scrollbar-corner { background: transparent; }
* { scrollbar-color: rgba(0,82,0,0.25) transparent; scrollbar-width: thin; }

/* ── App shell ────────────────────────────────────────────── */
.app-shell {
    display: block;
    position: relative;
    height: 100vh; height: 100dvh;
    overflow: hidden;
}

/* ── Sidebar ──────────────────────────────────────────────── */
.sidebar {
    position: fixed;
    left: 10px;
    top: 10px;
    bottom: 10px;
    width: 200px;
    border-radius: var(--r-lg);
    background: var(--green);
    display: flex;
    flex-direction: column;
    transition: width 0.22s ease;
    /* Visible, not hidden — hover flyouts (.sidebar-item-preview) need to
       escape past the panel edge, which matters most in collapsed/icon-only mode. */
    overflow: visible;
    z-index: 200;
}

.sidebar--collapsed { width: 72px; }

/* Button reset included — sidebar header is a <button> for keyboard access */
.sidebar__header {
    position: relative;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 14px;
    flex-shrink: 0;
    width: 100%;
    border: none;
    /* Self-clips its own top corners since .sidebar's overflow is visible. */
    border-radius: var(--r-lg) var(--r-lg) 0 0;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    background: transparent;
    color: inherit;
    font: inherit;
    text-align: left;
    cursor: pointer;
    user-select: none;
    transition: background 0.12s;
}

.sidebar__header:hover { background: rgba(255,255,255,0.06); }
/* Narrower padding fits the mascot (.logo-bg) inside the fixed 72px collapsed
   width; gap:0 frees up the space margin:auto below needs to center it. */
.sidebar--collapsed .sidebar__header { padding: 14px 12px; gap: 0; }

.logo-name {
    font-size: 14px;
    font-weight: 700;
    color: rgba(255,255,255,0.92);
    letter-spacing: -0.01em;
    white-space: nowrap;
    overflow: hidden;
    width: 110px;
    opacity: 1;
    transition: width 0.22s ease, opacity 0.55s;
    text-shadow: none;
}
.sidebar--collapsed .logo-name { width: 0; opacity: 0; }

/* Overrides the generic 36x36 .nav-icon-wrap; scoped so other sidebar icons are unaffected. */
.sidebar__header .nav-icon-wrap {
    width: 42px; height: 64px;
}
/* margin:auto centers the icon when collapsed (no label to sit left of).
   justify-content:center doesn't work here — Chromium ignores it on <button> flex containers. */
.sidebar--collapsed .sidebar__header .nav-icon-wrap {
    margin: 0 auto;
}
.logo-bg {
    width: 44px; height: 64px;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}
@keyframes logo-pulse {
    0%, 100% {
        filter: drop-shadow(0 0 2px var(--green)) drop-shadow(0 0 4px rgba(0, 255, 0, 0.3));
    }

    50% {
        filter: drop-shadow(0 0 5px var(--green)) drop-shadow(0 0 10px rgba(0, 255, 0, 0.5));
    }
}

/* Same source SVG as favicon.svg. Portrait (320x480), so sized by height not width. */
.vega-full {
    display: block;
    height: 100%; width: auto;
    animation: logo-pulse 2.4s ease-in-out infinite;
}
.logo-bg:hover .vega-full {
    animation: none;
    filter: drop-shadow(0 0 6px var(--green)) drop-shadow(0 0 12px var(--green)) drop-shadow(0 0 24px rgba(0, 255, 0, 0.1));
}

/* Both eyes blink together (unlike the single-eye wink on the compact face variant). */
@keyframes vega-blink {
    0%, 92%, 100% { transform: scaleY(1); }
    95%, 97.5% { transform: scaleY(0.06); }
}
.veye { transform-box: fill-box; transform-origin: center; animation: vega-blink 5.4s ease infinite; }

.sidebar__toggle-icon {
    margin-left: auto;
    flex-shrink: 0;
    color: rgba(255,255,255,0.65);
    transition: transform 0.22s ease, opacity 0.15s, width 0.22s;
    width: 18px;
    overflow: hidden;
}
.sidebar:not(.sidebar--collapsed) .sidebar__toggle-icon { transform: rotate(180deg); }
.sidebar--collapsed .sidebar__toggle-icon { opacity: 0; width: 0; }

.sidebar__nav {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 4px;
}
.sidebar__nav--top { padding: 8px; flex-shrink: 0; }
.sidebar__nav--bottom { flex-shrink: 0; padding: 8px; margin-top: auto; }
.sidebar__nav--middle { flex-shrink: 0; padding: 8px; }

.sidebar__divider {
    height: 1px;
    background: rgba(255,255,255,0.18);
    margin: 2px 12px;
    flex-shrink: 0;
}

.sidebar__middle {
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    /* Visible so Search/Recent's hover flyouts aren't clipped; the recent
       list itself scrolls independently via its own overflow-y:auto. */
    overflow: visible;
}
.sidebar--recent-open .sidebar__middle {
    flex: 1;
    min-height: 0;
}

.sidebar__recent-list {
    display: none;
    flex-direction: column;
    overflow-y: auto;
    padding: 8px 8px 8px;
    gap: 4px;
    flex: 1;
    min-height: 0;
    background: transparent;
}
.sidebar--recent-open .sidebar__recent-list {
    display: flex;
}
.sidebar--collapsed .sidebar__recent-list { display: none; }

.sidebar__personalize-panel {
    display: none; flex-direction: column;
    gap: 4px; padding: 6px 8px; flex-shrink: 0;
}
.sidebar--personalize-open .sidebar__personalize-panel { display: flex; }
.sidebar--collapsed .sidebar__personalize-panel { display: none; }

.sidebar-personality-item {
    position: relative;
    display: flex; align-items: center; justify-content: space-between;
    gap: 8px; width: 100%;
    padding: 8px 12px; border-radius: var(--r-md);
    border: 1px solid transparent; background: transparent;
    font: inherit; font-size: 13px; font-weight: 600;
    color: var(--white); cursor: pointer; text-align: left;
    transition: background 0.12s, color 0.12s, border-color 0.12s, box-shadow 0.12s;
}
/* Higher opacity than other nav/conversation hover states — text flips to dark
   green here, which needs a lighter backdrop to stay legible. */
.sidebar-personality-item:hover {
    background: rgba(241,252,241,0.35);
    border: 1px solid rgba(255,255,255,0.2);
    box-shadow: inset 0 0 5px 2px rgba(255,255,255,0.3);
    backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
    color: var(--green);
}
.sidebar-personality-item--active {
    background: rgba(229,252,229,0.4);
    border: 1px solid rgba(255,255,255,0.3);
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.5), inset 0 0 6px 3px rgba(255,255,255,0.4);
    backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
    color: var(--green);
}
.sidebar-personality-item__name { flex: 1; text-transform: capitalize; }

.nav-icon-wrap {
    width: 36px; height: 36px;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}

.nav-icon { flex-shrink: 0; width: 24px; height: 24px; }

.nav-item {
    position: relative;
    display: flex; flex-direction: row;
    align-items: center;
    padding: 8px 10px 8px 10px;
    gap: 10px;
    width: 100%; height: 40px;
    border-radius: var(--r-md);
    border: 1px solid transparent; background: transparent;
    cursor: pointer; text-decoration: none;
    color: rgba(255,255,255,0.75);
    font: inherit; font-size: 14px; font-weight: 500;
    transition: background 0.12s, color 0.12s, border-color 0.12s, box-shadow 0.12s;
}
.sidebar--collapsed .nav-item { gap: 0; }

.nav-item:hover:not(.nav-item--active) {
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.15);
    box-shadow: inset 0 0 5px 2px rgba(255,255,255,0.25);
    backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
    color: #fff;
}
.nav-item--active {
    background: rgba(255,255,255,0.08);
    border: 1px solid rgba(255,255,255,0.25);
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.4), inset 0 0 6px 3px rgba(255,255,255,0.35);
    backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
    color: #fff;
}
/* ── Shared hover-flyout base (frosted glass) ─────────────────────────
   Shared by the framework picker and deliver-type pills (home.css) and
   sidebar nav (.sidebar-item-preview, below). */
.flyout-card {
    display: flex; flex-direction: column; gap: 2px;
    background: rgba(255,255,255,0.8);
    backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(255,255,255,0.7);
    border-radius: var(--r-md);
    box-shadow: 0 6px 20px rgba(0,0,0,0.14), inset 0 1px 0 rgba(255,255,255,0.6);
    padding: 8px 10px;
    text-align: left; white-space: normal;
    opacity: 0; pointer-events: none;
    transition: opacity 0.1s ease, transform 0.1s ease;
    z-index: 20;
}
.flyout-card__name { font-size: 11.5px; font-weight: 700; color: var(--ink); }
.flyout-card__text {
    font-size: 11px; font-weight: 400; line-height: 1.42; color: var(--grey);
    display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical;
    overflow: hidden;
}
/* Caret fill matches the card's own translucent glass rather than solid
   white, so it blends instead of reading as a mismatched opaque tab */
.flyout-card::before, .flyout-card::after {
    content: ""; position: absolute; width: 7px; height: 7px;
    transform: rotate(45deg); border-radius: 1px;
}
.flyout-card::before { background: rgba(255,255,255,0.7); }
.flyout-card::after { background: rgba(255,255,255,0.8); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); }

/* Colour-tinted variant of .flyout-card, driven by --fc-color (set inline
   per-framework, or fixed for sign-out below). */
.flyout-card--tinted {
    background: color-mix(in srgb, var(--fc-color, var(--green)) 22%, rgba(255,255,255,0.55) 78%);
    border-color: color-mix(in srgb, var(--fc-color, var(--green)) 42%, rgba(255,255,255,0.6) 58%);
}
.flyout-card--tinted::before {
    background: color-mix(in srgb, var(--fc-color, var(--green)) 30%, rgba(255,255,255,0.6) 70%);
}
.flyout-card--tinted::after {
    background: color-mix(in srgb, var(--fc-color, var(--green)) 22%, rgba(255,255,255,0.55) 78%);
}
.flyout-card--tinted .flyout-card__text { color: var(--ink); }

/* ── Sidebar hover flyouts ────────────────────────────────── */
.sidebar-item-preview {
    position: absolute; left: calc(100% + 12px); top: 50%;
    transform: translateY(-50%) translateX(-6px) scale(0.97);
    transform-origin: left center;
    width: max-content; max-width: 200px;
}
/* Delay only on the way in, so passing over several rows doesn't flash every flyout. */
.nav-item:hover .sidebar-item-preview,
.nav-item:focus-visible .sidebar-item-preview,
.sidebar__header:hover .sidebar-item-preview,
.sidebar__header:focus-visible .sidebar-item-preview,
.sidebar-personality-item:hover .sidebar-item-preview,
.sidebar-personality-item:focus-visible .sidebar-item-preview {
    opacity: 1; transform: translateY(-50%) translateX(0) scale(1);
    transition: opacity 0.15s ease 0.1s, transform 0.15s ease 0.1s;
}
.sidebar-item-preview.flyout-card::before,
.sidebar-item-preview.flyout-card::after { top: 50%; transform: translateY(-50%) rotate(45deg); }
.sidebar-item-preview.flyout-card::before { left: -5px; }
.sidebar-item-preview.flyout-card::after { left: -4px; }

.nav-label {
    font-size: 14px; font-weight: 500;
    color: inherit;
    flex: 1; text-align: left;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    width: 120px; opacity: 1;
    transition: width 0.22s ease, opacity 0.15s 0.06s;
}
.sidebar--collapsed .nav-label { width: 0; opacity: 0; transition: width 0.22s ease, opacity 0.1s; }
.nav-label--muted { opacity: 0.4; }
.nav-label--profile { text-transform: capitalize; }

.nav-avatar {
    width: 18px; height: 18px;
    display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}

.nav-item__chevron {
    margin-left: auto; flex-shrink: 0;
    color: rgba(255,255,255,0.65);
    width: 14px; overflow: hidden;
    transition: transform 0.18s ease, opacity 0.15s, width 0.22s ease;
}
.nav-item__chevron--open { transform: rotate(180deg); }
.sidebar--collapsed .nav-item__chevron { opacity: 0; width: 0; }

.sidebar-conv-item {
    display: flex; flex-direction: column;
    align-items: flex-start; gap: 2px;
    padding: 8px 10px;
    border-radius: var(--r-md);
    border: 1px solid transparent; background: transparent;
    cursor: pointer; text-align: left;
    width: 100%; font: inherit;
    transition: background 0.12s, border-color 0.12s, box-shadow 0.12s;
}
.sidebar-conv-item:hover {
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.15);
    box-shadow: inset 0 0 5px 2px rgba(255,255,255,0.25);
    backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
}
.sidebar-conv-item--active {
    background: rgba(255,255,255,0.08);
    border: 1px solid rgba(255,255,255,0.25);
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.4), inset 0 0 6px 3px rgba(255,255,255,0.35);
    backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
}

.sidebar-conv-item__title {
    font-size: 13px; font-weight: 500;
    color: rgba(255,255,255,0.82);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    width: 100%; text-transform: capitalize;
}
.sidebar-conv-item__date { font-size: 11px; color: rgba(255,255,255,0.55); }
.sidebar-conv-empty { font-size: 13px; color: rgba(255,255,255,0.55); padding: 8px 10px; }

/* ── Main area ────────────────────────────────────────────── */
.main-area {
    position: absolute; inset: 0;
    padding-left: 98px;
    transition: padding-left 0.22s ease;
    display: flex; flex-direction: column;
    overflow: hidden;
    background:
        linear-gradient(to right,  white 0%, transparent 18%, transparent 82%, white 100%),
        linear-gradient(to bottom, white 0%, transparent 18%, transparent 82%, white 100%),
        linear-gradient(rgba(255,255,255,0.60), rgba(255,255,255,0.60)),
        url('/Intellivega-background.webp') calc(50% + 150px) calc(50% + 200px) / cover no-repeat fixed;
}
.shell--sidebar-expanded .main-area { padding-left: 226px; }

/* ── Floating top-right actions ───────────────────────────── */
.topbar-float-actions {
    position: absolute;
    top: 14px; right: 18px;
    display: flex; align-items: center; gap: 6px;
    z-index: 100;
}

/* ── Shared buttons ───────────────────────────────────────── */
.btn-text {
    position: relative;
    border: 1px solid rgba(255,255,255,0.6); background: rgba(255,255,255,0.35);
    backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.5), 0 2px 8px rgba(0,0,0,0.05);
    font: inherit; font-size: 13px; font-weight: 600;
    color: var(--grey);
    cursor: pointer; padding: 4px 12px;
    border-radius: var(--r-md);
    flex-shrink: 0; text-decoration: none;
    transition: background 0.12s, color 0.12s, border-color 0.12s, box-shadow 0.12s;
}
.btn-text:hover:not(:disabled) {
    background: rgba(10,102,22,0.12); border-color: rgba(10,102,22,0.3);
    box-shadow: inset 0 0 6px 2px rgba(10,102,22,0.15), 0 2px 8px rgba(0,0,0,0.05);
    color: var(--green);
}
.btn-text:disabled { opacity: 0.45; cursor: default; }

.btn-text--signout {
    background: rgba(205,32,32,0.14); border-color: rgba(205,32,32,0.4);
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.4), inset 0 0 6px 2px rgba(205,32,32,0.15), 0 2px 8px rgba(0,0,0,0.05);
    color: var(--red);
}
.btn-text--signout:hover:not(:disabled) {
    background: rgba(205,32,32,0.24); border-color: rgba(205,32,32,0.55);
    box-shadow: inset 0 0 8px 3px rgba(205,32,32,0.25), 0 2px 8px rgba(0,0,0,0.05);
    color: var(--red);
}

/* Right-anchored, not centered — this button sits at the top-right corner
   of the viewport, where a centered flyout would run off the edge. */
.btn-text-preview {
    --fc-color: var(--red);
    position: absolute; top: calc(100% + 8px); right: 0;
    transform: translateY(-6px) scale(0.97);
    transform-origin: top right;
    width: max-content; max-width: 190px;
    z-index: 20;
}
.btn-text--signout:hover .btn-text-preview,
.btn-text--signout:focus-visible .btn-text-preview {
    opacity: 1; transform: translateY(0) scale(1);
    transition: opacity 0.15s ease 0.1s, transform 0.15s ease 0.1s;
}
.btn-text-preview.flyout-card::before,
.btn-text-preview.flyout-card::after { right: 14px; transform: rotate(45deg); }
.btn-text-preview.flyout-card::before { top: -5px; }
.btn-text-preview.flyout-card::after { top: -4px; }

.logout-form { display: inline; margin: 0; }

/* ── Error & not-found pages ──────────────────────────────── */
.error-page {
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    min-height: calc(100vh - 120px);
    gap: 14px; text-align: center; padding: 40px 24px;
}
.error-page__icon { margin-bottom: 6px; opacity: 0.8; }
.error-page__title { font-size: 22px; font-weight: 800; color: var(--ink); }
.error-page__desc { font-size: 14px; color: var(--ink); max-width: 360px; line-height: 2; }
.error-page__btn {
    margin-top: 6px; display: inline-block;
    padding: 9px 22px; background: var(--red);
    color: #fff; border-radius: var(--r-md);
    font-size: 14px; font-weight: 600;
    text-decoration: none; transition: opacity 0.12s;
}
.error-page__btn:hover { color: #fff; opacity: 0.88; }

/* ── Mobile hamburger button ──────────────────────────────── */
/* Same solid-green language as .btn-text--primary (Create account) — icon-only, square variant. */
.mobile-menu-btn {
    display: none;
    position: absolute; top: 14px; left: 14px;
    width: 44px; height: 44px;
    align-items: center; justify-content: center;
    border: 1px solid var(--green); background: var(--green);
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.25), 0 2px 8px rgba(0,0,0,0.12);
    border-radius: var(--r-md); color: #fff;
    cursor: pointer; z-index: 100;
    transition: background 0.12s, color 0.12s, border-color 0.12s, box-shadow 0.12s;
}
.mobile-menu-btn:hover {
    background: color-mix(in srgb, var(--green) 85%, black 15%);
    border-color: color-mix(in srgb, var(--green) 85%, black 15%);
    color: #fff;
}

/* ── Sidebar backdrop (mobile overlay scrim) ──────────────── */
.sidebar-backdrop {
    display: none;
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 199;
    cursor: pointer;
}

/* ── Responsive ───────────────────────────────────────────── */

/* Tablet (768–1024px): sidebar auto-collapsed via JS; layout otherwise unchanged */
@media (max-width: 1024px) {
    .topbar-float-actions { top: 10px; right: 12px; }
    .btn-text { font-size: 12px; padding: 4px 9px; }
}

/* Mobile (≤ 767px): sidebar becomes a slide-in overlay drawer */
@media (max-width: 767px) {
    .main-area { padding-left: 0 !important; }
    .shell--sidebar-expanded .main-area { padding-left: 0 !important; }

    .sidebar {
        left: 0; top: 0; bottom: 0;
        border-radius: 0;
        width: 216px !important;
        transform: translateX(calc(-100% - 10px));
        transition: transform 0.25s ease;
    }
    .sidebar__header { border-radius: 0; }
    .sidebar--collapsed { width: 216px !important; }
    .sidebar:not(.sidebar--collapsed) {
        transform: translateX(0);
        box-shadow: 4px 0 32px rgba(0,0,0,0.28);
    }

    .shell--sidebar-expanded .sidebar-backdrop { display: block; }
    .mobile-menu-btn { display: flex; }

    /* No reliable hover on touch, and labels are already visible in the full-width overlay. */
    .sidebar-item-preview { display: none; }
}

/* Pocket (≤ 480px): tighten shell chrome */
@media (max-width: 480px) {
    .topbar-float-actions { top: 8px; right: 8px; }
    .mobile-menu-btn { top: 8px; left: 8px; width: 40px; height: 40px; }
    .btn-text { font-size: 12px; padding: 4px 8px; }
}

/* ── Motion preferences ───────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
