/* ==================== OVERRIDE .content FOR CHAT ==================== */

/* Chat Column Width - Single source of truth for alignment */
:root {
    --chat-column-width: 920px;
}

/* Hide feedback button when chat is active */
body:has(#chat.content.active) #feedbackWidget,
body:has(#chat.content.active) .feedback-widget,
body:has(#chat.content.active) .feedback-toggle-btn {
    display: none !important;
}

/* Prevent HTML and body scroll when chat is active - BUT KEEP SCROLLBAR TRACK */
html:has(#chat.content.active) {
    overflow-y: scroll !important;
    /* Keep scrollbar visible to prevent layout shift */
    height: 100vh;
    background: #FFFFFF !important;
}

body:has(#chat.content.active) {
    overflow: hidden !important;
    height: 100vh;
    width: 100%;
    background: #FFFFFF !important;
}

.main-content-centered:has(#chat.content.active) {
    overflow: hidden !important;
    height: 100vh;
    padding: var(--header-height) 0 0 0 !important;
    margin: 0 !important;
    background: #FFFFFF !important;
    max-width: 100% !important;
    width: 100% !important;
}

.app-container:has(#chat.content.active) {
    overflow: hidden !important;
    overflow-y: hidden !important;
    overflow-x: hidden !important;
    height: 100vh !important;
    background: #FFFFFF !important;
}

/* Fix tab-content padding for chat and prevent page scroll */
.tab-content.chat-active {
    margin: 0 !important;
    padding: 0 !important;
    max-width: 100% !important;
    height: 100vh !important;
    overflow: hidden !important;
    width: 100% !important;
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    background: #FFFFFF !important;
    z-index: 10;
    padding-bottom: calc(var(--bottom-nav-height) + 20px) !important;
}

#chat.content {
    padding: 0 !important;
    background: #FFFFFF !important;
    border: none !important;
    box-shadow: none !important;
    border-radius: 0 !important;
    min-height: 100vh !important;
    max-height: 100vh !important;
    height: 100vh !important;
    align-items: stretch;
    justify-content: center;
    overflow: hidden !important;
    position: relative;
    margin: 0 !important;
    width: 100% !important;
}

#chat.content.active {
    display: flex !important;
}

/* Hide all chat elements when chat tab is not active */
#chat.content:not(.active) {
    display: none !important;
}

/* Only show input dock on Chat tab */
body:has(#home.content.active) .chat-input-dock,
body:has(#agents.content.active) .chat-input-dock,
body:has(#automations.content.active) .chat-input-dock,
body:has(#files.content.active) .chat-input-dock {
    display: none !important;
}

/* Explicitly hide all chat child elements when chat is not active */
#chat.content:not(.active) .modern-chat-sidebar,
#chat.content:not(.active) .modern-chat-container,
#chat.content:not(.active) .sidebar-backdrop,
#chat.content:not(.active) .sidebar-edge-toggle,
#chat.content:not(.active) .modern-chat-main,
#chat.content:not(.active) .modern-messages-wrapper,
#chat.content:not(.active) .modern-input-wrapper {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
    pointer-events: none !important;
}

/* ==================== MODERN CHAT CONTAINER ==================== */

.modern-chat-container {
    display: flex;
    height: 100%;
    min-height: 600px;
    max-height: 100%;
    background: transparent;
    border-radius: 0;
    overflow: visible;
    box-shadow: none;
    position: relative;
    margin: 0;
    max-width: 100%;
    width: 100%;
    flex: 1;
}

/* Mesh gradient overlay for modern depth - only in top portion */
.modern-chat-container::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 150px;
    background: transparent;
    pointer-events: none;
    z-index: 0;
}

/* Only show sidebar when chat is active */
#chat.content.active .modern-chat-sidebar {
    width: 280px;
    background: #FFFFFF;
    backdrop-filter: blur(20px);
    border-right: 1px solid rgba(0, 0, 0, 0.06);
    display: flex !important;
    flex-direction: column;
    padding: var(--header-height) 20px 20px 20px;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    z-index: 150;
    flex-shrink: 0;
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.08);
    overflow-y: auto;
    overflow-x: hidden;
    visibility: visible !important;
    opacity: 1 !important;
    pointer-events: auto !important;
}

/* Hide sidebar by default when chat is not active */
.modern-chat-sidebar {
    display: none !important;
}

.modern-chat-sidebar.collapsed {
    transform: translateX(-100%) !important;
    pointer-events: none !important;
    box-shadow: none !important;
}

/* Backdrop overlay for mobile when sidebar is open */
.sidebar-backdrop {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 250;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}

/* Show backdrop on small screens when sidebar is open, but only if chat is active */
@media (max-width: 1023px) {
    #chat.content.active .sidebar-backdrop.visible {
        display: block;
        opacity: 1;
        pointer-events: auto;
    }

    /* Hide backdrop when chat is not active */
    #chat.content:not(.active) .sidebar-backdrop {
        display: none !important;
        opacity: 0 !important;
        pointer-events: none !important;
    }
}

/* Remove old sidebar-toggle styles when collapsed - not needed anymore */


/* Sidebar Toggle Icon - Next to Conversations Header */
.sidebar-toggle-icon {
    width: 36px;
    height: 36px;
    background: rgba(var(--color-primary-rgb), 0.06);
    border: 1px solid rgba(var(--color-primary-rgb), 0.12);
    border-radius: 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    color: var(--color-primary);
    flex-shrink: 0;
    position: relative;
    z-index: 100;
    pointer-events: auto !important;
}

.sidebar-toggle-icon:hover {
    background: rgba(var(--color-primary-rgb), 0.12);
    border-color: rgba(var(--color-primary-rgb), 0.25);
    transform: scale(1.08);
    box-shadow: 0 2px 8px rgba(var(--color-primary-rgb), 0.15);
}

.sidebar-toggle-icon:active {
    transform: scale(0.95);
    background: rgba(var(--color-primary-rgb), 0.15);
}

.sidebar-toggle-icon svg {
    width: 18px;
    height: 18px;
    transition: transform 0.3s ease;
    pointer-events: none;
}

/* Edge Toggle Button - Appears when sidebar is collapsed */
.sidebar-edge-toggle {
    position: fixed;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 32px;
    height: 80px;
    background: var(--color-primary);
    border: none;
    border-radius: 0 12px 12px 0;
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 200;
    box-shadow: 4px 0 16px rgba(var(--color-primary-rgb), 0.35);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    color: #ffffff;
    overflow: hidden;
}

.sidebar-edge-toggle::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
    transition: left 0.5s;
}

.sidebar-edge-toggle:hover::before {
    left: 100%;
}

.sidebar-edge-toggle:hover {
    width: 40px;
    box-shadow: 6px 0 24px rgba(var(--color-primary-rgb), 0.45);
    background: var(--color-primary-hover);
}

.sidebar-edge-toggle svg {
    transition: transform 0.3s ease;
    position: relative;
    z-index: 1;
}

.sidebar-edge-toggle:hover svg {
    transform: translateX(3px) scale(1.1);
}

.sidebar-edge-toggle:active {
    width: 36px;
}

