:root {
    --bg: #f6f8fc;                 /* Solid app background */
    --bg-elev: #ffffff;            /* Solid elevated surfaces (sidebar, composer, cards) */
    --text: #0f1115;               /* High contrast text */
    --muted: #606a78;              /* Muted text */
    --primary: #5b8cff;            /* Brand color */
    --primary-600: #3e6bff;
    --border: rgba(17, 24, 39, 0.14); /* Slightly stronger borders for clarity */
    --chip-bg: rgba(35, 98, 255, 0.10);

    --bubble-user-bg: #eaf1ff;
    --bubble-user-border: #cfdcff;

    --bubble-assist-bg: #ffffff;
    --bubble-assist-border: #e5e7eb;

    --shadow: 0 10px 24px rgba(2, 6, 23, 0.06);
    --code-bg: #0f172a;
    --code-text: #e2e8f0;
    --link: #2563eb;
    --accent: #22d3ee;
    --item-hover-bg: rgba(25, 79, 217, 0.868);
    --item-active-bg: rgba(25, 79, 217, 0.868);
    color-scheme: light;
}

[data-theme="dark"] {
    --bg: #0d1117;                 /* Solid dark background */
    --bg-elev: #0f141c;            /* Solid elevated surfaces (no glass) */
    --text: #e6e8eb;               /* High contrast text */
    --muted: #99a3b0;
    --primary: #7aa2ff;
    --primary-600: #93b1ff;
    --border: rgba(255, 255, 255, 0.12); /* Slightly stronger than before */
    --chip-bg: rgba(122,162,255,0.15);

    --bubble-user-bg: #0f1a2e;
    --bubble-user-border: rgba(122,162,255,0.35);

    --bubble-assist-bg: #121826;
    --bubble-assist-border: rgba(255,255,255,0.10);

    --shadow: 0 10px 30px rgba(0,0,0,0.40);
    --code-bg: #0b1220;
    --code-text: #dbeafe;
    --link: #8ab4ff;
    --accent: #60a5fa;
    --item-hover-bg: rgba(122,162,255,0.16);
    --item-active-bg: rgba(122,162,255,0.26);
    color-scheme: dark;
}

/* Custom selection color */
::selection {
    background-color: #007FFF; /* Electric Azure Blue */
    color: white;
    text-shadow: none;
}
::-moz-selection {
    background-color: #007FFF; /* Electric Azure Blue */
    color: white;
    text-shadow: none;
}

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

html, body {
    height: 100%;
    overflow: hidden; /* Only messages pane should scroll */
}
/* Ensure root background matches app surface (covers iOS Safari safe areas) */
html {
    background: var(--bg);
}

body {
    background: var(--bg);
    color: var(--text);
    font-family: "Inter", system-ui, -apple-system, Segoe UI, Roboto, "Helvetica Neue", Arial, "Noto Sans", "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", sans-serif;
}

.brand-logo { display: none !important; font-size: 0 !important; }

/* Brand hero: compact header */
.brand-hero {
    position: relative;
    padding: 2px 6px 0 6px;
    text-align: center;
    isolation: isolate;
}
.brand-hero::before {
    content: "";
    display: none;
}
.brand-hero::after {
    content: "";
    display: none;
}

.brand-text {
    position: relative;
    z-index: 1;
    letter-spacing: 0.35px;
    font-size: 25px;
    /* Layered gradients clipped to text: core multi-blue + internal luminous highlight */
    background-image:
        linear-gradient(120deg,
            #bfe3ff 0%,
            #93c5fd 16%,
            #60a5fa 32%,
            #3b82f6 50%,
            #2563eb 68%,
            #1d4ed8 84%,
            #0ea5e9 100%),
        radial-gradient(120% 180% at 80% 50%,
            rgba(191,227,255,0.65) 0%,
            rgba(59,130,246,0.35) 35%,
            rgba(29,78,216,0.00) 70%);
    background-size: 240% 100%, 200% 100%;
    background-position: 0% 50%, 100% 50%;
    background-repeat: no-repeat;
    background-blend-mode: screen;
    -webkit-background-clip: text;
            background-clip: text;
    color: transparent;
    -webkit-text-fill-color: transparent; /* Safari support */
    animation: brandTextShift 10s ease-in-out infinite alternate;
    will-change: background-position;
}

/* Brand text animated multi-blue gradient within glyphs (no outside glow) */
@keyframes brandTextShift {
    0% {
        background-position: 0% 50%, 100% 50%;
    }
    50% {
        background-position: 100% 50%, 0% 50%;
    }
    100% {
        background-position: 0% 50%, 100% 50%;
    }
}

@media (prefers-reduced-motion: reduce) {
    .brand-text {
        animation: none !important;
        background-position: 50% 50%, 50% 50% !important;
    }
}

/* Layout */
.app-shell {
    height: 100dvh;
    padding: 0;
    overflow: hidden;
}

.sidebar {
    min-width: 260px;
    min-height: 100%;
    max-height: 100%;
    display: flex;
    flex-direction: column;
    overflow: hidden; /* chat list scrolls, not the whole sidebar */
    background: var(--bg-elev); /* solid surface */
    border-right: 1px solid var(--border);
}

.sidebar-offcanvas { background: var(--bg-elev); }

@media (max-width: 767.98px) {
    .sidebar-offcanvas {
        max-width: 70vw;
    }
}

.sidebar-header {
   
    background: var(--bg-elev);
}
.sidebar-search {
    padding-left: 36px; /* space for icon */
    height: 38px;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: var(--bg-elev); /* blend with sidebar surface */
    color: var(--text);
    box-shadow: none;
    transition:
      border-color 200ms ease,
      box-shadow 220ms ease,
      background-color 220ms ease;
}
.sidebar-search:hover {
    border-color: rgba(122,162,255,0.25); /* softer hover */
}
.sidebar-search:focus {
    outline: none;
    border-color: transparent; /* gradient ring drawn via background */
    background:
      linear-gradient(var(--bg-elev), var(--bg-elev)) padding-box,
      linear-gradient(135deg, #38bdf8 0%, #3b82f6 30%, #2563eb 55%, #1d4ed8 75%, #60a5fa 100%) border-box;
    background-origin: padding-box, border-box;
    background-clip: padding-box, border-box;
    box-shadow: 0 0 0 2px rgba(122,162,255,0.22); /* subtle focus ring */
}
.sidebar-search::placeholder {
    color: var(--muted);
    opacity: 1;
}

.sidebar-search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--muted);
    font-size: 0.95rem;
    pointer-events: none;
}

