/*
 * Fluid Tech Dark Theme
 * Using high-specificity, direct selectors to override Chainlit's default styles.
 * Philosophy: Work WITH Chainlit's framework, not against it.
 */

/* ============================================================================
   CSS VARIABLES & BASE SETUP
   ============================================================================ */

body, #root {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Inter', 'SF Pro Display', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif !important;
    font-size: 15px !important;
    line-height: 1.6 !important;
    -webkit-font-smoothing: antialiased !important;
    -moz-osx-font-smoothing: grayscale !important;
}

/* Watermark removal */
.watermark {
    display: none !important;
}

/* ============================================================================
   CORE LAYOUT & STRUCTURE
   ============================================================================ */

/* Main chat area background */
#root main,
#root .input-box-container {
    background-color: #060815 !important;
    border-color: #2a2a50 !important;
}

/* Add padding to main content to compensate for fixed header */
main {
    padding-top: 64px !important;
}

/* Message container spacing */
#root .step {
    margin-bottom: 1.5rem !important;
}

/* Constrain parent containers to prevent page-wide horizontal scroll */
.step,
.step > .flex.flex-col,
.message-content,
.message-container {
    max-width: 100% !important;
}

/* Full-width layout - override Chainlit's centered containers */
.flex.flex-col.mx-auto,
.flex.flex-col.mx-auto.w-full {
    max-width: 100% !important;
    width: 100% !important;
}

/* Prevent horizontal scroll on page - only within tables */
main,
main > div,
.step,
.step > .flex.flex-col,
.step > div,
.ai-message {
    overflow-x: hidden !important;
    max-width: 100% !important;
}

/* Message content - scrollable container */
.message-content {
    overflow-x: auto !important;
    overflow-y: visible !important;
    width: 100% !important;
    max-width: 100% !important;
}

/* Tables - natural width, scroll within message-content only */
.message-content table {
    width: max-content !important;
    min-width: 100% !important;
    max-width: none !important;
}

/* Simplified scroll handling - just prevent horizontal page scroll */
main .relative.flex.flex-col.flex-grow.overflow-y-auto {
    overflow-x: hidden !important;
    max-width: 100% !important;
}

/* Welcome screen - base layout */
#welcome-screen,
.welcome-screen {
    display: flex !important;
    flex-direction: column !important;
    justify-content: center !important;
    align-items: center !important;
    min-height: calc(100vh - 64px);
    padding: 0 !important;
    padding-bottom: 10rem !important; /* Prevent content hiding under fixed composer */
    background: transparent !important;
}

/* ============================================================================
   SCROLLBAR CUSTOMIZATION - Always visible scrollbars
   ============================================================================ */

/* Force scrollbar to always show on table containers (horizontal) */
.relative.overflow-auto::-webkit-scrollbar {
    -webkit-appearance: none;
    height: 14px;
}

.relative.overflow-auto::-webkit-scrollbar-thumb {
    background-color: rgba(255, 255, 255, 0.3);
    border-radius: 8px;
    border: 2px solid transparent;
    background-clip: padding-box;
}

.relative.overflow-auto::-webkit-scrollbar-thumb:hover {
    background-color: rgba(255, 255, 255, 0.5);
}

.relative.overflow-auto::-webkit-scrollbar-track {
    background-color: rgba(0, 0, 0, 0.1);
    border-radius: 8px;
}

/* Force scrollbar to always show on main chat area (vertical) */
.overflow-y-auto::-webkit-scrollbar {
    -webkit-appearance: none;
    width: 14px;
}

.overflow-y-auto::-webkit-scrollbar-thumb {
    background-color: rgba(255, 255, 255, 0.3);
    border-radius: 8px;
    border: 2px solid transparent;
    background-clip: padding-box;
}

.overflow-y-auto::-webkit-scrollbar-thumb:hover {
    background-color: rgba(255, 255, 255, 0.5);
}

.overflow-y-auto::-webkit-scrollbar-track {
    background-color: rgba(0, 0, 0, 0.1);
    border-radius: 8px;
}

/* ============================================================================
   HEADER (Fixed Navigation Bar)
   ============================================================================ */

#header {
    background: linear-gradient(135deg, #2563eb 0%, #7c3aed 50%, #9333ea 100%);
    box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px -1px rgba(0, 0, 0, 0.1);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    min-height: 64px !important;
    height: 64px !important;
    padding: 0 1.5rem !important;
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    z-index: 100 !important;
}

/* Right side controls container */
#header .flex.items-center.gap-1 {
    gap: 0.5rem !important;
}

/* Native chat profiles button */
#chat-profiles,
#chat-profiles span {
    color: white !important;
}

#chat-profiles {
    background-color: transparent !important;
}