/* Show edge button when sidebar is collapsed, but only if chat is active */
body:has(#chat.content.active .modern-chat-sidebar.collapsed) .sidebar-edge-toggle {
    display: flex;
    animation: slideInFromLeft 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Hide edge toggle when chat is not active */
#chat.content:not(.active)~* .sidebar-edge-toggle,
body:not(:has(#chat.content.active)) .sidebar-edge-toggle {
    display: none !important;
}

@keyframes slideInFromLeft {
    from {
        transform: translateY(-50%) translateX(-100%);
        opacity: 0;
    }

    to {
        transform: translateY(-50%) translateX(0);
        opacity: 1;
    }
}

/* Removed old toggle button styles */

.sidebar-header {
    margin-bottom: 16px;
    padding: 12px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    position: relative;
    z-index: 50;
}

.sidebar-header h3 {
    font-size: 13px;
    font-weight: 800;
    background: var(--color-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin: 0;
    text-transform: uppercase;
    letter-spacing: 1.2px;
}

.new-chat-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    padding: 14px 20px;
    background: var(--color-primary);
    color: #ffffff;
    border: none;
    border-radius: 12px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    margin-bottom: 24px;
    box-shadow: 0 4px 15px rgba(var(--color-primary-rgb), 0.25);
    position: relative;
    overflow: hidden;
}

.new-chat-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: left 0.5s;
}

.new-chat-btn:hover::before {
    left: 100%;
}

.new-chat-btn:hover {
    transform: translateY(-2px);
    background: var(--color-primary-hover);
    box-shadow: 0 6px 25px rgba(var(--color-primary-rgb), 0.35);
}

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

.new-chat-btn svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

/* Conversation List */
.conversation-list {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding-bottom: 20px;
    margin-top: 12px;
}

.conversation-list::-webkit-scrollbar {
    width: 8px;
}

.conversation-list::-webkit-scrollbar-track {
    background: rgba(var(--color-primary-rgb), 0.04);
    border-radius: 10px;
}

.conversation-list::-webkit-scrollbar-thumb {
    background: var(--color-primary);
    border-radius: 10px;
    border: 2px solid rgba(255, 255, 255, 0.5);
}

.conversation-list::-webkit-scrollbar-thumb:hover {
    background: var(--color-primary-hover);
}

.conversation-item {
    padding: 14px 16px;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    background: transparent;
    font-size: 14px;
    color: #1f2937;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    border: 1px solid transparent;
}

.conversation-item:hover {
    background: linear-gradient(135deg, rgba(var(--color-primary-rgb), 0.06) 0%, rgba(var(--color-accent-rgb), 0.04) 100%);
    transform: translateX(4px);
    border-color: rgba(var(--color-primary-rgb), 0.15);
}

.conversation-item.active {
    background: linear-gradient(135deg, rgba(var(--color-primary-rgb), 0.1) 0%, rgba(var(--color-accent-rgb), 0.06) 100%);
    font-weight: 600;
    color: var(--color-primary);
    border-color: rgba(var(--color-primary-rgb), 0.25);
    box-shadow: 0 2px 8px rgba(var(--color-primary-rgb), 0.12);
}

.conversation-preview {
    flex: 1;
    min-width: 0;
}

.conversation-text {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 14px;
    line-height: 1.5;
    font-weight: 500;
}

.conversation-date {
    font-size: 10px;
    color: #9ca3af;
    margin-top: 2px;
    font-weight: 400;
    letter-spacing: 0.3px;
}

.conversation-subtitle {
    font-size: 12px;
    color: #4B5563;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.4;
}

.chat-menu-btn {
    opacity: 0;
    background: none;
    border: none;
    color: #9ca3af;
    cursor: pointer;
    padding: 6px;
    border-radius: 8px;
    transition: all 0.2s ease;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    z-index: 2;
}

.conversation-item:hover .chat-menu-btn,
.chat-menu-btn.active {
    opacity: 1;
}

.chat-menu-btn:hover,
.chat-menu-btn.active {
    background: rgba(var(--color-primary-rgb), 0.08);
    color: var(--color-primary);
}

/* Dropdown */
.chat-menu-dropdown {
    position: absolute;
    right: 10px;
    top: 40px;
    background: white;
    border-radius: 12px;
    box-shadow:
        0 4px 6px -1px rgba(0, 0, 0, 0.1),
        0 2px 4px -1px rgba(0, 0, 0, 0.06),
        0 10px 15px -3px rgba(0, 0, 0, 0.1);
    border: 1px solid rgba(0, 0, 0, 0.05);
    width: 160px;
    z-index: 1000;
    /* High z-index to float above everything */
    padding: 6px;
    display: none;
    animation: fadeIn 0.2s ease;
}

.chat-menu-dropdown.visible {
    display: block;
}

/* Ensure parent item stacks correctly when menu is open */
.conversation-item.menu-open {
    z-index: 50;
    background: #ffffff;
    /* Ensure solid background */
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
    /* Subtle lift */
}

.chat-menu-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    width: 100%;
    border: none;
    background: none;
    text-align: left;
    font-size: 13px;
    color: #4b5563;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.chat-menu-item:hover {
    background: #f3f4f6;
    color: #1f2937;
}

.chat-menu-item.delete {
    color: #ef4444;
}

.chat-menu-item.delete:hover {
    background: #fef2f2;
}

.chat-menu-item svg {
    width: 16px;
    height: 16px;
    opacity: 0.7;
}

/* Mobile: Always show menu button */
@media (max-width: 768px) {
    .chat-menu-btn {
        opacity: 1;
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-5px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ==================== MAIN CHAT AREA ==================== */

.modern-chat-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: transparent;
    position: relative;
    width: 100%;
    margin-left: 0;
    z-index: 1;
    height: 100%;
    overflow: visible;
}

/* Chat Header - Hidden since we moved selector to bottom */
.chat-header-modern {
    display: none;
}

/* Old provider selector styles - kept for backward compatibility if needed */
.provider-selector-modern,
.provider-label,
.provider-select-modern {
    display: none !important;
}

/* Messages Wrapper - Scrollable container with HARD HEIGHT CONSTRAINT */
.modern-messages-wrapper {
    /* Height: viewport - header - input bar - bottom nav - gaps */
    /* Input bar ~44px + gap above it 10px = 54px */
    /* Bottom nav 80px (var) + gap below input 10px = 90px */
    height: calc(100vh - var(--header-height) - var(--bottom-nav-height) - 60px);
    max-height: calc(100vh - var(--header-height) - var(--bottom-nav-height) - 60px);
    overflow-y: auto !important;
    overflow-x: hidden;
    padding-top: 0;
    margin-top: var(--header-height);
    background: #FFFFFF;
    scroll-behavior: smooth;
    position: relative;
}

.modern-messages-wrapper::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 200px;
    background: transparent;
    pointer-events: none;
    z-index: 0;
}

/* ==================== CHAT COLUMN - SINGLE WIDTH SOURCE ==================== */
/* This wrapper controls the width for BOTH messages and input bar */
.chat-column {
    max-width: 980px;
    width: 100%;
    margin: 0 auto;
    padding: 0 24px;
    position: relative;
    z-index: 1;
}

/* Messages container - inherits width from .chat-column */
.modern-messages {
    width: 100%;
    /* Bottom padding for scroll buffer above input bar */
    padding: 16px 0 80px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    position: relative;
}

/* Welcome Message - Clean Command Card Style */
.welcome-message {
    text-align: center;
    padding: 60px 40px 70px;
    position: relative;
    overflow: hidden;
    max-width: 800px;
    margin: 30px auto 0;
    border-radius: 24px;
    background: #ffffff;
    border: 1px solid rgba(226, 232, 240, 0.8);
    box-shadow:
        0 20px 25px -5px rgba(0, 0, 0, 0.05),
        0 10px 10px -5px rgba(0, 0, 0, 0.02);
}

/* Subtle top accent */
.welcome-message::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 6px;
    background: linear-gradient(90deg, var(--color-primary) 0%, var(--color-primary-hover) 100%);
}

.welcome-message::after {
    display: none;
}

/* Heading */
.welcome-message h2 {
    font-size: 32px;
    font-weight: 800;
    color: #1e293b;
    margin: 0 0 12px 0;
    letter-spacing: -0.5px;
    position: relative;
    z-index: 1;
}

.welcome-message p {
    font-size: 16px;
    color: #64748b;
    margin: 0 auto 40px;
    font-weight: 500;
    line-height: 1.6;
    max-width: 540px;
    position: relative;
    z-index: 1;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes fadeOut {
    from {
        opacity: 1;
        transform: scale(1);
    }

    to {
        opacity: 0;
        transform: scale(0.95);
    }
}

/* Quick Actions Grid - Modern Glassmorphism */
.quick-actions-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
    margin: 0 0 30px;
    /* Removed top margin as p has bottom margin */
    padding: 0 20px;
}

@keyframes gridFadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.quick-action-card {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 20px 24px;
    background: #ffffff;
    border: 1px solid rgba(226, 232, 240, 0.8);
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    text-align: left;
    position: relative;
    overflow: hidden;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
    z-index: 1;
}

/* Primary Action Card (Plan My Day) */
.quick-action-card[data-action="plan-day"] {
    background: var(--purple-light);
    border-color: var(--purple-border);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.06);
}

.quick-action-card[data-action="plan-day"] .quick-action-icon {
    color: var(--purple-dark);
}

.quick-action-card[data-action="plan-day"] .quick-action-text strong {
    color: var(--text-primary);
}

.quick-action-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.08), 0 10px 10px -5px rgba(0, 0, 0, 0.03);
    border-color: rgba(var(--color-primary-rgb), 0.3);
}

.quick-action-card:active {
    transform: translateY(-2px);
}

.quick-action-icon {
    font-size: 32px;
    flex-shrink: 0;
    transition: transform 0.3s ease;
    color: #64748b;
}

.quick-action-card:hover .quick-action-icon {
    transform: scale(1.1) rotate(5deg);
}

.quick-action-text {
    flex: 1;
    min-width: 0;
}

.quick-action-text strong {
    display: block;
    font-size: 16px;
    font-weight: 700;
    color: #0f172a;
    margin-bottom: 6px;
    transition: color 0.3s ease;
}

.quick-action-card:hover .quick-action-text strong {
    color: var(--color-primary);
}

.quick-action-text span {
    display: block;
    font-size: 13px;
    color: #374151;
    line-height: 1.4;
}

/* Suggested Prompts - Modern Style */
.suggested-prompts {
    margin-top: 30px;
    animation: subtitleFadeIn 0.8s cubic-bezier(0.34, 1.56, 0.64, 1) 0.5s both;
}

.prompts-header {
    font-size: 12px;
    font-weight: 800;
    color: #9ca3af;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    margin-bottom: 18px;
}

.prompts-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    justify-content: center;
}