/* Dark theme: same blended surface, consistent ring */
[data-theme="dark"] .sidebar-search {
    background: var(--bg-elev) !important;
    color: var(--text) !important;
}
[data-theme="dark"] .sidebar-search::placeholder {
    color: var(--muted) !important;
}
[data-theme="dark"] .sidebar-search:focus {
    background:
      linear-gradient(var(--bg-elev), var(--bg-elev)) padding-box,
      linear-gradient(135deg, #38bdf8 0%, #3b82f6 30%, #2563eb 55%, #1d4ed8 75%, #60a5fa 100%) border-box;
    background-origin: padding-box, border-box;
    background-clip: padding-box, border-box;
}
/* New Chat button — Blue Aurora */
.btn-new-chat {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 8px 12px;
    border: 0;
    border-radius: 12px;
    color: #ffffff;
    font-weight: 700;
    letter-spacing: 0.2px;
    text-align: center;
    cursor: pointer;
    overflow: hidden;

    /* Animated gradient core (all blues) */
    background: linear-gradient(135deg, #0ea5e9 0%, #3b82f6 30%, #2563eb 55%, #1d4ed8 75%, #38bdf8 100%);
    background-size: 220% 220%;
    background-position: 0% 50%;
    animation: btnAuroraGradient 7s ease-in-out infinite;

    /* Subtle inner edge and glow */
    box-shadow:
      0 10px 30px -12px rgba(59, 130, 246, 0.55),
      0 8px 22px -12px rgba(14, 165, 233, 0.50),
      inset 0 0 0 1px rgba(255, 255, 255, 0.12);

    transition:
      transform 160ms ease,
      box-shadow 220ms ease,
      filter 220ms ease,
      opacity 160ms ease;
}

.btn-new-chat::before {
    /* Soft outer aura (blues only) */
    content: "";
    position: absolute;
    inset: -20%;
    background: radial-gradient(60% 60% at 10% 0%,
      rgba(56,189,248,0.35) 0%,
      rgba(59,130,246,0.35) 25%,
      rgba(14,165,233,0.25) 45%,
      rgba(56,189,248,0.0) 70%);
    filter: blur(18px) saturate(120%);
    z-index: 0;
    pointer-events: none;
    opacity: 0.85;
    transition: opacity 220ms ease, filter 220ms ease;
}

.btn-new-chat::after {
    /* Moving sheen on hover */
    content: "";
    position: absolute;
    top: -40%;
    left: -120%;
    height: 180%;
    width: 60%;
    background: linear-gradient(120deg,
      rgba(255,255,255,0) 0%,
      rgba(255,255,255,0.24) 20%,
      rgba(255,255,255,0.08) 32%,
      rgba(255,255,255,0) 60%);
    transform: skewX(-20deg);
    z-index: 1;
    pointer-events: none;
    opacity: 0;
}

.btn-new-chat > * {
    position: relative;
    z-index: 2; /* Keep icon/text above glow layers */
}

.btn-new-chat:hover {
    box-shadow:
      0 18px 45px -15px rgba(59, 130, 246, 0.75),
      0 12px 28px -12px rgba(14, 165, 233, 0.65),
      inset 0 0 0 1px rgba(255, 255, 255, 0.16);
}

.btn-new-chat:hover::after {
    opacity: 1;
    animation: btnAuroraSheen 900ms ease forwards;
}

.btn-new-chat:active {
    transform: translateY(0) scale(0.99);
    filter: saturate(1.05);
    box-shadow:
      0 12px 28px -14px rgba(59, 130, 246, 0.60),
      0 10px 22px -14px rgba(14, 165, 233, 0.55),
      inset 0 0 0 1px rgba(255, 255, 255, 0.18);
}

.btn-new-chat:focus-visible {
    outline: none;
    box-shadow:
      0 0 0 3px rgba(59,130,246,0.35),
      0 18px 45px -15px rgba(59, 130, 246, 0.70),
      0 12px 28px -12px rgba(14, 165, 233, 0.60),
      inset 0 0 0 1px rgba(255, 255, 255, 0.18);
}

.btn-new-chat:disabled {
    opacity: 0.7;
    filter: grayscale(10%);
    cursor: not-allowed;
}

.btn-new-chat i {
    font-size: 1rem;
    filter: drop-shadow(0 1px 2px rgba(0,0,0,0.25));
}

/* Compact variant for mobile offcanvas icon-only button (same vibe, tighter padding) */
.btn-new-chat-mobile {
    padding: 6px 12px;
    border-radius: 10px;
}

/* Animations */
@keyframes btnAuroraGradient {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

@keyframes btnAuroraSheen {
    0%   { left: -120%; opacity: 0; }
    10%  { opacity: 1; }
    60%  { opacity: 1; }
    100% { left: 140%; opacity: 0; }
}

/* Respect reduced motion preferences */
@media (prefers-reduced-motion: reduce) {
    .btn-new-chat {
        animation: none;
        transition: transform 160ms ease, box-shadow 220ms ease, opacity 160ms ease;
    }
    .btn-new-chat:hover::after {
        animation: none;
        opacity: 0.5;
        left: -20%;
    }
}

body > div.container-fluid.app-shell > div > aside > div.sidebar-footer.small.text-muted.p-3 > a:hover{
    color: white;
}

/* Chats list */
.chat-item {
    position: relative;
    border: none;
    border-radius: 12px;
    margin: 4px 8px;
    padding: 10px 12px;
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    box-shadow: none;
}
.chat-item:hover {
    background: var(--item-hover-bg); /* light blue hover */
    box-shadow: none;
}
.chat-item.active {
    background: var(--item-active-bg); /* light blue active */
    box-shadow: none;
}
/* Left accent bar removed */
/* Borderless list-group resets for chat lists */
#chat-list .list-group-item,
#chat-list-mobile .list-group-item {
    border: 0 !important;
    border-radius: 12px;
    padding-left: 4px;
    padding-right: 12px;
}

.chat-item-main-link {
    flex-grow: 1;
    min-width: 0;
    text-align: left;
    display: grid;
    row-gap: 2px;
}
.chat-item .title {
    font-weight: 600;
    font-size: 0.90rem;
    white-space: nowrap;
    text-overflow: ellipsis;
    overflow: hidden;
    padding-left: 10px;
}

/* Chat list icon and metadata */
.chat-item-icon {
    display: none !important;
}
.chat-item .meta { display: none !important; }

.chat-item-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    opacity: 0;
    transition: opacity 0.2s ease;
   
}
/*.chat-item:hover .chat-item-actions, .chat-item-actions {
    opacity: 1;
}*/
.chat-item-actions .btn {
    padding: 0.1rem 0.4rem;
    font-size: 0.8rem;
    background: transparent;
    border: 1px solid var(--border);
    color: inherit;
    border-radius: 8px;
}
.chat-item-actions .btn:hover {
    background: rgba(125,125,200,0.15);
}

/* Sidebar footer */
.sidebar-footer {
    border-top: 1px solid var(--border);
    background: var(--bg-elev);
}

/* Scroll areas */
.chats-scroll { flex: 1 1 auto; min-height: 0; overflow-y: auto; overflow-x: hidden; }

/* Hide chat list scrollbar visuals but keep scrolling */
#chat-list::-webkit-scrollbar, #chat-list-mobile::-webkit-scrollbar { width: 0; height: 0; }
#chat-list, #chat-list-mobile { -ms-overflow-style: none; scrollbar-width: none; }

/* Main pane */
.main-pane {
    position: relative; /* For mobile toggle positioning */
    overflow: hidden;
    background: var(--bg);
    height: 100%;
    min-width: 0;
}
.mobile-sidebar-toggle {
    position: absolute;
    top: 12px;
    left: 12px;
    z-index: 50;
}
.desktop-sidebar-toggle {
    position: fixed;
    top: 12px;
    left: 12px;
    z-index: 1050; /* stay above sidebar/header surfaces */
}

.theme-toggle-main {
    position: fixed;
    top: 12px;
    right: 12px;
    z-index: 1050;
}
.min-w-0 { min-width: 0; }

/* Messages */
.messages-scroll {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;   /* Only scroll area */
    overflow-x: hidden; /* No horizontal scroll */
    background: transparent;
    position: relative;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
}

/* Only style the visible scrollbar in messages pane */
.messages-scroll::-webkit-scrollbar { width: 10px; }
.messages-scroll::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.15); border-radius: 8px; }
[data-theme="dark"] .messages-scroll::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.12); }