#chat-profiles:hover {
    background-color: rgba(255, 255, 255, 0.1) !important;
}

/* User avatar in header */
#user-nav-button {
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    border: none !important;
    border-radius: 50%;
    padding: 0 !important;
}

#user-nav-button:hover {
    transform: scale(1.05);
    box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.2);
}

#user-nav-button span span {
    background: linear-gradient(135deg, #2563eb 0%, #9333ea 100%);
    width: 2rem !important;
    height: 2rem !important;
}

#user-nav-button:active {
    transform: scale(0.96);
}

/* ============================================================================
   CUSTOM TOOLBAR (Fluid Tech Navigation)
   ============================================================================ */

.fluid-nav-group {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.fluid-logo {
    width: 32px;
    height: 32px;
    object-fit: contain;
    filter: invert(1) drop-shadow(0 1px 2px rgba(0, 0, 0, 0.2));
    margin-right: 0.5rem;
    transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
}

.fluid-logo:hover {
    transform: scale(1.05);
}

.fluid-logo:active {
    transform: scale(0.96);
}

.fluid-header-title {
    font-size: 1.125rem;
    font-weight: 600;
    color: white !important;
    letter-spacing: -0.025em;
    white-space: nowrap;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.fluid-agent-selector {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-left: 1.5rem;
    padding-left: 1.5rem;
    border-left: 1px solid rgba(255, 255, 255, 0.15);
}

.fluid-agent-label {
    font-size: 0.6875rem;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.6) !important;
    white-space: nowrap;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

#chat-profiles-fluid {
    background: transparent !important;
    border: 1px solid rgba(255, 255, 255, 0.15) !important;
    color: white !important;
    padding: 0.375rem 0.625rem !important;
    border-radius: 0.5rem;
    font-size: 0.8125rem !important;
    font-weight: 500 !important;
    height: auto !important;
    min-height: unset !important;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

#chat-profiles-fluid:hover {
    background: rgba(255, 255, 255, 0.08) !important;
    border-color: rgba(255, 255, 255, 0.25) !important;
}

#chat-profiles-fluid:active {
    transform: scale(0.98);
    background: rgba(255, 255, 255, 0.12) !important;
}

#chat-profiles-fluid span {
    color: rgba(255, 255, 255, 0.95) !important;
    font-size: 0.8125rem !important;
}

#chat-profiles-fluid img {
    width: 1.25rem !important;
    height: 1.25rem !important;
    border-radius: 0.25rem;
}

#chat-profiles-fluid svg {
    width: 0.875rem !important;
    height: 0.875rem !important;
    color: rgba(255, 255, 255, 0.7) !important;
}

/* Hamburger menu - hidden on desktop */
.fluid-hamburger {
    display: none;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 0.5rem;
    color: rgba(255, 255, 255, 0.9);
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.fluid-hamburger svg {
    width: 24px;
    height: 24px;
}

.fluid-hamburger:hover {
    background: rgba(124, 58, 237, 0.2);
    border-color: rgba(124, 58, 237, 0.4);
}

/* Divider in mobile menu */
.fluid-mobile-menu-divider {
    height: 1px;
    background: rgba(255, 255, 255, 0.1);
    margin: 0.5rem 0;
}

/* Hide agent container in mobile menu - keeping it simple */
#fluid-mobile-agent-container {
    display: none;
}