.prompt-chip {
    padding: 12px 22px;
    background: #ffffff;
    border: 1.5px solid rgba(var(--color-primary-rgb), 0.15);
    border-radius: 28px;
    font-size: 14px;
    font-weight: 600;
    color: var(--color-primary);
    cursor: pointer;
    transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    position: relative;
    overflow: hidden;
    box-shadow:
        0 2px 8px rgba(var(--color-primary-rgb), 0.05),
        0 4px 12px rgba(0, 0, 0, 0.02);
}

/* Staggered entrance animation */
.prompts-grid .prompt-chip {
    animation: chipFadeIn 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

.prompts-grid .prompt-chip:nth-child(1) {
    animation-delay: 0.6s;
}

.prompts-grid .prompt-chip:nth-child(2) {
    animation-delay: 0.7s;
}

.prompts-grid .prompt-chip:nth-child(3) {
    animation-delay: 0.8s;
}

.prompts-grid .prompt-chip:nth-child(4) {
    animation-delay: 0.9s;
}

@keyframes chipFadeIn {
    from {
        opacity: 0;
        transform: translateY(15px) scale(0.9);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Shimmer effect on hover */
.prompt-chip::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.6), transparent);
    transition: left 0.6s ease;
}

.prompt-chip:hover::before {
    left: 100%;
}

.prompt-chip:hover {
    background: #ffffff;
    border-color: rgba(var(--color-primary-rgb), 0.4);
    transform: translateY(-5px) scale(1.05);
    box-shadow:
        0 10px 30px rgba(var(--color-primary-rgb), 0.15),
        0 4px 10px rgba(0, 0, 0, 0.03);
    color: var(--color-primary-hover);
}

.prompt-chip:active {
    transform: translateY(-2px) scale(1.02);
}

.prompt-chip.processing {
    opacity: 0.6;
    pointer-events: none;
    background: linear-gradient(135deg, rgba(var(--color-primary-rgb), 0.12) 0%, rgba(var(--color-accent-rgb), 0.08) 100%);
}

/* ==================== MESSAGE WRAPPERS ==================== */

.message-wrapper {
    display: flex;
    gap: 16px;
    animation: messageSlideIn 0.4s ease-out;
    width: 100%;
    padding: 16px 0;
    position: relative;
}

/* Removed decorative border - flat style */

@keyframes messageSlideIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes messageComplete {
    0% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.02);
    }

    100% {
        transform: scale(1);
    }
}

.message-wrapper.user {
    animation: userMessageSlideIn 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes userMessageSlideIn {
    from {
        opacity: 0;
        transform: translateX(30px) scale(0.95);
    }

    to {
        opacity: 1;
        transform: translateX(0) scale(1);
    }
}

.message-wrapper.user {
    background: transparent;
    margin: 0 0 0 auto;
    padding: 12px 0;
    border: none;
    gap: 0;
    max-width: 85%;
    /* Constrain user messages */
    justify-content: flex-end;
}

.message-wrapper.assistant {
    background: transparent;
    position: relative;
    max-width: 100%;
    /* Full width to align with input bar */
}

/* Context Quote styles removed */

/* ==================== NEW TYPING INDICATOR - Minimal Pill ==================== */
/* Standalone component - NOT a message bubble */

.trivio-typing-indicator {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    padding: 12px 16px;
    margin-left: 56px;
    /* Align with where assistant messages start */
}

.trivio-typing-indicator .typing-dots {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    padding: 10px 16px;
    background: rgba(128, 128, 128, 0.08);
    border-radius: 16px;
    /* No border, no shadow - minimal design */
}

.trivio-typing-indicator .dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: rgba(var(--color-primary-rgb), 0.6);
    animation: typingDotPulse 1.4s infinite ease-in-out;
}

.trivio-typing-indicator .dot:nth-child(1) {
    animation-delay: 0s;
}

.trivio-typing-indicator .dot:nth-child(2) {
    animation-delay: 0.16s;
}

.trivio-typing-indicator .dot:nth-child(3) {
    animation-delay: 0.32s;
}

@keyframes typingDotPulse {

    0%,
    60%,
    100% {
        transform: scale(0.8);
        opacity: 0.4;
    }

    30% {
        transform: scale(1.1);
        opacity: 1;
    }
}

/* Legacy typing-bubble styles removed - no longer used */

.message-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    font-weight: 600;
    transition: all 0.2s ease;
}

.message-wrapper.user .message-avatar {
    display: none;
}

.message-wrapper.assistant .message-avatar {
    background: rgba(var(--color-primary-rgb), 0.08);
    color: var(--color-primary);
}

.message-avatar:hover {
    opacity: 0.8;
}

.message-content {
    flex: 1;
    max-width: 100%;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.message-wrapper.user .message-content {
    display: flex;
    justify-content: flex-end;
    align-items: flex-end;
}

.message-bubble {
    padding: 0;
    font-size: 16px;
    line-height: 1.7;
    color: #1F2937;
    word-wrap: break-word;
    letter-spacing: 0.01em;
}

/* User Message Bubble - Light Purple */
.message-wrapper.user .message-bubble {
    background: var(--purple-light);
    color: var(--text-primary);
    font-weight: 500;
    font-size: 16px;
    line-height: 1.6;
    padding: 14px 20px;
    border-radius: 20px 20px 4px 20px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    display: inline-block;
    max-width: 100%;
    word-wrap: break-word;
    transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    position: relative;
    overflow: hidden;
    animation: userBubblePop 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes userBubblePop {
    0% {
        opacity: 0;
        transform: scale(0.5) translateX(30px);
    }

    60% {
        transform: scale(1.03) translateX(-5px);
    }

    100% {
        opacity: 1;
        transform: scale(1) translateX(0);
    }
}

/* Shimmer effect on user bubble */
.message-wrapper.user .message-bubble::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg,
            transparent 0%,
            rgba(255, 255, 255, 0.2) 50%,
            transparent 100%);
    animation: bubbleShimmer 4s infinite;
}

@keyframes bubbleShimmer {
    0% {
        left: -100%;
    }

    100% {
        left: 200%;
    }
}

.message-wrapper.user .message-bubble:hover {
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.1);
    transform: translateY(-2px);
}

/* AI Response - Flat Style (No Card) */
.message-wrapper.assistant .message-bubble {
    background: transparent;
    border: none;
    color: #1e293b;
    border-radius: 0;
    padding: 0;
    box-shadow: none;
    position: relative;
    animation: assistantFadeIn 0.5s ease-out;
}

@keyframes assistantFadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
        filter: blur(4px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
        filter: blur(0);
    }
}

/* Message Actions */
.message-actions {
    display: flex;
    gap: 8px;
    margin-top: 12px;
    opacity: 0;
    transform: translateY(-5px);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.message-wrapper.assistant:hover .message-actions {
    opacity: 1;
    transform: translateY(0);
}

.message-action-btn {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    border: 1px solid rgba(0, 0, 0, 0.08);
    background: #ffffff;
    color: #6b7280;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.message-action-btn:hover {
    background: linear-gradient(135deg, rgba(var(--color-primary-rgb), 0.08) 0%, rgba(var(--color-accent-rgb), 0.06) 100%);
    border-color: rgba(var(--color-primary-rgb), 0.25);
    color: var(--color-primary);
    transform: translateY(-2px) scale(1.05);
    box-shadow: 0 4px 8px rgba(var(--color-primary-rgb), 0.15);
}

.message-action-btn:active {
    transform: translateY(0) scale(0.95);
}

.message-action-btn.liked {
    color: #ef4444 !important;
    background: rgba(239, 68, 68, 0.1) !important;
    border-color: rgba(239, 68, 68, 0.3) !important;
}

.message-action-btn.liked svg {
    fill: currentColor;
}

/* Text Formatting - ChatGPT-style clean look */
.message-bubble p {
    margin: 0 0 12px 0;
    /* Reduced margin */
    line-height: 1.7;
    color: #1F2937;
}

.message-bubble p:last-child {
    margin-bottom: 0;
}

.message-bubble strong {
    font-weight: 600;
    color: #0f172a;
    background: none;
    padding: 0;
}

/* Product/topic names - stand out more */
.message-bubble p>strong:first-child {
    color: #0f172a;
    font-weight: 700;
}

/* Headings - More conversational, less document-like */
.message-bubble .message-heading,
.message-bubble h1,
.message-bubble h2,
.message-bubble h3 {
    font-weight: 700;
    color: #1e293b;
    line-height: 1.3;
    margin: 24px 0 8px 0;
    padding-bottom: 0;
    border-bottom: none;
    /* Removed border for cleaner look */
    display: block;
}

.message-bubble h1.message-heading,
.message-bubble h1 {
    font-size: 18px;
    /* Significantly smaller */
    margin-top: 24px;
    color: #0f172a;
}

.message-bubble h2.message-heading,
.message-bubble h2 {
    font-size: 16px;
    margin-top: 20px;
    color: #1e293b;
}

.message-bubble h3.message-heading,
.message-bubble h3 {
    font-size: 15px;
    margin-top: 16px;
    color: #334155;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-size: 12px;
}

.message-bubble .message-heading:first-child,
.message-bubble h1:first-child,
.message-bubble h2:first-child,
.message-bubble h3:first-child {
    margin-top: 0;
}

/* Horizontal Rules */
.message-bubble .message-hr,
.message-bubble hr {
    border: none;
    border-top: 2px solid rgba(0, 0, 0, 0.1);
    margin: 24px 0;
    background: none;
}

.message-bubble em {
    font-style: italic;
    color: #000000;
}

/* Lists - Clean formatting */
.message-bubble .message-list {
    margin: 12px 0;
    padding-left: 24px;
    color: #1F2937;
}

.message-bubble .message-list li {
    margin: 6px 0;
    line-height: 1.7;
    position: relative;
    color: #1F2937;
    padding-left: 4px;
}

.message-bubble .message-list li strong {
    color: #0f172a;
    background: none;
    padding: 0;
}

.message-bubble ul.message-list li::marker {
    color: #94a3b8;
    /* Softer bullet color */
    font-size: 0.8em;
}

.message-bubble ol.message-list li::marker {
    color: #64748b;
    font-weight: 600;
    font-size: 0.9em;
}

.message-bubble ul.message-list {
    list-style-type: disc;
}

.message-bubble ol.message-list {
    list-style-type: decimal;
}

/* Table Styling - ChatGPT-style clean formatting */
.message-bubble .message-table {
    width: 100%;
    border-collapse: collapse;
    margin: 20px 0;
    font-size: 14px;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.message-bubble .message-table thead tr {
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.1) 0%, rgba(118, 75, 162, 0.08) 100%);
}

