/* ── 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;
    /* Radius scale */
    --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);
}


.sr-only {
    position: absolute; width: 1px; height: 1px; padding: 0;
    margin: -1px; overflow: hidden; clip: rect(0,0,0,0);
    white-space: nowrap; border: 0;
}

/* ── 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;
    overflow: hidden;
    z-index: 200;
}

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

/* Button reset included — sidebar header is a <button> for keyboard access */
.sidebar__header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 18px;
    flex-shrink: 0;
    width: 100%;
    border: none;
    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); }
.sidebar--collapsed .sidebar__header { padding: 14px 18px; }

.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; }

.logo-bg {
    width: 42px; height: 38px;
    background: #100;
    border-radius: var(--r-md);
    position: relative; overflow: hidden; flex-shrink: 0;
}
@keyframes logo-pulse {
    0%, 100% {
        /* Dimmer state for non-hover */
        filter: drop-shadow(0 0 2px var(--green)) drop-shadow(0 0 4px rgba(0, 255, 0, 0.3));
    }

    50% {
        /* Slightly brighter state for the pulse */
        filter: drop-shadow(0 0 5px var(--green)) drop-shadow(0 0 10px rgba(0, 255, 0, 0.5));
    }
}

.logo-ellipse {
    position: absolute;
    border-radius: 50%;
    background: var(--green-bright);
    transition: opacity 0.2s, filter 0.3s ease;
    will-change: filter;
    animation: logo-pulse 2s ease-in-out infinite;
}
.logo-ellipse--1 { width: 8px; height: 17px; left: 7px; top: 12px; opacity: 0.4; transform: rotate(-15deg); }
.logo-ellipse--2 { width: 15px; height: 25px; left: 13px; top: 8px; opacity: 1; mix-blend-mode: screen; }
.logo-ellipse--3 { width: 8px; height: 20px; left: 25px; top: 10px; opacity: 0.6; transform: rotate(15deg); }
.logo-bg:hover .logo-ellipse {
    opacity: 1;
    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));
}

.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;
    overflow: hidden;
}
.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 {
    display: flex; align-items: center; justify-content: space-between;
    gap: 8px; width: 100%;
    padding: 8px 12px; border-radius: var(--r-md);
    border: none; 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;
}
.sidebar-personality-item:hover { background: var(--pale); color: var(--green); }
.sidebar-personality-item--active { background: var(--tint); color: var(--green); }
.sidebar-personality-item__name { flex: 1; text-transform: capitalize; }

/* Nav items */
.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 {
    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: none; 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;
}
.sidebar--collapsed .nav-item { gap: 0; }

.nav-item:hover:not(.nav-item--active) { background: rgba(255,255,255,0.35); color: #fff; }
.nav-item--active { background: rgba(255,255,255,0.55); color: #fff; }
.nav-item--disabled { opacity: 0.35; cursor: default; }
.nav-item--disabled:hover { background: transparent !important; color: rgba(255,255,255,0.75) !important; }

.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; }

/* Conversation items in sidebar */
.sidebar-conv-item {
    display: flex; flex-direction: column;
    align-items: flex-start; gap: 2px;
    padding: 8px 10px;
    border-radius: var(--r-md);
    border: none; background: transparent;
    cursor: pointer; text-align: left;
    width: 100%; font: inherit;
    transition: background 0.12s;
}
.sidebar-conv-item:hover { background: rgba(255,255,255,0.35); }
.sidebar-conv-item--active { background: rgba(255,255,255,0.55); }

.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 {
    border: none; background: var(--bg);
    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;
}
.btn-text:hover:not(:disabled) { background: var(--tint); color: var(--green); }
.btn-text:disabled { opacity: 0.45; cursor: default; }

.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 ──────────────────────────────── */
.mobile-menu-btn {
    display: none;
    position: absolute; top: 14px; left: 14px;
    width: 44px; height: 44px;
    align-items: center; justify-content: center;
    background: var(--green); border: none;
    border-radius: var(--r-sm); color: #fff;
    cursor: pointer; z-index: 100;
    box-shadow: 0 2px 8px rgba(0,82,0,0.25);
    transition: opacity 0.12s;
}
.mobile-menu-btn:hover { opacity: 0.88; }

/* ── 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 fills the full width — sidebar no longer pushes it */
    .main-area { padding-left: 0 !important; }
    .shell--sidebar-expanded .main-area { padding-left: 0 !important; }

    /* Sidebar: hidden off-screen when collapsed, slides in when expanded */
    .sidebar {
        left: 0; top: 0; bottom: 0;
        border-radius: 0;
        width: 216px !important;
        transform: translateX(calc(-100% - 10px));
        transition: transform 0.25s ease;
    }
    .sidebar--collapsed { width: 216px !important; }
    .sidebar:not(.sidebar--collapsed) {
        transform: translateX(0);
        box-shadow: 4px 0 32px rgba(0,0,0,0.28);
    }

    /* Backdrop visible when sidebar is open */
    .shell--sidebar-expanded .sidebar-backdrop { display: block; }

    /* Hamburger visible on mobile */
    .mobile-menu-btn { display: flex; }
}

/* 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;
    }
}