.fluid-mobile-menu {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(8px);
    z-index: 300;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.fluid-mobile-menu.active {
    opacity: 1;
    visibility: visible;
}

.fluid-mobile-menu-content {
    position: absolute;
    top: 0;
    left: 0;
    width: 80%;
    max-width: 400px;
    height: 100%;
    background: linear-gradient(135deg, #0a0f1e 0%, #1a1f2e 50%, #0d1420 100%);
    border-right: 1px solid rgba(124, 58, 237, 0.3);
    padding: 1.5rem;
    transform: translateX(-100%);
    transition: transform 0.3s ease;
}

.fluid-mobile-menu.active .fluid-mobile-menu-content {
    transform: translateX(0);
}

.fluid-mobile-menu-close {
    all: unset;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    margin-bottom: 2rem;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 0.5rem;
    color: rgba(255, 255, 255, 0.9);
    cursor: pointer;
    transition: all 0.2s ease;
}

.fluid-mobile-menu-close svg {
    width: 24px;
    height: 24px;
}

.fluid-mobile-menu-close:hover {
    background: rgba(124, 58, 237, 0.2);
    border-color: rgba(124, 58, 237, 0.4);
}

.fluid-mobile-menu-nav {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.fluid-mobile-menu-btn {
    all: unset;
    display: flex;
    align-items: center;
    width: 100%;
    padding: 1rem 1.25rem;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-weight: 500;
    font-size: 1rem;
    color: rgba(255, 255, 255, 0.9);
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 0.5rem;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: left;
    box-sizing: border-box;
}

.fluid-mobile-menu-btn:hover {
    background: rgba(124, 58, 237, 0.2);
    border-color: rgba(124, 58, 237, 0.4);
    color: white;
}

/* Agent selector dropdown */
[data-radix-popper-content-wrapper] {
    z-index: 200 !important;
    overflow: visible !important;
}

[role="listbox"] {
    background: rgba(15, 15, 30, 0.98) !important;
    border: 1px solid rgba(255, 255, 255, 0.1) !important;
    border-radius: 0.75rem;
    padding: 0.5rem !important;
    box-shadow: 0 20px 40px -10px rgba(0, 0, 0, 0.6);
    max-height: 400px !important;
    min-width: 220px !important;
    max-width: 300px !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    margin-top: 0.375rem !important;
    z-index: 200 !important;
    contain: layout style;
}

[role="option"] {
    padding: 0.5rem 0.75rem !important;
    margin: 0.125rem 0 !important;
    border-radius: 0.5rem;
    display: flex !important;
    align-items: center !important;
    gap: 0.75rem;
    color: rgba(255, 255, 255, 0.8) !important;
    font-size: 0.875rem !important;
    cursor: pointer;
}

[role="option"]:hover {
    background: rgba(255, 255, 255, 0.06) !important;
    color: white !important;
}

[role="option"][data-state="checked"],
[role="option"][aria-selected="true"] {
    background: rgba(124, 58, 237, 0.15) !important;
    border: 1px solid rgba(124, 58, 237, 0.3) !important;
    color: white !important;
    font-weight: 600 !important;
    padding-left: 1rem !important;
    position: relative !important;
}

[role="option"][data-state="checked"]::before,
[role="option"][aria-selected="true"]::before {
    content: '';
    position: absolute;
    left: 0.375rem;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 60%;
    background: #7c3aed;
    border-radius: 2px;
}

[role="option"] img {
    width: 1.75rem !important;
    height: 1.75rem !important;
    border-radius: 0.375rem;
    flex-shrink: 0 !important;
}

[role="option"] svg,
[role="tooltip"] {
    display: none !important;
}

[role="listbox"]::-webkit-scrollbar {
    width: 4px;
}

[role="listbox"]::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 2px;
}

/* New chat button */
.fluid-new-chat-btn {
    padding: 0.5rem 1rem;
    background: white !important;
    color: #2563eb !important;
    border: none;
    border-radius: 0.5rem;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    white-space: nowrap;
    box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.1);
    letter-spacing: -0.01em;
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    visibility: visible !important;
    opacity: 1 !important;
    pointer-events: auto !important;
}

.fluid-new-chat-btn:hover {
    background: rgba(255, 255, 255, 0.9) !important;
    box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.25), 0 4px 8px -2px rgba(0, 0, 0, 0.1);
    transform: translateY(-1px);
}

.fluid-new-chat-btn:active {
    transform: translateY(0) scale(0.98);
}

/* ============================================================================
   SIDEBAR EDGE TAB - Floating toggle with keyboard shortcut
   ============================================================================ */

/* Floating sidebar edge tab - subtle utility control */
.fluid-sidebar-edge-tab {
    position: fixed;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    z-index: 85;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 48px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-left: none;
    border-radius: 0 0.375rem 0.375rem 0;
    color: rgba(255, 255, 255, 0.3);
    cursor: pointer;
    transition: all 0.2s ease;
    opacity: 0.6;
}

.fluid-sidebar-edge-tab:hover {
    background: rgba(124, 58, 237, 0.15);
    border-color: rgba(124, 58, 237, 0.25);
    color: rgba(255, 255, 255, 0.7);
    opacity: 1;
}

/* When sidebar is open: shift tab right and flip icon to point left */
body:has([data-state="expanded"][data-side="left"]) .fluid-sidebar-edge-tab {
    left: 16rem;
}

body:has([data-state="expanded"][data-side="left"]) .fluid-sidebar-edge-tab svg {
    transform: scaleX(-1);
}

/* Arrow icon sizing */
.fluid-sidebar-edge-tab svg {
    width: 14px;
    height: 14px;
    flex-shrink: 0;
}

/* ============================================================================
   SIDEBAR (History Panel)
   ============================================================================ */

/* Sidebar z-index hierarchy - all sidebar elements below header but above content */
.group.peer[data-side="left"],
.group.peer[data-variant="sidebar"],
.group.peer[data-side="left"] > *,
.group.peer[data-side="left"] div,
div[data-sidebar],
button[data-sidebar],
[data-sidebar='header'] {
    z-index: 90 !important;
}