.chat-thread {
    max-width: 820px;
    margin: 0 auto;
    padding: 24px 16px 80px 16px; /* bottom padding for composer space on small screens */
}

.message-row {
    display: flex;
    gap: 12px;
    margin: 0 auto 12px auto;
    width: 100%;
}
.message-row.role-assistant { align-items: flex-start; }
.message-row.role-user { align-items: flex-start; }

.avatar {
    flex: 0 0 auto;
    width: 34px; height: 34px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center; justify-content: center;
    background: rgba(122,162,255,0.20);
    border: 1px solid var(--border);
    color: var(--text);
    font-size: 18px;
    margin-top: 2px;
}
.avatar.user {
    background: rgba(35, 98, 255, 0.15);
}

.bubble {
    padding: 12px 16px;
    border-radius: 14px;
    max-width: 100%;
    line-height: 1.6;
    box-shadow: var(--shadow);
    border: 1px solid transparent;
    font-size: 0.98rem;
    position: relative;
}
.bubble-content-area {
    word-break: break-word;
    overflow-wrap: anywhere;
}
.bubble-user {
    margin-left: auto;
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    padding: 0 !important;
    display: flex;
    flex-direction: column;
    align-items: flex-end; /* Align items to the right */
}

.bubble-user .bubble-content-area {
    /* These styles make the content area look like the bubble */
    padding: 12px 16px;
    border-radius: 14px;
    background: var(--bubble-user-bg);
    box-shadow: var(--shadow);
    border: 1px solid var(--bubble-user-border);
    max-width: 100%;
}
.bubble-assistant {
    margin-right: auto;
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    padding: 0 !important;
    border-radius: 0 !important;
}