.message-bubble .message-table th {
    padding: 12px 16px;
    text-align: left;
    font-weight: 600;
    color: #1a1a1a;
    border-bottom: 2px solid rgba(102, 126, 234, 0.2);
}

.message-bubble .message-table td {
    padding: 12px 16px;
    color: #374151;
    border-bottom: 1px solid #e5e7eb;
}

.message-bubble .message-table tbody tr:hover {
    background-color: rgba(102, 126, 234, 0.04);
}

.message-bubble .message-table tbody tr:last-child td {
    border-bottom: none;
}

.message-bubble .message-table td strong,
.message-bubble .message-table th strong {
    color: #1a1a1a;
    font-weight: 700;
}


/* Code Styling */
.message-bubble .inline-code {
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.1) 0%, rgba(118, 75, 162, 0.08) 100%);
    padding: 4px 8px;
    border-radius: 6px;
    font-family: 'SF Mono', 'Monaco', 'Inconsolata', 'Fira Code', monospace;
    font-size: 15px;
    color: var(--color-primary);
    font-weight: 600;
    border: 1px solid rgba(102, 126, 234, 0.2);
}

.code-block-wrapper {
    position: relative;
    margin: 24px 0;
}

.message-bubble .code-block {
    background: #1e1e1e;
    border-radius: 8px;
    padding: 16px;
    padding-right: 60px;
    /* Space for copy button */
    margin: 0;
    overflow-x: auto;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.1);
    position: relative;
}

.message-bubble .code-block::before {
    display: none;
}

.message-bubble .code-block code {
    font-family: 'SF Mono', 'Monaco', 'Inconsolata', 'Fira Code', monospace;
    font-size: 14px;
    line-height: 1.6;
    color: #d4d4d4;
    display: block;
    white-space: pre;
    position: relative;
    z-index: 1;
    margin: 0;
    user-select: text;
    -webkit-user-select: text;
    -moz-user-select: text;
    -ms-user-select: text;
}

.code-copy-btn {
    position: absolute;
    top: 12px;
    right: 12px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 6px;
    padding: 6px 10px;
    color: #d4d4d4;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    font-weight: 500;
    transition: all 0.2s ease;
    z-index: 10;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.code-copy-btn:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.3);
    color: #ffffff;
    transform: translateY(-1px);
}

.code-copy-btn:active {
    transform: translateY(0);
}

.code-copy-btn.copied {
    background: rgba(34, 197, 94, 0.2);
    border-color: rgba(34, 197, 94, 0.4);
    color: #22c55e;
}

.code-copy-btn svg {
    width: 14px;
    height: 14px;
    flex-shrink: 0;
}

.code-copy-btn .copy-text {
    white-space: nowrap;
}

/* Legacy Typing Indicator styles - REMOVED
 * New typing indicator uses .trivio-typing-indicator class
 * See above for the new minimal pill design
 */

/* ==================== FIXED INPUT BAR DOCK ==================== */
/* Fixed positioned container that holds the input bar above bottom nav */
.chat-input-dock {
    position: fixed;
    left: 0;
    right: 0;
    bottom: calc(var(--bottom-nav-height) + 40px);
    z-index: 2010;
    padding: 0 24px;
    background: transparent;
    pointer-events: none;
    display: flex;
    justify-content: center;
}

.chat-input-dock .chat-column {
    max-width: 980px;
    width: 100%;
    pointer-events: auto;
}

/* Fade gradient ABOVE input bar - hides text approaching the input */
.chat-input-dock::before {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    bottom: 100%;
    height: 40px;
    background: linear-gradient(to bottom,
            rgba(255, 255, 255, 0) 0%,
            rgba(255, 255, 255, 0.8) 60%,
            rgba(255, 255, 255, 1) 100%);
    pointer-events: none;
    z-index: -1;
}

/* Legacy wrapper - hidden if still exists */
.modern-input-wrapper {
    display: none !important;
}

/* Bottom Model Selector - Moved INSIDE input container */
.bottom-model-selector {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    border: 1.5px solid rgba(var(--color-primary-rgb), 0.12);
    border-radius: 12px;
    font-size: 13px;
    font-weight: 600;
    color: var(--color-primary);
    background: rgba(var(--color-primary-rgb), 0.04);
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    outline: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 24 24' fill='none' stroke='%235B2D8B' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 8px center;
    padding-right: 26px;
    box-shadow: none;
    flex-shrink: 0;
    white-space: nowrap;
    min-width: 130px;
}

.bottom-model-select {
    padding: 8px 12px;
    border: 1.5px solid rgba(var(--color-primary-rgb), 0.12);
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
    color: var(--color-primary);
    background: rgba(var(--color-primary-rgb), 0.04);
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    outline: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 24 24' fill='none' stroke='%235B2D8B' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 8px center;
    padding-right: 26px;
    box-shadow: none;
    flex-shrink: 0;
    white-space: nowrap;
    min-width: 140px;
}

.bottom-model-select:hover {
    background: rgba(var(--color-primary-rgb), 0.08);
    border-color: rgba(var(--color-primary-rgb), 0.3);
}

.bottom-model-select:focus {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 2px rgba(var(--color-primary-rgb), 0.1);
}

/* ==================== INPUT ACTION BUTTON ==================== */
/* "+" button that opens action menu */

.input-action-wrapper {
    position: relative;
    flex-shrink: 0;
}

.input-action-btn {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 1px solid rgba(0, 0, 0, 0.1);
    background: transparent;
    color: #6b7280;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.input-action-btn:hover {
    background: rgba(0, 0, 0, 0.04);
    color: var(--color-primary);
}

.input-action-btn:active {
    transform: scale(0.92);
}

.input-action-btn[aria-expanded="true"] {
    background: rgba(0, 0, 0, 0.06);
    transform: rotate(45deg);
}

.input-action-btn svg {
    transition: transform 0.2s ease;
}

/* ==================== ACTION MENU POPOVER ==================== */

.input-action-menu {
    position: absolute;
    bottom: calc(100% + 12px);
    left: 0;
    min-width: 200px;
    background: #ffffff;
    border: 1px solid rgba(226, 232, 240, 0.8);
    border-radius: 12px;
    box-shadow:
        0 10px 40px rgba(0, 0, 0, 0.12),
        0 4px 12px rgba(0, 0, 0, 0.08);
    padding: 6px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(8px) scale(0.95);
    transform-origin: bottom left;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 100;
}

.input-action-menu.open {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

.action-menu-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 10px 12px;
    border: none;
    background: transparent;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    color: #334155;
    text-align: left;
    transition: all 0.15s ease;
}

.action-menu-item:hover:not(:disabled) {
    background: rgba(var(--color-primary-rgb), 0.06);
    color: var(--color-primary);
}

.action-menu-item:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.action-menu-item svg {
    flex-shrink: 0;
    color: var(--text-secondary);
}

.action-menu-item:hover:not(:disabled) svg {
    color: var(--color-primary);
}

.action-menu-item span:first-of-type {
    flex: 1;
}