.group.peer[data-side="left"] > div.fixed,
div.fixed[data-sidebar='sidebar'] {
    z-index: 90 !important;
}

/* Sidebar container */
#root div[data-sidebar='sidebar'],
div[data-sidebar='sidebar'] {
    background-color: #0f0f1e !important;
    border-right: 1px solid rgba(255, 255, 255, 0.08) !important;
    z-index: 90 !important;
    padding-top: 64px !important;
}

/* Sidebar header - positioned below fixed header */
div[data-sidebar='header'] {
    position: sticky !important;
    top: 64px !important;
    z-index: 20 !important;
    background-color: #0f0f1e !important;
    padding: 0.75rem !important;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06) !important;
}

/* Keep sidebar header visible inside the sidebar */
div[data-sidebar='sidebar'] div[data-sidebar='header'] {
    display: flex !important;
}

/* Hide sidebar trigger buttons - we use edge tab instead */
div[data-sidebar='header'] button[data-sidebar='trigger'],
div[data-sidebar='header'] #sidebar-trigger-button,
#header button[data-sidebar='trigger'],
#header #sidebar-trigger-button {
    display: none !important;
}

/* Sidebar search button */
div[data-sidebar='sidebar'] #search-chats-button,
div[data-sidebar='header'] #search-chats-button,
div[data-sidebar='sidebar'] button[aria-label*="Search"] {
    display: flex !important;
    align-items: center;
    justify-content: center;
    width: 2rem !important;
    height: 2rem !important;
    padding: 0 !important;
    background: transparent !important;
    border: 1px solid rgba(255, 255, 255, 0.12) !important;
    border-radius: 0.5rem;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    color: rgba(255, 255, 255, 0.7) !important;
}

div[data-sidebar='sidebar'] #search-chats-button:hover,
div[data-sidebar='header'] #search-chats-button:hover,
div[data-sidebar='sidebar'] button[aria-label*="Search"]:hover {
    background: rgba(255, 255, 255, 0.08) !important;
    border-color: rgba(255, 255, 255, 0.2) !important;
    color: white !important;
}

div[data-sidebar='sidebar'] #search-chats-button svg,
div[data-sidebar='header'] #search-chats-button svg {
    width: 1rem !important;
    height: 1rem !important;
}

/* Sidebar section headers */
div[data-sidebar='sidebar'] h2,
div[data-sidebar='sidebar'] h3 {
    color: rgba(255, 255, 255, 0.4) !important;
    font-size: 0.6875rem !important;
    font-weight: 600 !important;
    text-transform: uppercase !important;
    letter-spacing: 0.05em;
    padding: 1rem 0.75rem 0.375rem !important;
    margin: 0 !important;
}

div[data-sidebar='sidebar'] h2::after,
div[data-sidebar='sidebar'] h3::after {
    content: '';
    display: block;
    margin-top: 0.375rem;
    height: 1px;
    background: rgba(255, 255, 255, 0.05);
}

/* Sidebar history items */
button[data-sidebar='menu-button'] {
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    border-radius: 0.5rem;
    margin: 0.125rem 0.5rem !important;
    padding: 0.5rem 0.75rem !important;
    color: rgba(255, 255, 255, 0.75) !important;
    font-size: 0.8125rem !important;
    line-height: 1.4 !important;
    border: 1px solid transparent !important;
    text-align: left !important;
    height: auto !important;
    min-height: 2.5rem !important;
}

button[data-sidebar='menu-button']:hover {
    background: rgba(255, 255, 255, 0.06) !important;
    color: rgba(255, 255, 255, 0.95) !important;
    border-color: rgba(255, 255, 255, 0.08) !important;
}

button[data-sidebar='menu-button'][data-active='true'],
button[data-sidebar='menu-button'][aria-current='page'] {
    background: rgba(124, 58, 237, 0.15) !important;
    border: 1px solid rgba(124, 58, 237, 0.25) !important;
    color: white !important;
    font-weight: 500;
    position: relative;
}

button[data-sidebar='menu-button'][data-active='true']::before,
button[data-sidebar='menu-button'][aria-current='page']::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 2px;
    height: 60%;
    background: #7c3aed;
    border-radius: 0 2px 2px 0;
}

/* History item text wrapping - 2 line clamp */
#root button[data-sidebar='menu-button'] > div {
    background: none !important;
    display: -webkit-box !important;
    -webkit-line-clamp: 2 !important;
    line-clamp: 2 !important;
    -webkit-box-orient: vertical !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    white-space: normal !important;
    word-break: break-word !important;
    line-height: 1.4 !important;
    font-size: 0.8125rem !important;
}