/* Markdown and code */
.bubble pre, .bubble code {
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
}
.bubble pre {
    background: var(--code-bg) !important;
    color: var(--code-text) !important;
    border-radius: 10px;
    padding: 12px 12px 28px 12px;
    overflow: auto;
    border: 1px solid rgba(255,255,255,0.08);
    position: relative;
}
.bubble code:not(pre code) {
    background: rgba(127, 127, 180, 0.2);
    color: inherit;
    padding: 2px 6px;
    border-radius: 6px;
}

.code-block { position: relative; }
.copy-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    border: 1px solid var(--border);
    background: rgba(127,127,127,0.15);
    color: var(--text);
    font-size: 12px;
    padding: 4px 8px;
    border-radius: 8px;
    cursor: pointer;
    z-index: 2;
}
.copy-btn:hover { background: rgba(127,127,127,0.25); }

/* Empty state */
.empty-state {
    text-align: center;
    margin-top: 8vh;
    color: var(--text);
}
.empty-state .emoji { font-size: 2.2rem; margin-bottom: 10px; }
.empty-state .empty-hero {
    display: inline-block;
    padding: 24px 28px;
    border-radius: 16px;
    background: transparent; /* blend with background */
    border: none;
    box-shadow: none;
    max-width: 760px;
}
.suggestions-grid {
    margin-top: 8px;
    display: grid;
    grid-template-columns: repeat(2, minmax(220px, 1fr));
    gap: 8px;
}
@media (max-width: 576px) {
    .suggestions-grid { grid-template-columns: 1fr; }
}
.suggestion {
    border: 1px dashed var(--border);
    background: transparent;
    color: var(--text);
    padding: 10px 12px;
    border-radius: 10px;
    text-align: left;
}
.suggestion:hover { background: rgba(125,125,200,0.10); }

/* Composer */
.composer {
    background: var(--bg-elev); /* solid composer */
    border-top: 1px solid var(--border) !important;
    flex: 0 0 auto;
    padding: 8px 10px 0 10px;
}
.composer-inner {
    max-width: 860px;
    margin: 0 auto;
}
.composer-form { margin: 0; }
.input-wrap {
    position: relative;
    border: 1px solid var(--border);
    border-bottom: none; /* join with toolbar below */
    border-radius: 14px 14px 0 0;
    background: var(--bg);
}
.composer-textarea {
    resize: none;
    max-height: 240px;
    min-height: 42px;
    border: none !important;
    background: transparent !important;
    color: var(--text);
    padding: 12px 14px; /* no overlaid actions, reclaim space */
    box-shadow: none !important;
}
.composer-textarea:focus { outline: none; box-shadow: none; }
.composer-actions {
    position: static;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}
.btn-send {
    border-radius: 12px;
    padding: 8px 12px;
}
.btn-send .bi { transform: translateY(1px); }

.composer-actions .btn-stop {
    width: 38px;
    height: 38px;
    padding: 6px;
    border-radius: 10px;
}

.composer-actions #btn-attach,
.composer-actions .web-search-toggle-btn {
    height: 38px;
    padding: 6px 12px;
    border-radius: 10px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.8rem;
}