.action-badge {
    font-size: 10px;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 4px;
    background: rgba(var(--color-primary-rgb), 0.08);
    color: var(--color-primary);
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.action-menu-divider {
    height: 1px;
    background: rgba(226, 232, 240, 0.8);
    margin: 6px 8px;
}

/* Floating Glass Input Container - Horizontal Layout: [+] [Input] [Send] */
.modern-input-container {
    max-width: 100%;
    width: 100%;
    margin: 0 auto;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 20px;
    background: var(--bg-card);
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: 28px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
    transition: all 0.2s ease;
    position: relative;
    min-height: 64px;
}

/* Focus Mode - Input Styling */
body.chat-focus-mode .modern-input-wrapper {
    bottom: 24px;
    /* Drop down when nav is hidden */
    transition: bottom 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

body.chat-focus-mode .modern-input-container {
    border-color: rgba(var(--color-primary-rgb), 0.3);
    box-shadow:
        0 12px 32px rgba(var(--color-primary-rgb), 0.12),
        0 4px 12px rgba(0, 0, 0, 0.04);
    transform: scale(1.01);
    padding: 18px 24px;
}

body.chat-focus-mode .modern-send-btn {
    transform: scale(1);
    background: var(--color-primary);
}

.modern-chat-input {
    caret-color: var(--color-primary);
}

@keyframes inputFloatIn {
    from {
        opacity: 0;
        transform: translateY(30px) scale(0.95);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Animated glow border on focus */
.modern-input-container::before {
    content: '';
    position: absolute;
    inset: -3px;
    border-radius: 31px;
    background: linear-gradient(135deg,
            rgba(var(--color-primary-rgb), 0.3) 0%,
            rgba(var(--color-primary-rgb), 0.2) 50%,
            rgba(var(--color-primary-rgb), 0.3) 100%);
    opacity: 0;
    z-index: -1;
    transition: opacity 0.4s ease;
    filter: blur(12px);
}

.modern-input-container:focus-within {
    background: var(--bg-card);
    border-color: rgba(102, 126, 234, 0.4);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.modern-input-container:focus-within::before {
    opacity: 0.3;
}

/* Simple focus animation */
@keyframes focusPulse {
    0%, 100% {
        opacity: 0.3;
    }
    50% {
        opacity: 0.5;
    }
}

/* Input container with attachments - special styling (simpler, no gradient) */
.modern-input-container.has-attachments {
    border-color: rgba(102, 126, 234, 0.4);
}

.modern-input-container.has-attachments::before {
    opacity: 0;
}

.modern-input-container.has-attachments:focus-within::before {
    opacity: 0.3;
}

/* Workspace input container with attachments */
.input-container.has-attachments {
    border-color: rgba(102, 126, 234, 0.4);
}

/* ================================
   MESSAGE ATTACHMENTS (Inline like Gemini/ChatGPT)
   ================================ */

.message-attachments {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid rgba(0, 0, 0, 0.08);
}

.message-attachment {
    border-radius: 8px;
    overflow: hidden;
    background: #f5f5f5;
    border: 1px solid rgba(0, 0, 0, 0.08);
}

.attachment-image {
    max-width: 200px;
    max-height: 200px;
    display: block;
    object-fit: cover;
    border-radius: 6px;
    cursor: pointer;
    transition: transform 0.2s ease;
}

.attachment-image:hover {
    transform: scale(1.02);
}

.attachment-file {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    min-width: 150px;
}

.attachment-file svg {
    flex-shrink: 0;
    color: #666;
}

.attachment-filename {
    font-size: 13px;
    font-weight: 500;
    color: #333;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 120px;
}

.attachment-filesize {
    font-size: 11px;
    color: #888;
    white-space: nowrap;
}

/* Dark mode support for message attachments */
@media (prefers-color-scheme: dark) {
    .message-attachment {
        background: rgba(255, 255, 255, 0.08);
        border-color: rgba(255, 255, 255, 0.1);
    }

    .message-attachments {
        border-top-color: rgba(255, 255, 255, 0.1);
    }

    .attachment-file svg {
        color: #aaa;
    }

    .attachment-filename {
        color: #eee;
    }

    .attachment-filesize {
        color: #888;
    }
}

.modern-chat-input {
    flex: 1;
    border: none !important;
    background: transparent !important;
    font-size: 16px;
    color: #0f172a;
    resize: none;
    outline: none !important;
    box-shadow: none !important;
    font-family: inherit;
    line-height: 1.5;
    max-height: 120px;
    min-height: 24px;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    -webkit-text-fill-color: #0f172a;
    padding: 4px 0;
}

.modern-chat-input:focus {
    background: transparent !important;
    background-color: transparent !important;
    outline: none !important;
    box-shadow: none !important;
    -webkit-box-shadow: none !important;
    border: none !important;
}

.modern-chat-input:focus-visible {
    outline: none !important;
    box-shadow: none !important;
}

/* Browser autofill override - remove blue backgrounds */
.modern-chat-input:-webkit-autofill,
.modern-chat-input:-webkit-autofill:hover,
.modern-chat-input:-webkit-autofill:focus,
.modern-chat-input:-webkit-autofill:active {
    -webkit-box-shadow: 0 0 0 30px transparent inset !important;
    background: transparent !important;
}

.modern-chat-input::placeholder {
    color: #9ca3af;
    font-weight: 500;
}

/* Force hidden model selector to stay hidden */
.modern-input-container .bottom-model-select {
    display: none !important;
    visibility: hidden !important;
    width: 0 !important;
    height: 0 !important;
    opacity: 0 !important;
    position: absolute !important;
    pointer-events: none !important;
}

/* Enhanced Send Button */
.modern-send-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    background: var(--color-primary);
    color: #ffffff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    flex-shrink: 0;
    box-shadow: 0 2px 4px rgba(var(--color-primary-rgb), 0.2);
    position: relative;
    overflow: hidden;
}

/* Ripple effect container */
.modern-send-btn::before {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.4) 0%, transparent 70%);
    transform: scale(0);
    opacity: 0;
    border-radius: 50%;
    transition: transform 0.5s, opacity 0.5s;
}

.modern-send-btn:hover:not(:disabled) {
    transform: scale(1.08);
    box-shadow: 0 4px 12px rgba(var(--color-primary-rgb), 0.35);
}

.modern-send-btn:active:not(:disabled) {
    transform: scale(0.95) rotate(0deg);
}

.modern-send-btn:active::before {
    animation: sendRipple 0.5s ease-out;
}

@keyframes sendRipple {
    0% {
        transform: scale(0);
        opacity: 1;
    }

    100% {
        transform: scale(2.5);
        opacity: 0;
    }
}

.modern-send-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    background: linear-gradient(135deg, #d1d5db 0%, #9ca3af 100%);
    box-shadow: none;
    transform: none;
}

.modern-send-btn svg {
    width: 18px;
    height: 18px;
    z-index: 1;
    position: relative;
    transition: transform 0.2s ease;
}

.modern-send-btn:hover:not(:disabled) svg {
    transform: translateX(1px);
}

.input-hint {
    display: none;
}

/* ==================== SCROLLBAR ==================== */

.modern-messages-wrapper::-webkit-scrollbar {
    width: 12px;
}

.modern-messages-wrapper::-webkit-scrollbar-track {
    background: #FFFFFF;
    border-radius: 10px;
}

.modern-messages-wrapper::-webkit-scrollbar-thumb {
    background: var(--color-primary);
    border-radius: 10px;
    border: 3px solid var(--bg-app);
    box-shadow: 0 2px 6px rgba(var(--color-primary-rgb), 0.25);
}

.modern-messages-wrapper::-webkit-scrollbar-thumb:hover {
    background: var(--color-primary-hover);
    box-shadow: 0 4px 12px rgba(var(--color-primary-rgb), 0.4);
}

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

/* Auto-collapse breakpoint */
@media (max-width: 1024px) {
    /* No extra padding needed anymore */
}

@media (max-width: 768px) {
    body:has(#chat.content.active) {
        overflow: hidden !important;
        position: fixed;
        width: 100%;
        height: 100%;
    }

    #chat.content {
        padding: 0;
        height: 100dvh;
        background: #FFFFFF;
        padding-bottom: 0;
        display: flex;
        flex-direction: column;
    }

    .modern-chat-container {
        height: 100%;
        width: 100%;
        border-radius: 0;
        min-height: auto;
        background: transparent;
        display: flex;
        flex-direction: column;
        overflow: hidden;
    }

    /* Messages - horizontal padding handled by .chat-column */

    .modern-messages-wrapper {
        padding: 0;
        flex: 1;
        overflow-y: auto !important;
        min-height: 0;
        /* Allow flexbox to shrink */
    }

    /* User messages - smaller on mobile */
    .message-wrapper.user {
        margin: 0 0 0 auto;
        padding: 8px 0;
        max-width: 80%;
    }

    .message-wrapper.user .message-bubble {
        padding: 10px 14px;
        font-size: 14px;
        border-radius: 16px 16px 4px 16px;
    }

    /* Assistant messages - smaller on mobile */
    .message-wrapper.assistant {
        padding: 8px 0;
        max-width: 90%;
    }

    .message-wrapper.assistant .message-bubble {
        padding: 10px 14px;
        font-size: 14px;
    }

    .message-avatar {
        width: 28px;
        height: 28px;
        font-size: 14px;
    }

    /* NEW Typing Indicator - Mobile adjustments */
    .trivio-typing-indicator {
        margin-left: 40px;
        padding: 8px 12px;
    }

    .trivio-typing-indicator .typing-dots {
        padding: 8px 12px;
        gap: 4px;
    }

    .trivio-typing-indicator .dot {
        width: 6px;
        height: 6px;
    }

    /* Welcome message - smaller */
    .welcome-message {
        padding: 40px 16px;
    }

    .welcome-message h2 {
        font-size: 24px;
    }

    .welcome-message p {
        font-size: 14px;
    }

    .quick-actions-grid {
        grid-template-columns: 1fr;
        gap: 12px;
        margin: 24px 0;
    }

    .quick-action-card {
        padding: 16px;
    }

    .quick-action-icon {
        font-size: 28px;
    }

    .quick-action-text strong {
        font-size: 15px;
    }

    .quick-action-text span {
        font-size: 12px;
    }

    .suggested-prompts {
        margin-top: 24px;
    }

    .prompts-grid {
        gap: 8px;
    }

    .prompt-chip {
        padding: 8px 14px;
        font-size: 12px;
    }

    .message-actions {
        opacity: 1;
        /* Always visible on mobile */
        transform: translateY(0);
    }

    .message-action-btn {
        width: 36px;
        height: 36px;
    }

    /* Mobile chat column adjustments */
    .chat-column {
        padding: 0 16px;
    }

    /* Mobile height constraint for messages wrapper */
    .modern-messages-wrapper {
        height: calc(100dvh - var(--header-height) - var(--bottom-nav-height) - 50px);
        max-height: calc(100dvh - var(--header-height) - var(--bottom-nav-height) - 50px);
        margin-top: var(--header-height);
        overflow-y: auto !important;
    }

    .modern-messages {
        padding: 12px 0 60px;
        gap: 14px;
    }

    /* Input dock - mobile adjustments */
    .chat-input-dock {
        bottom: calc(var(--bottom-nav-height) + 12px);
    }

    .chat-input-dock::before {
        height: 30px;
    }

    .modern-input-container {
        padding: 10px 14px;
        border-radius: 24px;
        gap: 10px;
        min-height: 52px;
    }

    /* Action button - mobile */
    .input-action-btn {
        width: 36px;
        height: 36px;
    }

    .input-action-menu {
        min-width: 180px;
    }

    .modern-chat-input {
        font-size: 16px;
        min-height: 26px;
    }

    .modern-send-btn {
        width: 40px;
        height: 40px;
        border-radius: 50%;
    }

    .modern-send-btn svg {
        width: 18px;
        height: 18px;
    }

    .bottom-model-select {
        padding: 6px 8px;
        padding-right: 22px;
        font-size: 11px;
        min-width: 100px;
        border-radius: 10px;
    }

    .input-hint {
        display: none;
        /* Hide on mobile */
    }

    /* ========== SIDEBAR MOBILE ========== */
    /* Hide chat sidebar and all chat elements when chat is not active on mobile */
    #chat.content:not(.active) .modern-chat-sidebar,
    #chat.content:not(.active) .modern-chat-container,
    #chat.content:not(.active) .sidebar-backdrop,
    #chat.content:not(.active) .sidebar-edge-toggle,
    #chat.content:not(.active) .modern-chat-main {
        display: none !important;
        visibility: hidden !important;
        opacity: 0 !important;
        pointer-events: none !important;
    }

    /* Default state on mobile - sidebar should be collapsed by default */
    #chat.content.active .modern-chat-sidebar {
        position: fixed;
        left: 0;
        top: 0;
        bottom: 0;
        z-index: 300;
        box-shadow: 4px 0 24px rgba(0, 0, 0, 0.25);
        transform: translateX(-100%);
        /* Start collapsed on mobile */
        width: 280px;
        max-width: 85vw;
        padding: 12px;
        padding-top: 130px;
        /* More space for header */
        background: #ffffff;
        display: flex !important;
        flex-direction: column;
        visibility: visible !important;
        opacity: 1 !important;
        pointer-events: auto !important;
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    }

    /* Expanded state on mobile - only when NOT collapsed */
    #chat.content.active .modern-chat-sidebar:not(.collapsed) {
        transform: translateX(0) !important;
    }

    /* Collapsed state on mobile - must override the active state rule */
    #chat.content.active .modern-chat-sidebar.collapsed {
        transform: translateX(-100%) !important;
        box-shadow: none !important;
        pointer-events: none !important;
    }

    /* Also ensure collapsed state works globally */
    .modern-chat-sidebar.collapsed {
        transform: translateX(-100%) !important;
        box-shadow: none !important;
    }

    /* Sidebar header - visible at top */
    .sidebar-header {
        padding: 8px 4px;
        margin-bottom: 12px;
        background: #ffffff;
        flex-shrink: 0;
    }

    .sidebar-header h3 {
        font-size: 12px;
    }

    /* Sidebar toggle icon - larger tap target */
    .sidebar-toggle-icon {
        width: 36px;
        height: 36px;
        min-width: 36px;
        min-height: 36px;
        background: rgba(102, 126, 234, 0.1);
        border: 1px solid rgba(102, 126, 234, 0.2);
        border-radius: 10px;
    }

    .sidebar-toggle-icon svg {
        width: 18px;
        height: 18px;
    }

    /* New chat button - visible */
    .new-chat-btn {
        padding: 12px 14px;
        font-size: 14px;
        margin-bottom: 12px;
        flex-shrink: 0;
    }

    /* Conversation list - scrollable */
    .conversation-list {
        margin-top: 0;
        padding-bottom: 20px;
        gap: 4px;
        flex: 1;
        overflow-y: auto;
    }

    .conversation-item {
        padding: 10px 12px;
        font-size: 13px;
        border-radius: 10px;
    }

    .conversation-text {
        font-size: 13px;
    }

    .conversation-date {
        font-size: 10px;
    }

    /* Edge toggle */
    .sidebar-edge-toggle {
        width: 28px;
        height: 60px;
        border-radius: 0 10px 10px 0;
        top: 50%;
    }

    .sidebar-edge-toggle svg {
        width: 16px;
        height: 16px;
    }

    .sidebar-edge-toggle:hover {
        width: 32px;
    }

    /* Main chat area */
    .modern-chat-main {
        width: 100%;
        margin-left: 0 !important;
        height: 100%;
    }
}