/* Sidebar scrollbar */
div[data-sidebar='sidebar'] {
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.15) transparent;
}

div[data-sidebar='sidebar']::-webkit-scrollbar {
    width: 6px;
}

div[data-sidebar='sidebar']::-webkit-scrollbar-track {
    background: transparent;
}

div[data-sidebar='sidebar']::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.12);
    border-radius: 3px;
}

div[data-sidebar='sidebar']::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* ============================================================================
   CHAT MESSAGES & CONTENT
   ============================================================================ */

/* User message bubble */
#root .step[data-author="user"] .step-content,
#root div[class*='bg-accent'] {
    background: linear-gradient(135deg, rgba(37, 99, 235, 0.15) 0%, rgba(124, 58, 237, 0.15) 100%) !important;
    border: 1px solid rgba(124, 58, 237, 0.25) !important;
    border-radius: 1rem;
    padding: 1rem 1.25rem !important;
    color: rgba(255, 255, 255, 0.95) !important;
    font-size: 15px !important;
    line-height: 1.6 !important;
    font-weight: 400 !important;
}

/* AI/Assistant message bubble */
#root .step[data-author="assistant"] .step-content,
#root .step:not([data-author="user"]) .step-content {
    background: rgba(255, 255, 255, 0.03) !important;
    border: 1px solid rgba(255, 255, 255, 0.08) !important;
    border-radius: 1rem;
    padding: 1.25rem !important;
    color: rgba(255, 255, 255, 0.9) !important;
    font-size: 15px !important;
    line-height: 1.6 !important;
    font-weight: 400 !important;
}

/* Paragraphs in messages */
#root .step-content p,
#root .message-content p {
    margin: 0.75rem 0 !important;
    font-size: 15px !important;
    line-height: 1.6 !important;
    color: rgba(255, 255, 255, 0.9) !important;
}

#root .step-content p:first-child,
#root .message-content p:first-child {
    margin-top: 0 !important;
}

#root .step-content p:last-child,
#root .message-content p:last-child {
    margin-bottom: 0 !important;
}

/* Message headings */
#root .step-content h1,
#root .message-content h1 {
    font-size: 1.5rem !important;
    font-weight: 700 !important;
    line-height: 1.3 !important;
    color: white !important;
    background: linear-gradient(135deg, #2563eb 0%, #7c3aed 100%) !important;
    padding: 0.75rem 1rem !important;
    margin: 1.5rem 0 1rem 0 !important;
    border-radius: 0.5rem;
    border: none !important;
    letter-spacing: -0.02em;
}

#root .step-content h2,
#root .message-content h2 {
    color: white !important;
    background: rgba(37, 99, 235, 0.9) !important;
    padding: 0.625rem 1rem !important;
    margin: 1.25rem 0 0.75rem 0 !important;
    border-radius: 0.5rem;
    font-size: 1.25rem !important;
    font-weight: 600 !important;
    letter-spacing: -0.01em;
    border: none !important;
}

#root .step-content h3,
#root .message-content h3 {
    color: rgba(255, 255, 255, 0.9) !important;
    background: rgba(124, 58, 237, 0.15) !important;
    border-left: 3px solid #7c3aed !important;
    padding: 0.5rem 0.875rem !important;
    margin: 1rem 0 0.625rem 0 !important;
    border-radius: 0.375rem;
    font-size: 1.0625rem !important;
    font-weight: 600 !important;
}

/* Code blocks */
#root .step-content pre,
#root .message-content pre {
    background: rgba(0, 0, 0, 0.3) !important;
    border: 1px solid rgba(255, 255, 255, 0.1) !important;
    border-radius: 0.5rem;
    padding: 1rem !important;
    margin: 1rem 0 !important;
    overflow-x: auto !important;
    font-size: 0.8125rem !important;
    line-height: 1.5 !important;
}

#root .step-content code,
#root .message-content code {
    background: rgba(0, 0, 0, 0.2) !important;
    border: 1px solid rgba(255, 255, 255, 0.1) !important;
    border-radius: 0.25rem;
    padding: 0.125rem 0.375rem !important;
    font-size: 0.875em !important;
    font-family: 'SF Mono', 'Monaco', 'Inconsolata', 'Fira Code', monospace !important;
}

#root .step-content pre code,
#root .message-content pre code {
    background: transparent !important;
    border: none !important;
    padding: 0 !important;
}

/* Lists */
#root .step-content ul,
#root .message-content ul {
    margin: 0.75rem 0 !important;
    padding-left: 1.5rem !important;
}

#root .step-content ol,
#root .message-content ol {
    margin: 0.75rem 0 !important;
    padding-left: 1.5rem !important;
}