.composer-actions #btn-attach {
    background: var(--bg);
    color: var(--muted);
    border: 1px solid var(--border);
}

.composer-actions #btn-attach:hover {
    background: var(--text);
    color: var(--bg);
}

/* Scroll to bottom */
.scroll-bottom {
    position: sticky;
    bottom: 16px;
    left: calc(100% - 70px);
    border-radius: 999px;
    box-shadow: var(--shadow);
    z-index: 5;
}

/* Loader - dot pulse */
.thinking-indicator {
    padding: 8px 12px;
}
.thinking-header {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 10px;
    margin-bottom: 12px;
}
.thinking-model-name {
    font-weight: 600;
    color: var(--muted);
}
.dot-wave {
    display: flex;
    justify-content: flex-start;
    align-items: center;
    position: relative;
    width: 80px;
    height: 14px;
    margin: 0;
}
.dot-wave span {
    position: relative;
    width: 10px;
    height: 10px;
    background: var(--primary);
    border-radius: 50%;
    animation: dotPulse 1.4s infinite ease-in-out;
    animation-fill-mode: both;
    margin: 0 4px;
}
.dot-wave span:nth-child(1) { animation-delay: -0.32s; }
.dot-wave span:nth-child(2) { animation-delay: -0.16s; }
.dot-wave span:nth-child(3) { animation-delay: 0s; }

@keyframes dotPulse {
    0%, 80%, 100% {
        transform: scale(0.3);
        opacity: 0.5;
    }
    40% {
        transform: scale(1.0);
        opacity: 1;
    }
}

/* Links */
.bubble a { color: var(--link); text-decoration: underline; }

/* Utility */
.text-muted { color: var(--muted) !important; }

/* Prevent long tokens/URLs from causing overflow */
.bubble * { word-break: break-word; overflow-wrap: anywhere; }

/* Chat list redesign */
.chat-item {
    position: relative;
    background: var(--bg-elev); /* solid item background */
    border: none;
    border-radius: 12px;
    margin: 6px 8px;
    padding: 5px 12px;
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    transition: background 0.2s ease, box-shadow 0.2s ease;
    box-shadow: none;
}
.chat-item:hover,
.chat-item:focus-visible,
.chat-item:active,
.chat-item.active {
    /* Animated darker blue gradient (less light blue than button) */
    background: linear-gradient(135deg,
      #3b82f6 0%,
      #2563eb 35%,
      #1d4ed8 65%,
      #1e40af 100%
    );
    background-size: 220% 220%;
    background-position: 0% 50%;
    animation: btnAuroraGradient 7s ease-in-out infinite;
    box-shadow: none;
    transform: none;
}
/* Left accent bar removed */
.chat-item::before { content: none !important; display: none !important; }

.chat-item-main-link {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    flex-direction: row;
    align-items: center;
}
.chat-item .title {
    font-weight: 600;
    font-size: 0.90rem;
    white-space: nowrap;
    text-overflow: ellipsis;
    overflow: hidden;
    padding-left: 0; /* Align with icon */
}

.chat-pin-icon {
    /* No width, so no reserved space. Icon appears and pushes title. */
    text-align: center;
    color: var(--muted);
    font-size: 0.85rem;
    flex-shrink: 0;
}

.chat-pin-icon:not(:empty) {
    padding-right: 8px; /* Add space between icon and title */
}

.chat-item-actions {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    opacity: 0;
    transition: opacity 0.2s ease, max-width 0.3s ease;
    margin-left: auto;
    max-width: 0;
    white-space: nowrap;
}
.chat-item:hover .chat-item-actions {
    opacity: 1;
    max-width: 150px;
}
.chat-item.editing .chat-item-actions {
    opacity: 1;
}

.chat-item-actions .btn {
    font-size: 0.8rem;
    background: transparent;
    color: inherit;
    border-radius: 8px;
}
.chat-item-actions .btn:hover { background: rgba(125,125,200,0.15); }

/* Inline rename input */
.chat-rename-input {
    border-radius: 8px !important;
    border: 1px dashed var(--border) !important;
    background: transparent !important;
    color: var(--text) !important;
    padding: 6px 8px !important;
    height: 32px;
}

/* Hide old icon and meta lines thoroughly */
.chat-item-icon { display: none !important; }
.chat-item .meta { display: none !important; }

/* Search highlighting */
mark.search-hit {
    background: rgba(122,162,255,0.25);
    color: inherit;
    padding: 0 2px;
    border-radius: 4px;
}

/* Chat list color contrast overrides */
.list-group-item-action.chat-item,
.list-group-item-action.chat-item:hover,
.list-group-item-action.chat-item:focus,
.list-group-item-action.chat-item.active {
    color: var(--text) !important; /* Force readable text in both themes */
}
.chat-item .title {
    color: var(--text); /* Title follows theme foreground */
}