/* Even smaller phones */
@media (max-width: 480px) {
    #chat.content {
        height: 100dvh;
        padding-bottom: 0;
        background: #FFFFFF;
    }

    .message-wrapper.user .message-bubble,
    .message-wrapper.assistant .message-bubble {
        padding: 8px 12px;
        font-size: 13px;
    }

    /* Typing bubble - even smaller on tiny screens */
    .typing-bubble {
        margin-left: 36px;
        padding: 5px 10px;
        overflow: hidden;
    }

    .typing-dot {
        width: 5px;
        height: 5px;
    }

    .welcome-message {
        padding: 30px 12px;
    }

    .welcome-message h2 {
        font-size: 20px;
    }

    .welcome-icon {
        font-size: 40px;
    }

    /* Smallest phones - chat column adjustments */
    .chat-column {
        padding: 0 12px;
    }

    /* Smallest phones height constraint */
    .modern-messages-wrapper {
        height: calc(100dvh - var(--header-height) - var(--bottom-nav-height) - 45px);
        max-height: calc(100dvh - var(--header-height) - var(--bottom-nav-height) - 45px);
        overflow-y: auto !important;
    }

    .modern-messages {
        padding: 12px 0 50px;
        gap: 12px;
    }

    .chat-input-dock {
        bottom: calc(var(--bottom-nav-height) + 8px);
    }

    .chat-input-dock::before {
        height: 25px;
    }

    .modern-input-container {
        padding: 8px 12px;
        min-height: 48px;
        border-radius: 22px;
    }

    .modern-chat-input {
        font-size: 16px;
        min-height: 24px;
    }

    .modern-send-btn {
        width: 38px;
        height: 38px;
    }

    .bottom-model-select {
        padding: 5px 6px;
        padding-right: 18px;
        font-size: 10px;
        min-width: 80px;
    }

    .modern-chat-sidebar {
        width: 260px;
        padding: 10px;
        padding-top: var(--header-height);
        /* Space for header on small phones */
    }

    .sidebar-header {
        padding: 10px 6px;
    }

    .new-chat-btn {
        padding: 8px 12px;
        font-size: 12px;
    }

    .conversation-item {
        padding: 8px 10px;
    }

    .conversation-text {
        font-size: 12px;
    }
}

/* ==================== UTILITY CLASSES ==================== */

.fade-in {
    animation: fadeIn 0.3s ease-in-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

/* ==================== ACCESSIBILITY - REDUCED MOTION ==================== */

@media (prefers-reduced-motion: reduce) {

    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }

    .modern-input-container,
    .modern-input-container:focus-within {
        transform: none !important;
    }

    .modern-send-btn:hover:not(:disabled) {
        transform: scale(1.05) !important;
    }

    .quick-action-card:hover {
        transform: translateY(-4px) !important;
    }

    .prompt-chip:hover {
        transform: translateY(-2px) !important;
    }

    .message-wrapper.user .message-bubble::before {
        animation: none !important;
    }

    .welcome-message h2 {
        animation: none !important;
        background-size: 100% 100% !important;
    }
}