#root .step-content li,
#root .message-content li {
    margin: 0.375rem 0 !important;
    color: rgba(255, 255, 255, 0.85) !important;
    line-height: 1.6 !important;
}

/* Links */
#root .step-content a,
#root .message-content a {
    color: #60a5fa !important;
    text-decoration: none;
    transition: color 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

#root .step-content a:hover,
#root .message-content a:hover {
    color: #93c5fd !important;
    text-decoration: underline;
}

/* ============================================================================
   CODE PREVIEW CARDS (Raw code blocks)
   ============================================================================ */

/* Card wrapper */
.rounded-lg.border.bg-card {
    background: rgba(0, 0, 0, 0.3) !important;
    border: 1px solid rgba(255, 255, 255, 0.1) !important;
    border-radius: 0.75rem !important;
    box-shadow: none !important;
}

/* Card header */
.rounded-lg.border.bg-card .space-y-1\.5.p-6 {
    background: rgba(0, 0, 0, 0.2) !important;
    padding: 0.625rem 1rem !important;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08) !important;
    border-radius: 0.75rem 0.75rem 0 0 !important;
}

/* "Raw code" label */
.rounded-lg.border.bg-card .text-muted-foreground {
    color: rgba(255, 255, 255, 0.5) !important;
    font-size: 0.75rem !important;
    font-weight: 600 !important;
    text-transform: uppercase !important;
    letter-spacing: 0.05em !important;
}

/* Copy button */
.rounded-lg.border.bg-card button {
    color: rgba(255, 255, 255, 0.5) !important;
    transition: all 0.2s ease !important;
}

.rounded-lg.border.bg-card button:hover {
    background: rgba(255, 255, 255, 0.08) !important;
    color: rgba(255, 255, 255, 0.9) !important;
}

/* Code container */
.rounded-lg.border.bg-card .bg-accent {
    background: rgba(0, 0, 0, 0.4) !important;
    padding: 1.25rem !important;
    border-radius: 0 0 0.75rem 0.75rem !important;
}

/* Code text */
.rounded-lg.border.bg-card code.whitespace-pre-wrap {
    color: rgba(255, 255, 255, 0.9) !important;
    font-size: 0.875rem !important;
    line-height: 1.6 !important;
    font-family: 'SF Mono', 'Monaco', 'Inconsolata', 'Fira Code', monospace !important;
}

/* ============================================================================
   TABLES
   ============================================================================ */

#root .step-content table,
#root .message-content table {
    border-collapse: separate !important;
    border-spacing: 0 !important;
    width: max-content !important;
    min-width: 100% !important;
    border: 1px solid rgba(255, 255, 255, 0.1) !important;
    border-radius: 6px !important;
    overflow: hidden !important;
    margin: 1rem 0 !important;
    font-variant-numeric: tabular-nums !important;
}

#root .step-content th,
#root .message-content th {
    background: #2563eb !important;
    color: white !important;
    padding: 0.75rem !important;
    text-align: left !important;
    font-size: 0.8125rem !important;
    font-weight: 600 !important;
    border-bottom: 1px solid rgba(255, 255, 255, 0.2) !important;
}

#root .step-content td,
#root .message-content td {
    padding: 0.625rem 0.75rem !important;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08) !important;
    color: rgba(255, 255, 255, 0.85) !important;
}

#root .step-content tbody tr:last-child td,
#root .message-content tbody tr:last-child td {
    border-bottom: none !important;
}

#root .step-content tbody tr:hover td,
#root .message-content tbody tr:hover td {
    background: rgba(124, 58, 237, 0.08) !important;
}

/* ============================================================================
   MESSAGE INPUT & COMPOSER
   ============================================================================ */

/* ============================================================================
   LESSON LEARNED: Don't fight the framework
   After trying position:fixed with manual sidebar calculations, the solution
   was simple: let Chainlit handle layout, just remove the obstacles.
   1. margin-top: auto - flexbox pushes to bottom, stays in document flow
   2. Kill Chainlit's spacer div - it creates artificial gap
   3. Remove parent padding - flush to bottom edge
   Result: Works with sidebar, mobile, resizing - no positioning hacks needed.
   ============================================================================ */