/* Dark mode: make the chat input background white for strong contrast */
[data-theme="dark"] .input-wrap {
    background: #ffffff !important;
    border-color: var(--border);
}
[data-theme="dark"] .composer-textarea {
    color: #0f1115 !important; /* dark text on white */
}
[data-theme="dark"] .composer-textarea::placeholder {
    color: #6b7280 !important; /* neutral placeholder */
    opacity: 1;
}
[data-theme="dark"] .composer-meta {
    background: #ffffff !important; /* match input for single-component look */
    border-color: var(--border);
    color: #0f1115;
}

/* Composer UX upgrades */
.input-wrap:focus-within {
    border-color: var(--border);
    box-shadow: none;
}
.input-wrap.sending {
    opacity: 0.95;
}
.composer-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    color: var(--muted);
    gap: 8px;
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-top: none; /* connect to input-wrap */
    border-radius: 0; /* flat bottom edge */
    background: var(--bg);
}
.btn-stop {
    border-radius: 12px;
    padding: 8px 10px;
}

.web-search-toggle-btn {
    background: var(--bg);
    color: var(--muted);
    border: 1px solid var(--border);
    transition: all 0.2s ease;
}
.web-search-toggle-btn:hover {
    background: var(--text);
    color: var(--bg);
}
.web-search-toggle-btn.active {
    background: var(--chip-bg);
    color: var(--primary);
    border-color: var(--primary);
}

#composer-previews {
    flex-wrap: wrap;
}
.img-preview {
    position: relative;
    width: 72px;
    height: 72px;
}
.img-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 8px;
    border: 1px solid var(--border);
}
.img-preview .btn-remove-img {
    position: absolute;
    top: -6px;
    right: -6px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background-color: var(--bg);
    color: var(--text);
    border: 1px solid var(--border);
    font-size: 14px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    cursor: pointer;
}
.img-preview .upload-progress {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: rgba(122,162,255,0.4);
    border-radius: 0 0 8px 8px;
    overflow: hidden;
}
.img-preview .upload-progress-bar {
    width: 0;
    height: 100%;
    background: var(--primary);
    transition: width 0.2s ease;
}
.bubble-images {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 8px;
}
.bubble-images img {
    max-width: 200px;
    max-height: 200px;
    border-radius: 8px;
    object-fit: cover;
    border: 1px solid var(--border);
}
.img-preview.upload-error img {
    border-color: #dc3545; /* Bootstrap danger color */
    opacity: 0.6;
}
.img-preview.upload-error::after {
    content: "!";
    font-family: sans-serif;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: white;
    background: #dc3545;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    text-align: center;
    font-weight: bold;
    line-height: 18px;
    font-size: 14px;
    border: 1px solid white;
}
/* Send button — Blue Aurora (mirrors .btn-new-chat, all blues, slim) */
.btn-send {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 8px 12px; /* slim profile */
    border: 0;
    border-radius: 12px;
    color: #ffffff;
    font-weight: 700;
    letter-spacing: 0.2px;
    text-align: center;
    cursor: pointer;
    overflow: hidden;

    /* Animated gradient core (all blues) */
    background: linear-gradient(135deg, #0ea5e9 0%, #3b82f6 30%, #2563eb 55%, #1d4ed8 75%, #38bdf8 100%);
    background-size: 220% 220%;
    background-position: 0% 50%;
    animation: btnAuroraGradient 7s ease-in-out infinite;

    /* Subtle inner edge and glow */
    box-shadow:
      0 10px 30px -12px rgba(59, 130, 246, 0.55),
      0 8px 22px -12px rgba(14, 165, 233, 0.50),
      inset 0 0 0 1px rgba(255, 255, 255, 0.12);

    transition:
      transform 160ms ease,
      box-shadow 220ms ease,
      filter 220ms ease,
      opacity 160ms ease;
}
.btn-send::before {
    /* Soft outer aura (blues only) */
    content: "";
    position: absolute;
    inset: -20%;
    background: radial-gradient(60% 60% at 10% 0%,
      rgba(56,189,248,0.35) 0%,
      rgba(59,130,246,0.35) 25%,
      rgba(14,165,233,0.25) 45%,
      rgba(56,189,248,0.0) 70%);
    filter: blur(18px) saturate(120%);
    z-index: 0;
    pointer-events: none;
    opacity: 0.85;
    transition: opacity 220ms ease, filter 220ms ease;
}
.btn-send::after {
    /* Moving sheen on hover */
    content: "";
    position: absolute;
    top: -40%;
    left: -120%;
    height: 180%;
    width: 60%;
    background: linear-gradient(120deg,
      rgba(255,255,255,0) 0%,
      rgba(255,255,255,0.24) 20%,
      rgba(255,255,255,0.08) 32%,
      rgba(255,255,255,0) 60%);
    transform: skewX(-20deg);
    z-index: 1;
    pointer-events: none;
    opacity: 0;
}
.btn-send > * {
    position: relative;
    z-index: 2; /* Keep spinner/icon above glow layers */
}

/* Make the send arrow icon bolder and white */
.btn-send .send-label .bi {
    color: #ffffff !important;
    font-weight: 900;
    font-size: 1.2rem;
    line-height: 1;
}
.btn-send:hover {
    box-shadow:
      0 18px 45px -15px rgba(59, 130, 246, 0.75),
      0 12px 28px -12px rgba(14, 165, 233, 0.65),
      inset 0 0 0 1px rgba(255, 255, 255, 0.16);
}
.btn-send:hover::after {
    opacity: 1;
    animation: btnAuroraSheen 900ms ease forwards;
}
.btn-send:active {
    transform: translateY(0) scale(0.99);
    filter: saturate(1.05);
    box-shadow:
      0 12px 28px -14px rgba(59, 130, 246, 0.60),
      0 10px 22px -14px rgba(14, 165, 233, 0.55),
      inset 0 0 0 1px rgba(255, 255, 255, 0.18);
}
.btn-send:focus-visible {
    outline: none;
    box-shadow:
      0 0 0 3px rgba(59,130,246,0.35),
      0 18px 45px -15px rgba(59, 130, 246, 0.70),
      0 12px 28px -12px rgba(14, 165, 233, 0.60),
      inset 0 0 0 1px rgba(255, 255, 255, 0.18);
}
.btn-send:disabled {
    opacity: 0.7;
    filter: grayscale(10%);
    cursor: not-allowed;
}

/* Message tools in bubbles */
.message-tools {
    position: static;
    display: flex;
    gap: 6px;
    opacity: 0; /* Hidden by default */
    margin-top: 10px;
    justify-content: flex-end;
    flex-wrap: wrap;
    transition: opacity 0.2s ease;
}
.message-row:hover .message-tools {
    opacity: 1;
}
/* Remove absolute offsets for both bubble sides */
.bubble-user .message-tools {
    margin-top: 6px; /* Spacing between bubble and tools */
}


.btn-tool {
    padding: 4px 6px;
    font-size: 12px;
    border: 1px solid var(--border);
    background: rgba(127,127,127,0.12);
    color: var(--text);
    border-radius: 8px;
}
.btn-tool:hover {
    background: rgba(127,127,127,0.2);
}

.bubble .edit-area {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.bubble .edit-area textarea {
    width: 100%;
    min-height: 80px;
    background: var(--bg);
    border: 1px solid var(--border);
    color: var(--text);
    border-radius: 8px;
    padding: 8px;
    resize: vertical;
}
.bubble .edit-area .edit-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

/* Messages pane shadows (top/bottom fades) */
#messages-container::before,
#messages-container::after {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    height: 28px;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s ease;
    z-index: 2;
}
#messages-container::before {
    top: 0;
    background: linear-gradient(to bottom, var(--bg) 0%, rgba(0,0,0,0) 100%);
}
#messages-container::after {
    bottom: 0;
    background: linear-gradient(to top, var(--bg) 0%, rgba(0,0,0,0) 100%);
}
#messages-container.has-top-shadow::before { opacity: 1; }
#messages-container.has-bottom-shadow::after { opacity: 1; }