/* ==================== CHATGPT-STYLE RESPONSE PIPELINE STYLES ==================== */

/* Response intro paragraph - sets the stage (framing) */
.message-bubble .response-intro {
    margin: 0 0 16px 0;
    line-height: 1.7;
    color: #1F2937;
    font-size: 16px;
}

/* Response closing paragraph - follow-up invitation */
.message-bubble .response-closing {
    margin: 16px 0 0 0;
    line-height: 1.7;
    color: #4B5563;
    font-size: 15px;
    font-style: italic;
    padding-top: 12px;
    border-top: 1px solid rgba(102, 126, 234, 0.1);
}

/* Response lists - clean, scannable format */
.message-bubble .response-list {
    margin: 12px 0;
    padding-left: 0;
    list-style: none;
    color: #1F2937;
}

.message-bubble .response-list li {
    margin: 12px 0;
    line-height: 1.7;
    position: relative;
    padding-left: 24px;
    color: #1F2937;
}

.message-bubble .response-list li::before {
    content: '';
    position: absolute;
    left: 0;
    top: 10px;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-primary-hover) 100%);
}

.message-bubble .response-list li strong {
    color: #0f172a;
    font-weight: 700;
    background: none;
    padding: 0;
}

/* Response steps - numbered list with clean formatting */
.message-bubble .response-steps {
    margin: 16px 0;
    padding-left: 0;
    list-style: none;
    counter-reset: step-counter;
    color: #1F2937;
}

.message-bubble .response-steps li {
    margin: 16px 0;
    line-height: 1.7;
    position: relative;
    padding-left: 40px;
    color: #1F2937;
    counter-increment: step-counter;
}

.message-bubble .response-steps li::before {
    content: counter(step-counter);
    position: absolute;
    left: 0;
    top: 0;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-primary-hover) 100%);
    color: #ffffff;
    font-size: 13px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 6px rgba(102, 126, 234, 0.3);
}

.message-bubble .response-steps li strong {
    color: #0f172a;
    font-weight: 600;
}

/* Ensure clean paragraph spacing in response */
.message-bubble>p:first-child {
    margin-top: 0;
}

.message-bubble>p:last-child {
    margin-bottom: 0;
}

.message-bubble>.response-list:first-child,
.message-bubble>.response-steps:first-child {
    margin-top: 0;
}

.message-bubble>.response-list:last-child,
.message-bubble>.response-steps:last-child {
    margin-bottom: 0;
}

/* Ensure entity names in lists stand out */
.message-bubble .response-list li>strong:first-child {
    display: inline;
    color: #0f172a;
}

/* Pipeline output paragraphs */
.message-bubble p+p {
    margin-top: 12px;
}

/* Smooth animations for pipeline-rendered content */
.message-bubble .response-list li,
.message-bubble .response-steps li {
    animation: itemFadeIn 0.3s ease-out forwards;
    opacity: 0;
}

.message-bubble .response-list li:nth-child(1),
.message-bubble .response-steps li:nth-child(1) {
    animation-delay: 0.05s;
}

.message-bubble .response-list li:nth-child(2),
.message-bubble .response-steps li:nth-child(2) {
    animation-delay: 0.1s;
}

.message-bubble .response-list li:nth-child(3),
.message-bubble .response-steps li:nth-child(3) {
    animation-delay: 0.15s;
}

.message-bubble .response-list li:nth-child(4),
.message-bubble .response-steps li:nth-child(4) {
    animation-delay: 0.2s;
}

.message-bubble .response-list li:nth-child(5),
.message-bubble .response-steps li:nth-child(5) {
    animation-delay: 0.25s;
}

.message-bubble .response-list li:nth-child(n+6),
.message-bubble .response-steps li:nth-child(n+6) {
    animation-delay: 0.3s;
}