/* Kill Chainlit's spacer that creates gap above/below input */
.flex-shrink-0[style*="height"],
#welcome-screen + .flex-shrink-0,
.flex-shrink-0:has(+ #welcome-screen),
div[style*="height"]:empty {
    height: 0 !important;
    min-height: 0 !important;
    display: none !important;
}

/* Remove bottom padding/margin from parent containers, keep horizontal */
.flex.flex-col.mx-auto.w-full:has(#welcome-screen),
.flex.flex-col.mx-auto.w-full.p-4:has(#welcome-screen),
.flex.flex-col.mx-auto.w-full.flex-grow:has(#welcome-screen),
.flex.flex-col.mx-auto.w-full:has(#message-composer),
.flex.flex-col.mx-auto.w-full.p-4:has(#message-composer),
.flex.flex-col.mx-auto.w-full.flex-grow:has(#message-composer) {
    padding-left: 1rem !important;
    padding-right: 1rem !important;
    padding-top: 1rem !important;
    padding-bottom: 0 !important;
    margin-bottom: 0 !important;
}

/* Welcome screen: position:fixed for composer, account for sidebar */
#welcome-screen > #message-composer {
    position: fixed !important;
    bottom: 0 !important;
    left: 50% !important;
    transform: translateX(-50%) !important;
    max-width: 60rem !important;
    width: calc(100vw - 2rem) !important;
    margin: 0 !important;
    z-index: 50 !important;
}

/* Sidebar open: shift composer to account for 16rem sidebar width */
@media (min-width: 768px) {
    body:has([data-state="expanded"][data-side="left"]) #welcome-screen > #message-composer {
        left: calc(50% + 8rem) !important; /* Shift right by half sidebar */
        width: calc(100vw - 16rem - 2rem) !important; /* Narrow by sidebar width */
    }
}

/* Chat mode: push composer to bottom with margin-top */
.flex.flex-col:not(#welcome-screen) #message-composer {
    margin-top: auto !important;
}

/* Input composer container */
#message-composer,
#message-composer.bg-accent,
#message-composer.dark\:bg-card,
#message-composer.p-3,
#message-composer.px-4,
#message-composer.rounded-3xl {
    margin-bottom: 0 !important;
    background: rgba(255, 255, 255, 0.05) !important;
    border: 1px solid rgba(255, 255, 255, 0.12) !important;
    border-bottom: none !important;
    border-radius: 1rem 1rem 0 0 !important;
    padding: 1rem 1.5rem !important;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    backdrop-filter: blur(12px) !important;
}

#message-composer:focus-within {
    background: rgba(255, 255, 255, 0.08) !important;
    border-color: rgba(124, 58, 237, 0.4) !important;
    box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.1);
}

/* Textarea itself - clean and minimal */
#chat-input,
#chat-input.bg-transparent,
#root textarea[placeholder*="message"],
#root textarea[placeholder*="Type"],
#root input[type="text"][class*="input"] {
    background: transparent !important;
    border: none !important;
    color: rgba(255, 255, 255, 0.95) !important;
    padding: 0.5rem !important;
    font-size: 0.9375rem !important;
    line-height: 1.5 !important;
    resize: none !important;
}

#chat-input:focus,
#root textarea[placeholder*="message"]:focus,
#root textarea[placeholder*="Type"]:focus {
    outline: none !important;
    box-shadow: none !important;
    border: none !important;
}

#chat-input::placeholder,
#root textarea[placeholder*="message"]::placeholder,
#root textarea[placeholder*="Type"]::placeholder {
    color: rgba(255, 255, 255, 0.4) !important;
}

/* Send button */
#chat-submit,
#root button[type="submit"],
#root button[aria-label*="Send"] {
    background: linear-gradient(135deg, #2563eb 0%, #7c3aed 100%) !important;
    border: none !important;
    border-radius: 0.5rem;
    width: 2rem !important;
    height: 2rem !important;
    padding: 0 !important;
    color: white !important;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
}

#chat-submit:hover:not(:disabled),
#root button[type="submit"]:hover:not(:disabled),
#root button[aria-label*="Send"]:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 8px 16px -4px rgba(124, 58, 237, 0.4);
}

#chat-submit:active,
#root button[type="submit"]:active,
#root button[aria-label*="Send"]:active {
    transform: translateY(0);
}

#chat-submit:disabled,
#root button[type="submit"]:disabled {
    opacity: 0.5 !important;
    cursor: not-allowed;
}

/* ============================================================================
   WELCOME SCREEN & STARTERS
   ============================================================================ */

/* Welcome message - force to top with negative order */
#fluid-welcome-message {
    text-align: center;
    margin-bottom: 3rem;
    order: -100 !important;
}

.fluid-welcome-title {
    font-size: 3rem;
    font-weight: 700;
    letter-spacing: -0.03em;
    margin: 0 0 0.75rem 0;
    color: #ffffff;
}

.fluid-welcome-subtitle {
    color: rgba(255, 255, 255, 0.6);
    margin: 0;
}

/* Starter question cards */
#root .suggestions {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    max-width: 100%;
    margin: 0;
    padding: 0;
    order: 100 !important;
}