/* Model Selector Grid Dropdown */
.model-grid-dropdown {
    min-width: 460px;
    padding: 12px !important;
}
.model-selector-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
}
.model-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px;
    border-radius: 10px;
    border: 1px solid transparent;
    background: transparent;
    cursor: pointer;
    text-align: left;
    transition: background-color 0.2s ease, border-color 0.2s ease;
}
.model-card:hover {
    background-color: var(--item-hover-bg);
}
.model-card.active {
    border-color: var(--primary);
    background-color: var(--chip-bg);
}
.model-card-icon {
    flex-shrink: 0;
    height: 32px;
    width: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.model-card-icon img,
.model-card-icon svg {
    max-height: 100%;
    max-width: 100%;
    color: var(--primary);
}
.model-card-icon .bi {
    font-size: 28px;
    color: var(--primary);
}
.model-card-details {
    display: flex;
    flex-direction: column;
}
.model-card-name {
    font-weight: 600;
    font-size: 0.9rem;
    line-height: 1.3;
    color: var(--text);
}
.model-card-provider {
    font-size: 0.75rem;
    color: var(--muted);
}
.model-card.active .model-card-name {
    color: var(--primary);
}
.model-card.active .model-card-provider {
    color: var(--primary);
}


/* Model Selector Dropdown */
.model-selector-btn {
    border-radius: 10px;
    border: 1px solid transparent; /* No border by default */
    background: var(--bg);
    color: var(--text);
    text-align: left;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 12px;
    font-weight: 600;
    transition:
      background-color 0.2s ease,
      border-color 0.2s ease,
      color 0.2s ease;
}

/* Show border only on hover/focus/active or when dropdown is open */
.model-selector-btn:hover,
.model-selector-btn:focus,
.model-selector-btn:active,
.model-selector-btn[aria-expanded="true"] {
    background: rgba(15,17,21,0.06);
    border-color: var(--primary);
    color: var(--text);
}

.model-selector-btn::after {
   display: none;
}

/* On dark theme, the composer toolbar becomes white; force darker text and border only on interaction */
[data-theme="dark"] .composer-meta .model-selector-btn {
    background: #ffffff;
    color: #0f1115;
    border-color: transparent; /* No border by default on white toolbar */
}
[data-theme="dark"] .composer-meta .model-selector-btn:hover,
[data-theme="dark"] .composer-meta .model-selector-btn:focus,
[data-theme="dark"] .composer-meta .model-selector-btn:active,
[data-theme="dark"] .composer-meta .model-selector-btn[aria-expanded="true"] {
    background: rgba(15,17,21,0.06);
    border-color: rgba(15,17,21,0.38);
    color: #0f1115;
}

.dropdown-menu {
    background: var(--bg-elev);
    border: 1px solid var(--border);
    border-radius: 10px;
    box-shadow: var(--shadow);
    padding: 6px;
    max-height: 400px;
    overflow-y: auto;
}
.dropdown-item {
    color: var(--text);
    font-size: 0.9rem;
    padding: 8px 12px;
    border-radius: 8px;
    font-weight: 500;
}
.dropdown-item:hover, .dropdown-item:focus {
    background: rgba(125,125,200,0.15);
    color: var(--text);
}
.dropdown-item.active, .dropdown-item:active {
    background: var(--primary);
    color: #fff;
}
[data-theme="dark"] .dropdown-item.active, [data-theme="dark"] .dropdown-item:active {
    color: var(--bg);
}

/* Collapse behavior for desktop sidebar */
@media (min-width: 768px) {
    body.sidebar-collapsed .sidebar {
        display: none !important;
    }
}

.list-group-item, .list-group-item.active {
    margin-top: 1px !important; /* remove top border on active item */
}

@media (max-width: 767.98px) {
    /* Hide chat row action buttons on mobile for a cleaner UI */
    .chat-item-actions { display: none !important; }

    /* Hide textual labels in composer action buttons on mobile */
    .composer-actions #web-search-toggle span,
    .composer-actions #btn-attach span,
    .composer-actions #btn-reasoning span:not(.reasoning-icon) {
        display: none !important;
    }

    /* Disable text selection on chat list to allow proper long-press */
    #chat-list, #chat-list-mobile,
    #chat-list *, #chat-list-mobile * {
        -webkit-user-select: none;
        -webkit-touch-callout: none;
        user-select: none;
    }

    /* Add top padding to messages container on mobile */
    #messages-container { padding-top: 35px; }

    /* Mobile long-press context menu for chat items */
    .chat-context-menu {
        position: absolute;
        min-width: 190px;
        max-width: 80vw;
        background: var(--bg-elev);
        color: var(--text);
        border: 1px solid var(--border);
        border-radius: 10px;
        box-shadow: var(--shadow);
        padding: 6px;
        z-index: 1060;
        display: none;
    }
    .chat-context-menu .ctx-btn {
        display: flex;
        align-items: center;
        gap: 8px;
        width: 100%;
        background: transparent;
        border: 0;
        color: inherit;
        text-align: left;
        padding: 8px 10px;
        border-radius: 8px;
        font-size: 0.95rem;
    }
    .chat-context-menu .ctx-btn:hover,
    .chat-context-menu .ctx-btn:active {
        background: rgba(125,125,200,0.15);
    }
    .chat-context-menu .divider {
        height: 1px;
        margin: 4px 0;
        background: var(--border);
    }
}