@keyframes itemFadeIn {
    from {
        opacity: 0;
        transform: translateX(-10px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* Reduced motion preference */
@media (prefers-reduced-motion: reduce) {

    .message-bubble .response-list li,
    .message-bubble .response-steps li {
        animation: none !important;
        opacity: 1 !important;
    }
}

/* ==================== MIXED CONTENT STYLING ==================== */
/* Allow natural ChatGPT-style mixed structures: paragraph + list + paragraph */

/* Headings in responses */
.message-bubble .response-heading {
    font-weight: 600;
    color: #1e293b;
    margin: 20px 0 8px 0;
    font-size: 15px;
}

.message-bubble .response-heading:first-child {
    margin-top: 0;
}

.message-bubble h1.response-heading {
    font-size: 18px;
}

.message-bubble h2.response-heading {
    font-size: 16px;
}

.message-bubble h3.response-heading {
    font-size: 15px;
}

/* Horizontal rules */
.message-bubble .response-hr {
    border: none;
    border-top: 1px solid rgba(0, 0, 0, 0.1);
    margin: 20px 0;
}

/* Allow paragraphs after lists (closing paragraphs) */
.message-bubble .response-list+p,
.message-bubble .response-steps+p {
    margin-top: 16px;
}

/* Allow lists after paragraphs (natural flow) */
.message-bubble p+.response-list,
.message-bubble p+.response-steps {
    margin-top: 12px;
}

/* Allow headings to introduce lists */
.message-bubble .response-heading+.response-list,
.message-bubble .response-heading+.response-steps {
    margin-top: 8px;
}

/* Spacing between consecutive lists (rare but allowed) */
.message-bubble .response-list+.response-list,
.message-bubble .response-steps+.response-steps {
    margin-top: 16px;
}

/* Response intro gets slightly more weight */
.message-bubble p.response-intro {
    color: #334155;
}

/* Ensure proper list marker styling */
.message-bubble .response-list li::marker {
    display: none;
}

.message-bubble .response-steps li::marker {
    display: none;
}

/* Strong text in responses */
.message-bubble strong {
    font-weight: 600;
    color: #1e293b;
}

/* Emphasized text */
.message-bubble em {
    font-style: italic;
    color: #475569;
}

/* Inline code */
.message-bubble code.inline-code {
    background: rgba(102, 126, 234, 0.08);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'SF Mono', Monaco, monospace;
    font-size: 14px;
    color: var(--color-primary);
}

/* ========================
   FILE ATTACHMENT STYLES
   ======================== */

/* Attachment Preview Container */
.input-attachments {
    padding: 12px;
    background: rgba(102, 126, 234, 0.05);
    border-radius: 12px;
    margin-bottom: 12px;
    border: 1px solid rgba(102, 126, 234, 0.1);
}

.input-attachments[hidden] {
    display: none;
}

/* Individual Attachment Preview */
.attachment-preview {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px;
    background: white;
    border-radius: 8px;
    margin-bottom: 8px;
    transition: all 0.2s ease;
    border: 1px solid rgba(102, 126, 234, 0.1);
}

.attachment-preview:last-child {
    margin-bottom: 0;
}

.attachment-preview:hover {
    background: rgba(102, 126, 234, 0.02);
    border-color: rgba(102, 126, 234, 0.2);
}

.attachment-icon {
    font-size: 32px;
    flex-shrink: 0;
    line-height: 1;
}

.attachment-info {
    flex: 1;
    min-width: 0;
}

.attachment-name {
    font-size: 14px;
    font-weight: 500;
    color: #1e293b;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 2px;
}

.attachment-size {
    font-size: 12px;
    color: #64748b;
}

.attachment-remove {
    background: transparent;
    border: none;
    padding: 6px;
    cursor: pointer;
    color: #94a3b8;
    border-radius: 4px;
    transition: all 0.2s ease;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.attachment-remove:hover {
    background: #fee2e2;
    color: #dc2626;
}

.attachment-remove svg {
    display: block;
}

/* Image Thumbnail Preview */
.attachment-thumbnail {
    width: 48px;
    height: 48px;
    border-radius: 6px;
    flex-shrink: 0;
    border: 1px solid rgba(102, 126, 234, 0.2);
}

/* Upload Progress Styles */
.attachment-preview.uploading .attachment-icon {
    animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.attachment-progress {
    width: 100%;
    height: 6px;
    background: rgba(102, 126, 234, 0.1);
    border-radius: 3px;
    overflow: hidden;
    margin-top: 4px;
}

.attachment-progress-bar {
    height: 100%;
    background: linear-gradient(90deg, #667eea 0%, #764ba2 100%);
    border-radius: 3px;
    transition: width 0.3s ease;
}

/* Upload Error State */
.attachment-preview.error .attachment-icon {
    color: #dc2626;
}

/* Retry Button */
.attachment-retry {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 6px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 500;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.attachment-retry:hover {
    transform: scale(1.05);
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.4);
}

/* ================================
   SIMPLE ATTACHMENT BAR DESIGN
   ================================ */

/* Workspace Attachment Bar */
.attachment-bar {
    background: #f8f9fa;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    margin-bottom: 12px;
    padding: 10px 14px;
    animation: slideDown 0.2s ease;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.attachment-bar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
}

.attachment-count {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    font-weight: 500;
    color: #666;
}

.attachment-count svg {
    flex-shrink: 0;
    color: #888;
}

.clear-attachments-btn {
    display: flex;
    align-items: center;
    gap: 4px;
    background: transparent;
    border: none;
    color: #999;
    font-size: 12px;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.clear-attachments-btn:hover {
    background: #fee2e2;
    color: #dc2626;
}

.attachment-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

/* Individual Attachment Item */
.attachment-item {
    display: flex;
    align-items: center;
    gap: 10px;
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 6px 10px 6px 6px;
    transition: all 0.2s ease;
    min-width: 160px;
    max-width: 280px;
}

.attachment-item:hover {
    border-color: #d1d5db;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.05);
}

.attachment-item-preview {
    width: 36px;
    height: 36px;
    border-radius: 6px;
    background: #f3f4f6;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    overflow: hidden;
}

.attachment-item-preview.has-image {
    background-size: cover;
    background-position: center;
}

.attachment-item-preview.uploading {
    background: #f3f4f6;
}

.attachment-item-icon {
    font-size: 16px;
}

.attachment-item-details {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.attachment-item-name {
    font-size: 12px;
    font-weight: 500;
    color: #374151;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.attachment-item-meta {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 10px;
    color: #9ca3af;
}

.attachment-item-type {
    background: #f3f4f6;
    color: #6b7280;
    padding: 2px 5px;
    border-radius: 3px;
    font-weight: 500;
}

.attachment-item-remove {
    background: transparent;
    border: none;
    padding: 4px;
    cursor: pointer;
    color: #9ca3af;
    border-radius: 4px;
    transition: all 0.2s ease;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.attachment-item-remove:hover {
    background: #fee2e2;
    color: #dc2626;
}

/* Upload Progress in Attachment Bar */
.attachment-item-progress {
    width: 100%;
    height: 3px;
    background: #e5e7eb;
    border-radius: 2px;
    overflow: hidden;
    margin-top: 3px;
}

.attachment-item-progress-bar {
    height: 100%;
    background: #6b7280;
    border-radius: 2px;
    transition: width 0.3s ease;
}

.attachment-spinner {
    width: 16px;
    height: 16px;
    border: 2px solid #e5e7eb;
    border-top-color: #6b7280;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Main Chat Attachment Bar */
.chat-attachment-bar {
    background: #f8f9fa;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    margin: 0 12px 12px 12px;
    padding: 10px 14px;
    animation: slideDown 0.2s ease;
}

.chat-attachment-bar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
}

.chat-attachment-count {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    font-weight: 500;
    color: #666;
}

.chat-clear-attachments-btn {
    display: flex;
    align-items: center;
    gap: 4px;
    background: transparent;
    border: none;
    color: #999;
    font-size: 12px;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.chat-clear-attachments-btn:hover {
    background: #fee2e2;
    color: #dc2626;
}

.chat-attachment-list {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    overflow-y: hidden;
    padding-bottom: 4px;
    scrollbar-width: thin;
    scrollbar-color: rgba(0, 0, 0, 0.2) transparent;
    -webkit-overflow-scrolling: touch;
}

.chat-attachment-list::-webkit-scrollbar {
    height: 4px;
}

.chat-attachment-list::-webkit-scrollbar-track {
    background: transparent;
}

.chat-attachment-list::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 2px;
}

/* Prevent attachment items from shrinking */
.chat-attachment-list .attachment-item {
    flex-shrink: 0;
}

/* Action Hint Badge */
.action-hint {
    font-size: 11px;
    color: #64748b;
    margin-left: auto;
    padding: 2px 6px;
    background: rgba(102, 126, 234, 0.08);
    border-radius: 4px;
    font-weight: 500;
}

/* ==========================================
   DRAG & DROP OVERLAY STYLES
   ========================================== */

/* Main Chat Drag Overlay */
.chat-drag-overlay {
    position: fixed;
    inset: 0;
    background: rgba(102, 126, 234, 0.08);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    border: 3px dashed var(--color-primary, #667eea);
    z-index: 9999;
    display: none;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    transition: opacity 0.2s ease;
}

.chat-drag-overlay.active {
    display: flex;
    animation: fadeIn 0.15s ease;
}

.chat-drag-overlay .drag-overlay-content {
    background: white;
    padding: 32px 48px;
    border-radius: 20px;
    text-align: center;
    box-shadow: 0 20px 60px rgba(102, 126, 234, 0.25),
                0 0 0 1px rgba(255, 255, 255, 0.8) inset;
    pointer-events: auto;
    animation: bounceIn 0.3s ease;
}

.chat-drag-overlay .drag-overlay-content svg {
    width: 48px;
    height: 48px;
    color: var(--color-primary, #667eea);
    margin-bottom: 16px;
}

.chat-drag-overlay .drag-overlay-content h3 {
    margin: 0 0 8px;
    color: #1f2937;
    font-size: 18px;
    font-weight: 600;
}

.chat-drag-overlay .drag-overlay-content p {
    margin: 0;
    color: #6b7280;
    font-size: 14px;
}

/* Agent Workspace Drag Overlay */
.agent-drag-overlay {
    position: absolute;
    inset: 0;
    background: rgba(102, 126, 234, 0.08);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    border: 3px dashed var(--color-primary, #667eea);
    border-radius: 12px;
    z-index: 100;
    display: none;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    transition: opacity 0.2s ease;
}

.agent-drag-overlay.active {
    display: flex;
    animation: fadeIn 0.15s ease;
}

.agent-drag-overlay .drag-overlay-content {
    background: white;
    padding: 24px 36px;
    border-radius: 16px;
    text-align: center;
    box-shadow: 0 16px 48px rgba(102, 126, 234, 0.2),
                0 0 0 1px rgba(255, 255, 255, 0.8) inset;
    pointer-events: auto;
    animation: bounceIn 0.3s ease;
}

.agent-drag-overlay .drag-overlay-content svg {
    width: 40px;
    height: 40px;
    color: var(--color-primary, #667eea);
    margin-bottom: 12px;
}

.agent-drag-overlay .drag-overlay-content h3 {
    margin: 0 0 6px;
    color: #1f2937;
    font-size: 16px;
    font-weight: 600;
}

.agent-drag-overlay .drag-overlay-content p {
    margin: 0;
    color: #6b7280;
    font-size: 13px;
}

/* Drag overlay animations */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes bounceIn {
    0% {
        opacity: 0;
        transform: scale(0.9);
    }
    50% {
        transform: scale(1.02);
    }
    100% {
        opacity: 1;
        transform: scale(1);
    }
}

/* ============================================
   Image Lightbox Modal
   ============================================ */

.image-lightbox {
    position: fixed;
    inset: 0;
    z-index: 10000;
    display: none;
    align-items: center;
    justify-content: center;
}

.image-lightbox.active {
    display: flex;
}

.lightbox-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.9);
    animation: fadeIn 0.2s ease-out;
}

.lightbox-content {
    position: relative;
    max-width: 90vw;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    animation: lightboxZoomIn 0.3s ease-out;
}

.lightbox-close {
    position: absolute;
    top: -40px;
    right: 0;
    background: transparent;
    border: none;
    color: white;
    cursor: pointer;
    padding: 8px;
    opacity: 0.7;
    transition: opacity 0.2s, transform 0.2s;
}

.lightbox-close:hover {
    opacity: 1;
    transform: scale(1.1);
}

.lightbox-image {
    max-width: 100%;
    max-height: 85vh;
    object-fit: contain;
    border-radius: 8px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.lightbox-caption {
    margin-top: 12px;
    color: rgba(255, 255, 255, 0.8);
    font-size: 14px;
    text-align: center;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

@keyframes lightboxZoomIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* Make attachment images clickable */
.message-attachment .attachment-image {
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

.message-attachment .attachment-image:hover {
    transform: scale(1.02);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}
/* Mobile Fix: Ensure Input Dock clears the Bottom Nav FAB */
@media (max-width: 768px) {
    .chat-input-dock {
        /* FAB top is approx 120px from bottom, so we need >140px */
        bottom: 160px !important;
        padding-bottom: env(safe-area-inset-bottom, 0px);
    }
}

/* Mobile Fix v2: Force huge padding and bottom lift */
@media (max-width: 768px) {
    .chat-input-dock {
        position: fixed !important;
        bottom: 180px !important; /* Move WAY up */
        left: 0;
        right: 0;
        z-index: 9999 !important; /* Force on top */
        background: transparent !important;
    }
    
    .modern-messages-wrapper {
        padding-bottom: 200px !important; /* Ensure content doesn't hide behind input */
    }
    
    /* Ensure the input container itself is visible */
    .modern-input-container {
        background: #ffffff !important;
        box-shadow: 0 -4px 20px rgba(0,0,0,0.1) !important;
    }
}