#root .suggestions button {
    background: rgba(255, 255, 255, 0.03) !important;
    border: 1px solid rgba(255, 255, 255, 0.1) !important;
    color: rgba(255, 255, 255, 0.85) !important;
    border-radius: 0.75rem;
    padding: 1rem 1.25rem !important;
    font-size: 0.9375rem !important;
    font-weight: 500 !important;
    line-height: 1.5 !important;
    text-align: left !important;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
    white-space: normal !important;
}

#root .suggestions button:hover {
    background: rgba(124, 58, 237, 0.12) !important;
    border-color: rgba(124, 58, 237, 0.3) !important;
    color: white !important;
    transform: translateY(-2px);
    box-shadow: 0 8px 16px -4px rgba(124, 58, 237, 0.2);
}

#root .suggestions button:active {
    transform: translateY(0);
}

/* ============================================================================
   ELEMENT HIDING
   ============================================================================ */

/* Hide Chainlit controls that we replace with custom toolbar */
#header button[data-sidebar='trigger'],
#header #sidebar-trigger-button,
#header #new-chat-button,
#header button#new-chat-button {
    display: none !important;
}

/* Hide theme toggle - we control the theme */
#theme-toggle,
button#theme-toggle {
    display: none !important;
    visibility: hidden !important;
}

/* ============================================================================
   MOBILE RESPONSIVE
   ============================================================================ */

/* Mobile adjustments */
@media (max-width: 768px) {
    /* Header - compact */
    #header {
        min-height: 56px !important;
        height: 56px !important;
        padding: 0.5rem 0.75rem !important;
    }

    /* Adjust main padding for header height */
    main {
        padding-top: 56px !important;
    }

    /* Sidebar header */
    div[data-sidebar='header'] {
        top: 56px !important;
    }

    /* Left container - full width between hamburger and right controls */
    #header .flex.items-center:first-child {
        flex: 1 !important;
    }

    /* Mobile header layout */
    .fluid-nav-group {
        display: flex !important;
        align-items: center !important;
        gap: 0.75rem !important;
        flex: 1 !important;
    }

    .fluid-logo {
        width: 28px;
        height: 28px;
    }

    .fluid-header-title {
        display: none !important; /* Hide title on mobile */
    }

    /* Hide hamburger on mobile - not needed */
    .fluid-hamburger {
        display: none !important;
    }

    /* Show agent selector on mobile, remove decorations */
    .fluid-agent-selector {
        display: flex !important;
        border-left: none !important;
        margin-left: 0 !important;
        padding-left: 0 !important;
        flex: 1 !important;
    }

    /* Hide "AGENT:" label on mobile */
    .fluid-agent-label {
        display: none !important;
    }

    /* Make dropdown full width on mobile */
    #chat-profiles-fluid {
        width: 100% !important;
        font-size: 0.875rem !important;
        padding: 0.5rem 0.75rem !important;
    }

    /* Right controls - tighter spacing */
    #header .flex.items-center.gap-1 {
        gap: 0.5rem !important;
        flex-shrink: 0 !important;
    }

    /* Hide desktop New Chat button on mobile */
    .fluid-new-chat-btn {
        display: none !important;
    }

    #user-nav-button span span {
        width: 1.75rem !important;
        height: 1.75rem !important;
    }

    /* Sidebar edge tab - slightly smaller and better positioning */
    .fluid-sidebar-edge-tab {
        width: 32px !important;
        height: 56px !important;
        opacity: 1 !important;
    }

    /* When sidebar is open on mobile, shift tab to match mobile sidebar width */
    body:has([data-state="expanded"][data-side="left"]) .fluid-sidebar-edge-tab {
        left: 16rem !important; /* Match Chainlit's mobile sidebar width */
    }

    /* Welcome screen */
    #welcome-screen {
        min-height: calc(100vh - 56px - 80px) !important;
        padding: 2rem 0 !important;
    }

    .fluid-welcome-title {
        font-size: 1.75rem !important;
    }

    /* Message composer */
    #message-composer {
        padding: 0.625rem 1rem !important;
        border-radius: 0.625rem 0.625rem 0 0 !important;
    }

    #chat-input {
        font-size: 0.875rem !important;
        padding: 0.375rem !important;
    }

    #chat-submit {
        width: 2rem !important;
        height: 2rem !important;
    }

    /* Starters - stack vertically */
    #root .suggestions {
        flex-direction: column !important;
    }

    #root .suggestions button {
        width: 100% !important;
        justify-content: center !important;
        padding: 0.875rem 1rem !important;
        font-size: 0.875rem !important;
    }

    /* Tables - smaller text */
    .message-content table {
        font-size: 0.8125rem !important;
    }

    .message-content table th {
        font-size: 10px !important;
        padding: 8px !important;
    }

    .message-content table td {
        font-size: 12px !important;
        padding: 6px 8px !important;
    }
}