.reasoning-toggle {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--muted);
    font-weight: 600;
    font-size: 0.8rem;
    padding: 4px 8px;
    border-radius: 8px;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}
.reasoning-toggle:hover {
    background: rgba(127,127,127,0.1);
}

/* Reasoning selection popover */
.reasoning-popover {
    position: absolute;
    min-width: 190px;
    max-width: 80vw;
    background: var(--bg-elev);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 10px;
    box-shadow: var(--shadow);
    padding: 6px;
    z-index: 1060;
    display: none;
}
.reasoning-popover .reasoning-option {
    display: block;
    width: 100%;
    background: transparent;
    border: 0;
    color: inherit;
    text-align: left;
    padding: 8px 10px;
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 600;
}
.reasoning-popover .reasoning-option:hover,
.reasoning-popover .reasoning-option:active {
    background: rgba(125,125,200,0.15);
}

/* Reasoning button icon uses SVG mask so it inherits currentColor like other icons */
#btn-reasoning .reasoning-icon {
    width: 1em;
    height: 1em;
    display: inline-block;
    vertical-align: -2px;
    background-color: currentColor;
    -webkit-mask-image: url('../../icons/brain.svg');
            mask-image: url('../../icons/brain.svg');
    -webkit-mask-repeat: no-repeat;
            mask-repeat: no-repeat;
    -webkit-mask-position: center;
            mask-position: center;
    -webkit-mask-size: contain;
            mask-size: contain;
    flex-shrink: 0;
}
