/* Custom styles for LlamaIndex RAG Chat */

/* Comprehensive iOS zoom prevention */
html {
    -webkit-text-size-adjust: 100%;
    -ms-text-size-adjust: 100%;
    text-size-adjust: 100%;
    touch-action: manipulation;
}

html {
    margin: 0 !important;
    padding: 0 !important;
}

body {
    -webkit-text-size-adjust: 100%;
    -ms-text-size-adjust: 100%;
    text-size-adjust: 100%;
    touch-action: manipulation;
    overflow-x: hidden;
    margin: 0 !important;
    padding: 0 !important;
}

/* Demo Banner - Full Width Edge to Edge */
#demoBanner {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    width: 100% !important;
    min-width: 100% !important;
    max-width: none !important;
    margin: 0 !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
    padding: 8px 0 !important;
    padding-left: 0 !important;
    padding-right: 0 !important;
    box-sizing: border-box !important;
    transform: none !important;
}

/* Override any parent constraints */
body > #demoBanner {
    position: fixed !important;
    left: 0 !important;
    right: 0 !important;
    width: 100% !important;
}

* {
    -webkit-text-size-adjust: 100%;
    -ms-text-size-adjust: 100%;
    text-size-adjust: 100%;
    -webkit-tap-highlight-color: transparent;
}

input[type="email"], 
input[type="password"], 
input[type="text"], 
textarea,
select,
button {
    font-size: 16px !important;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    border-radius: 0;
    -webkit-user-select: text;
    -webkit-touch-callout: default;
}

/* RISK INTELLIGENCE MOBILE RESPONSIVE STYLES */
@media (max-width: 768px) {
    /* Risk Intelligence Dashboard Container - stack vertically */
    #riskIntelligenceContainer {
        flex-direction: column !important;
        padding: 8px !important;
        margin: 0 !important;
        max-height: none !important;
    }
    
    /* Sidebar - full width on mobile */
    .risk-intelligence-sidebar {
        width: 100% !important;
        border-right: none !important;
        border-bottom: 1px solid #e5e7eb !important;
        padding: 12px !important;
        max-height: 300px !important;
        overflow-y: auto !important;
    }
    
    /* Statistics Cards - horizontal grid on mobile */
    .stats-grid {
        display: grid !important;
        grid-template-columns: repeat(3, 1fr) !important;
        gap: 8px !important;
    }
    
    /* Statistics cards - smaller on mobile */
    .stats-grid .bg-white {
        padding: 8px !important;
    }
    
    .stats-grid .text-2xl {
        font-size: 1.2rem !important;
    }
    
    .stats-grid .text-sm {
        font-size: 0.7rem !important;
    }
    
    /* Risk cards grid - single column on mobile */
    .risk-cards-grid {
        grid-template-columns: repeat(1, 1fr) !important;
        gap: 12px !important;
    }
    
    /* Individual risk cards - smaller padding */
    .risk-card {
        padding: 12px !important;
        margin: 0 !important;
    }
    
    /* Filter controls - stack vertically */
    .filter-controls {
        flex-direction: column !important;
        gap: 8px !important;
        margin-bottom: 12px !important;
    }
    
    .filter-controls > div {
        width: 100% !important;
    }
    
    .filter-controls select {
        width: 100% !important;
        margin: 0 !important;
    }
    
    /* Main content area - full width */
    .risk-intelligence-sidebar + .flex-1 {
        padding: 12px !important;
    }
    
    /* Intelligence Modal - full screen on mobile */
    #intelligenceModal .bg-white {
        max-width: 100vw !important;
        max-height: 100vh !important;
        margin: 0 !important;
        border-radius: 0 !important;
    }
    
    /* Risk Details Modal - full screen on mobile */
    #riskDetailsModal .bg-white {
        max-width: 100vw !important;
        max-height: 100vh !important;
        margin: 0 !important;
        border-radius: 0 !important;
    }
    
    /* Risk details grid - single column */
    .risk-details-grid {
        grid-template-columns: repeat(1, 1fr) !important;
    }
    
    /* Category breakdown - horizontal scroll */
    #categoryBreakdown {
        display: flex !important;
        overflow-x: auto !important;
        gap: 8px !important;
        padding-bottom: 8px !important;
    }
    
    #categoryBreakdown > div {
        min-width: 120px !important;
        flex-shrink: 0 !important;
    }
}

/* UNIVERSAL MOBILE FONT SIZE OVERRIDE - Applied to ALL browsers */
@media (max-width: 768px) {
    * {
        font-size: 14px !important;
        line-height: 1.4 !important;
    }
    
    body, html, div, p, span, h1, h2, h3, h4, h5, h6, td, th, button, input, textarea, select {
        font-size: 14px !important;
        line-height: 1.4 !important;
    }
    
    .text-xl, .text-lg, .text-base, .text-sm, .text-xs {
        font-size: 14px !important;
        line-height: 1.4 !important;
    }
    
    /* Hide placeholder text on mobile */
    #messageInput::placeholder {
        color: transparent !important;
        opacity: 0 !important;
    }
    
    /* Show navigation tabs on mobile when sidebar is open - compressed */
    #conversationSidebar .nav-tabs-section {
        display: flex !important;
        height: auto !important;
        min-height: 120px !important;
        padding: 4px !important;
    }
    
    /* Compressed mobile navigation tabs */
    #conversationSidebar .nav-tab {
        padding: 4px 12px !important; /* Reduced by 35% from 6px */
        margin: 1px 0 !important; /* Reduced margin for tighter spacing */
        font-size: 12px !important;
        min-height: 28px !important; /* Reduced by 35% from 32px */
        display: flex !important;
        align-items: center !important;
        border-radius: 6px !important;
    }
    
    #conversationSidebar .nav-tab i {
        font-size: 12px !important;
        margin-right: 8px !important;
        width: 16px !important;
        text-align: center !important;
    }
    
    #conversationSidebar .nav-tab span {
        font-size: 12px !important;
        font-weight: 500 !important;
    }
    
    /* Adjust conversations section height on mobile */
    #conversationSidebar .conversations-section {
        height: calc(100% - 200px) !important;
        flex: 1 !important;
    }
    
    /* Fix mobile chat area layout */
    #chatArea {
        width: 100% !important;
        min-width: 0 !important;
        max-width: 100vw !important;
    }
    
    /* Mobile input area - always visible and thinner */
    #chatArea .border-t {
        position: fixed !important;
        bottom: 0 !important;
        left: 0 !important;
        right: 0 !important;
        width: 100% !important;
        z-index: 30 !important;
        background: white !important;
        border-top: 1px solid #e5e7eb !important;
        padding: 8px !important;
    }
    
    /* Adjust messages container to account for fixed header and input */
    #messagesContainer {
        padding-bottom: 200px !important;
        margin-bottom: 0 !important;
        max-height: calc(100vh - 200px) !important;
        overflow-y: auto !important;
    }
    
    /* Mobile input styling - thinner and no iOS zoom */
    #messageInput {
        font-size: 16px !important; /* Prevents zoom on iOS */
        min-height: 32px !important;
        height: 32px !important;
        padding: 6px 10px !important;
        transform: scale(1) !important; /* Additional iOS zoom prevention */
    }
    
    /* Prevent iOS zoom on ALL inputs */
    input, textarea, select {
        font-size: 16px !important;
        transform: scale(1) !important;
    }
    
    /* Mobile send button - thinner */
    #sendBtn {
        padding: 6px 10px !important;
        min-width: 44px !important;
        min-height: 32px !important;
    }
    
    /* Mobile body constraints */
    body {
        overflow-x: hidden !important;
        width: 100vw !important;
        max-width: 100vw !important;
    }
    
    /* MOBILE CHAT MESSAGES - Make them much thinner */
    .message-bubble-user,
    .message-bubble-assistant,
    div[style*="background-color: #6ab9c9"],
    .message {
        padding: 4px 8px !important;
        margin: 4px 0 !important;
        border-radius: 8px !important;
        min-height: auto !important;
        font-size: 14px !important;
        max-width: 85% !important;
        line-height: 1.2 !important;
    }
    
    /* Small chat content */
    .message-content h1, .message-content h2, .message-content h3 {
        font-size: 14px !important;
        line-height: 1.2 !important;
        margin: 2px 0 !important;
    }
    
    /* Small tables */
    .message-content table {
        font-size: 12px !important;
    }
    
    .message-content table th,
    .message-content table td {
        padding: 4px 6px !important;
        font-size: 12px !important;
    }
    
    /* Mobile source citations - compact but readable */
    .source-tag,
    a[style*="color: blue"],
    .citation-link {
        font-size: 9px !important;
        min-width: 16px !important;
        height: 16px !important;
        padding: 1px 3px !important;
        margin: 1px !important;
        background-color: #f3f4f6 !important;
        color: #374151 !important;
        border: 1px solid #d1d5db !important;
        border-radius: 3px !important;
        text-decoration: none !important;
        display: inline-flex !important;
        align-items: center !important;
        justify-content: center !important;
        font-weight: 500 !important;
        line-height: 1 !important;
    }
    
    /* Mobile citation hover states */
    .source-tag:hover,
    a[style*="color: blue"]:hover,
    .citation-link:hover {
        background-color: #e5e7eb !important;
        color: #1f2937 !important;
    }
}

/* Production UI Polish Enhancements */
:root {
    --primary-color: #6ab9c9;
    --primary-hover: #5aa8b8;
    --primary-light: #e0f4f7;
    --text-primary: #1f2937;
    --text-secondary: #6b7280;
    --border-color: #e5e7eb;
    --shadow-sm: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

/* Smooth page transitions */
body {
    transition: all 0.2s ease;
}

/* Enhanced message bubbles */
.message {
    animation: messageSlideIn 0.3s ease-out;
    transition: all 0.2s ease;
}

/* Universal thin chat bubbles - works in all environments */
.message-bubble-user,
.message-bubble-assistant,
.message,
div[style*="background-color: #6ab9c9"] {
    padding: 4px 8px;
    margin: 2px 0;
    border-radius: 8px;
    line-height: 1.2;
    max-width: 85%;
}

/* Force thin styling on mobile-width screens */
@media screen and (max-width: 480px) {
    .message-bubble-user,
    .message-bubble-assistant,
    .message,
    div[style*="background-color: #6ab9c9"] {
        padding: 4px 8px !important;
        margin: 2px 0 !important;
        border-radius: 8px !important;
        line-height: 1.2 !important;
        max-width: 85% !important;
    }
}

@keyframes messageSlideIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Enhanced chat input */
#messageInput {
    transition: all 0.2s ease, height 0.1s ease;
    border-radius: 12px;
}

#messageInput:focus {
    box-shadow: var(--shadow-md);
    border-color: var(--primary-color);
}

/* Enhanced send button */
#sendBtn {
    transition: all 0.2s ease;
    border-radius: 12px;
    box-shadow: var(--shadow-sm);
}

#sendBtn:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
}

#sendBtn:active {
    transform: translateY(0);
    box-shadow: var(--shadow-sm);
}

/* Enhanced Wave Loading Animation */
.wave-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2rem;
}

.wave-text {
    font-size: 1.125rem;
    color: var(--primary-color);
    font-weight: 600;
    text-align: center;
    opacity: 0;
    animation: fadeIn 1s ease-in-out 0.5s forwards;
    letter-spacing: 0.025em;
}

.wave-animation {
    display: flex;
    gap: 0.5rem;
    align-items: end;
    height: 60px;
    padding: 0.5rem;
    border-radius: 12px;
    background: linear-gradient(135deg, rgba(106, 185, 201, 0.05), rgba(106, 185, 201, 0.1));
}

.wave-bar {
    width: 8px;
    background: linear-gradient(to top, var(--primary-color), #e0f4f7);
    border-radius: 4px;
    animation: waveMotion 1.5s ease-in-out infinite;
    box-shadow: 0 2px 4px rgba(106, 185, 201, 0.2);
}

.wave-bar:nth-child(1) { animation-delay: 0s; height: 20px; }
.wave-bar:nth-child(2) { animation-delay: 0.1s; height: 30px; }
.wave-bar:nth-child(3) { animation-delay: 0.2s; height: 45px; }
.wave-bar:nth-child(4) { animation-delay: 0.3s; height: 60px; }
.wave-bar:nth-child(5) { animation-delay: 0.4s; height: 45px; }
.wave-bar:nth-child(6) { animation-delay: 0.5s; height: 30px; }
.wave-bar:nth-child(7) { animation-delay: 0.6s; height: 20px; }
.wave-bar:nth-child(8) { animation-delay: 0.7s; height: 15px; }

@keyframes waveMotion {
    0%, 100% {
        transform: scaleY(0.5);
        opacity: 0.7;
    }
    50% {
        transform: scaleY(1.2);
        opacity: 1;
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Loading timer styles */
.loading-timer {
    animation: fadeIn 0.8s ease-in-out 1s forwards;
    opacity: 0;
}

.loading-info {
    margin-top: 1rem;
}

/* Ensure loading container is centered */
.loading-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    padding: 1rem 0;
}

/* Mobile Responsiveness */
@media (max-width: 767px) {
    /* Mobile sidebar - only on mobile screens */
    #conversationSidebar {
        position: fixed !important;
        left: -280px !important;
        top: 0 !important;
        bottom: 0 !important;
        z-index: 9999 !important;
        width: 280px !important;
        height: 100vh !important;
        background-color: white !important;
        border-right: 1px solid #e5e7eb !important;
        box-shadow: 2px 0 10px rgba(0,0,0,0.1) !important;
        transition: left 0.4s cubic-bezier(0.4, 0, 0.2, 1) !important;
        display: flex !important;
        flex-direction: column !important;
        transform: none !important;
    }
    
    /* When sidebar should be visible on mobile */
    #conversationSidebar.mobile-open {
        left: 0 !important;
    }
    
    /* Mobile overlay styling */
    #mobileOverlay {
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        background-color: rgba(0, 0, 0, 0.5) !important;
        z-index: 9998 !important;
        display: none !important;
    }
    
    #mobileOverlay.mobile-visible {
        display: block !important;
    }
    
    /* Chat area full width on mobile */
    #chatArea {
        width: 100%;
        margin-left: 0;
    }
    
    /* Messages container padding for mobile */
    #messagesContainer {
        padding: 1rem;
        max-height: calc(100vh - 180px);
    }
    
    /* Input area responsive */
    .flex-shrink-0 {
        padding: 0.75rem;
    }
    
    /* Modal adjustments for mobile */
    .max-w-md {
        margin: 1rem;
        max-width: calc(100vw - 2rem);
    }
    
    /* PDF viewer responsive */
    .max-w-6xl {
        margin: 0.5rem;
        max-width: calc(100vw - 1rem);
        max-height: calc(100vh - 1rem);
    }
    
    /* Header responsive text */
    .text-xl {
        font-size: 1.125rem;
    }
    
    .text-lg {
        font-size: 1rem;
    }

    /* Navigation tabs on mobile */
    .nav-tab {
        padding: 0.49rem 0.5rem; /* Reduced by 35% from 0.75rem */
        font-size: 0.85rem;
    }
    
    .nav-tab i {
        margin-right: 0.25rem;
    }
    
    /* Conversation items on mobile */
    .conversation-item {
        padding: 0.75rem 1rem;
        font-size: 0.9rem;
    }
    
    /* Target exact chat bubble classes from HTML */
    .message .bg-white.rounded-lg.p-4.shadow-sm.border.max-w-4xl,
    .message .bg-white.rounded-lg.p-4.shadow-sm.border.max-w-2xl,
    /* REMOVED - This was making chat bubbles huge */
    
    /* Force consistent small font size */
    .message-content,
    .message-content *,
    .message *,
    #chatMessages *,
    #chatMessages div,
    #chatMessages p,
    #chatMessages span {
        font-size: 14px !important;
        line-height: 1.4 !important;
        font-weight: normal !important;
    }
    
    /* Override ALL Tailwind size classes */
    .text-sm, .text-xs, .text-base, .text-lg, .text-xl {
        font-size: 14px !important;
        line-height: 1.4 !important;
    }
    
    /* Bigger avatar on mobile - no padding */
    .profile-container-chat {
        width: 48px !important;
        height: 48px !important;
        padding: 0 !important;
        margin: 0 !important;
    }
    
    /* AGGRESSIVELY hide AI Assistant logo in chat messages */
    img[src="/static/logo.png"],
    img[alt="AI Assistant"],
    .w-8.h-8.rounded-full.object-cover.flex-shrink-0,
    .w-8.h-8.rounded-full,
    .flex-shrink-0 img,
    .message img,
    .welcome-message img,
    .flex.items-start.space-x-3 img:first-child {
        display: none !important;
        visibility: hidden !important;
        width: 0px !important;
        height: 0px !important;
        opacity: 0 !important;
        position: absolute !important;
        left: -9999px !important;
    }
    
    /* Remove spacing for hidden avatars */
    .message.flex.items-start.space-x-3 {
        gap: 0 !important;
        space: 0 !important;
    }
    
    /* Bigger user input on mobile */
    #messageInput {
        font-size: 1.1rem !important;
        padding: 1rem 1.25rem !important;
        min-height: 50px !important;
    }
    
    /* Bigger send button on mobile */
    #sendBtn {
        padding: 1rem 1.5rem !important;
        font-size: 1.1rem !important;
        min-height: 50px !important;
    }
}

/* Tablet adjustments */
@media (min-width: 768px) and (max-width: 1023px) {
    #conversationSidebar {
        width: 16rem; /* Slightly smaller on tablets */
    }
    
    #messagesContainer {
        padding: 1.25rem;
    }
}

/* Fixed height layout for proper scrolling */
html, body {
    height: 100vh;
    overflow: hidden;
}

/* Ensure main app container uses full height */
#mainApp {
    height: 100vh;
    max-height: 100vh;
}

/* Chat area needs full height for proper flex layout */
#chatArea {
    height: 100%;
    max-height: 100%;
}

/* Scrollbar styling */
.overflow-y-auto::-webkit-scrollbar {
    width: 6px;
}

.overflow-y-auto::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.overflow-y-auto::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 3px;
}

.overflow-y-auto::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* Ensure proper scrolling in containers with fixed header */
#messagesContainer {
    scrollbar-width: thin;
    scrollbar-color: #c1c1c1 #f1f1f1;
    height: 100%;
    max-height: calc(100vh - 180px); /* Account for fixed header and input area */
    overflow-y: auto;
    padding-bottom: 40px; /* Reduced padding for cleaner appearance */
}

/* Fix source container spacing with fixed header */
.sources-actions-container {
    margin-top: 0.5rem;
    margin-bottom: 0.5rem;
    clear: both;
}

/* Ensure last message has proper spacing */
.message:last-child .sources-actions-container {
    margin-bottom: 0.5rem;
    padding-bottom: 0.25rem;
}

/* Additional mobile source visibility */
@media (max-width: 768px) {
    .message:last-child {
        margin-bottom: 1rem !important;
        padding-bottom: 0.5rem !important;
    }
    
    .sources-actions-container {
        margin-bottom: 0.5rem !important;
        padding-bottom: 0.25rem !important;
    }
}

#conversationsList {
    scrollbar-width: thin;
    scrollbar-color: #c1c1c1 #f1f1f1;
    height: 100%;
    max-height: calc(75vh - 60px); /* Account for conversations header */
}

/* Ensure proper flex behavior and scrolling */
.min-h-0 {
    min-height: 0;
}

/* Fixed input area styling */
.flex-shrink-0 {
    flex-shrink: 0;
}

/* Ensure main content area distributes space properly */
#mainApp > div:first-child {
    flex-shrink: 0; /* Header should not shrink */
}

/* Conversation sidebar height fix */
#conversationSidebar {
    height: 100%;
    max-height: 100%;
}

/* Navigation tabs styling - auto-size based on content */
.nav-tabs-section {
    background-color: white;
    flex-shrink: 0; /* Don't shrink navigation */
}

.nav-tab {
    background-color: white;
    border: none;
    display: flex;
    align-items: center;
    padding: 0.57rem 1rem; /* Reduced by 35% for more conversation space */
    min-height: 32px; /* Reduced by 35% from 44px */
    font-size: 0.95rem;
    font-weight: 500;
    transition: all 0.2s ease;
}

.nav-tab:hover {
    background-color: #f9fafb;
}

.nav-tab.active {
    background-color: #f3f4f6;
}

.nav-tab i {
    color: #6b7280;
    font-size: 1rem;
    width: 1.25rem;
    margin-right: 0.875rem;
}

.nav-tab.active i {
    color: rgb(106, 185, 201);
}

.nav-tab span {
    color: #111827;
    font-weight: 600;
    letter-spacing: 0.01em;
}

.nav-tab.active span {
    color: #111827;
}

/* Conversations section styling - takes remaining space */
.conversations-section {
    background-color: white;
    flex: 1; /* Take up all remaining space */
    min-height: 0; /* Allow shrinking below content size */
    overflow: hidden; /* Prevent overflow of parent */
}

/* Message animations */
.message {
    animation: fadeInUp 0.3s ease-out;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Typing indicator animation */
.fa-circle-notch.fa-spin {
    animation: fa-spin 1s infinite linear;
}

@keyframes fa-spin {
    0% {
        transform: rotate(0deg);
    }
    100% {
        transform: rotate(359deg);
    }
}

/* Suggestion buttons hover effect */
.suggestion-btn {
    transition: all 0.2s ease;
}

.suggestion-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* Upload progress bar animation */
.progress-bar {
    transition: width 0.3s ease;
}

/* Table spacing improvements */
.message-content table {
    border-collapse: separate;
    border-spacing: 0;
    width: 100%;
    margin: 1rem 0;
}

.message-content table th,
.message-content table td {
    padding: 0.75rem 1rem;
    text-align: left;
    border-bottom: 1px solid #e5e7eb;
    vertical-align: top;
}

.message-content table th {
    background-color: #f9fafb;
    font-weight: 600;
    border-bottom: 2px solid #d1d5db;
}

.message-content table tr:hover {
    background-color: #f9fafb;
}

/* Citation links and source containers */
.sources-actions-container {
    margin: 0 !important;
    padding: 0 !important;
}

.source-tag,
.citation-link,
a[href="#"][class*="citation"] {
    font-size: 9px;
    min-width: 18px;
    height: 16px;
    padding: 1px 3px;
    margin: 1px;
    background-color: #f3f4f6;
    color: #374151;
    border: 1px solid #d1d5db;
    border-radius: 3px;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 500;
    line-height: 1;
    cursor: pointer;
    transition: all 0.2s ease;
}

.source-tag:hover,
.citation-link:hover,
a[href="#"][class*="citation"]:hover {
    background-color: #e5e7eb;
    color: #1f2937;
}

/* Drag and drop styling */
.border-dashed {
    transition: all 0.2s ease;
}

.border-dashed.border-blue-500 {
    border-color: #3b82f6;
    background-color: #eff6ff;
}

/* Button hover effects */
button {
    transition: all 0.2s ease;
}

button:hover {
    transform: translateY(-1px);
}

button:active {
    transform: translateY(0);
}

/* Modal animations */
.fixed.inset-0 {
    animation: fadeIn 0.2s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.bg-white.rounded-lg {
    animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: scale(0.9) translateY(-20px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

/* Sidebar animation */
#documentsSidebar {
    transition: all 0.3s ease;
}

/* Enhanced message content styling for readability */
.message-content {
    line-height: 1.7;
    font-size: 0.95rem;
    word-wrap: break-word;
}

.message-content p {
    margin-bottom: 0.75rem;
}

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

.message-content h1, .message-content h2, .message-content h3 {
    margin-top: 1rem;
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: #1f2937;
}

.message-content h1 {
    font-size: 1.15rem;
}

.message-content h2 {
    font-size: 1.1rem;
}

.message-content h3 {
    font-size: 1.05rem;
}

.message-content ul, .message-content ol {
    margin: 0.5rem 0;
    padding-left: 1.25rem;
}

.message-content li {
    margin-bottom: 0.3rem;
    line-height: 1.6;
}

.message-content strong {
    font-weight: 600;
    color: #1f2937;
}

.message-content em {
    font-style: italic;
    color: #4b5563;
}

.message-content pre {
    background: #f8f9fa;
    padding: 12px;
    border-radius: 6px;
    overflow-x: auto;
    margin: 8px 0;
    font-family: 'Courier New', monospace;
    border: 1px solid #e5e7eb;
}

.message-content code {
    background: #f3f4f6;
    padding: 0.15rem 0.3rem;
    border-radius: 0.25rem;
    font-family: 'SF Mono', 'Monaco', 'Inconsolata', 'Roboto Mono', monospace;
    font-size: 0.9em;
    font-weight: 500;
    color: #1f2937;
    border: 1px solid #e5e7eb;
}

.message-content blockquote {
    border-left: 3px solid #3b82f6;
    padding-left: 1rem;
    margin: 0.5rem 0;
    font-style: italic;
    color: #4b5563;
}

/* Loading states */
.loading {
    opacity: 0.6;
    pointer-events: none;
}

/* Focus styles */
textarea:focus,
input:focus,
button:focus {
    outline: none;
}

/* Mobile responsiveness - unified design */
@media (max-width: 768px) {
    /* Sidebar sizing for all mobile */
    #conversationHistorySidebar {
        display: flex !important;
        width: 200px !important;
        min-width: 200px !important;
        max-width: 200px !important;
        flex-shrink: 0;
        position: relative !important;
    }
    
    /* Main content area */
    .flex-1 {
        min-width: 0;
        flex: 1;
        width: auto !important;
        margin-left: 0 !important;
    }
    
    /* Chat area consistent spacing */
    .max-w-2xl {
        max-width: 100% !important;
        width: 100% !important;
        margin: 0 !important;
        padding: 0 8px !important;
    }
    
    .flex-1.flex.max-w-6xl {
        max-width: 100% !important;
        width: 100% !important;
        padding: 0 8px !important;
        margin: 0 !important;
    }
    
    /* Consistent font sizes for mobile */
    .text-xl {
        font-size: 16px !important;
    }
    
    .text-lg {
        font-size: 15px !important;
    }
    
    .text-base {
        font-size: 14px !important;
    }
    
    .text-sm {
        font-size: 13px !important;
    }
    
    /* Consistent padding across mobile */
    .px-4.py-3 {
        padding: 10px 8px !important;
    }
    
    .px-4.py-2 {
        padding: 8px 8px !important;
    }
    
    .p-6 {
        padding: 12px !important;
    }
    
    .p-4 {
        padding: 10px !important;
    }
    
    /* Conversation items consistent */
    .conversation-item {
        padding: 8px 10px !important;
        font-size: 14px !important;
    }
    
    .conversation-item .text-ellipsis {
        max-width: 140px !important;
    }
    
    /* Button text consistent */
    button {
        font-size: 14px !important;
    }
    
    /* Input text consistent */
    input, textarea {
        font-size: 14px !important;
    }
    
    /* Hide mobile menu button if it exists */
    .mobile-menu-btn {
        display: none !important;
    }
    
    /* Ensure sidebar uses mobile width properly */
    #conversationSidebar {
        width: 200px !important;
        min-width: 200px !important;
        max-width: 200px !important;
    }
}

/* Dark mode support (optional) */
@media (prefers-color-scheme: dark) {
    /* Add dark mode styles if needed */
}

/* Print styles */
@media print {
    .no-print {
        display: none;
    }
}

/* Accessibility improvements */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* High contrast mode */
@media (prefers-contrast: high) {
    .border {
        border-width: 2px;
    }
    
    .shadow-sm {
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
    }
}

/* Selection styling */
::selection {
    background-color: #3b82f6;
    color: white;
}

::-moz-selection {
    background-color: #3b82f6;
    color: white;
}

/* Profile image perfect circle styling */
.profile-image-circle {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    object-fit: cover;
    object-position: center;
    display: block;
}

.profile-image-circle-small {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    object-fit: cover;
    object-position: center;
    display: block;
}

.profile-image-circle-chat {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
    object-position: center;
    display: block;
}

/* Ensure image containers are also circular */
.profile-container {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: #f3f4f6;
    position: relative;
}

.profile-container img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 2;
}

.profile-container i {
    z-index: 1;
}

.profile-container-small {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: #f3f4f6;
    position: relative;
}

.profile-container-small img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 2;
}

.profile-container-small i {
    z-index: 1;
}

.profile-container-chat {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: #f3f4f6;
}

/* PDF Viewer styling */
#pdfViewer {
    transition: all 0.3s ease;
}

#pdfViewer iframe {
    border: 1px solid #e5e7eb;
    border-radius: 0.5rem;
}

/* PDF Canvas styling */
#pdfCanvas {
    transition: all 0.2s ease;
    max-width: 100%;
    height: auto;
}

#pdfContainer {
    min-height: 400px;
    background-color: #f8f9fa;
}

#pdfCanvas {
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    max-width: none !important;
    max-height: calc(90vh - 120px);
}

#pdfFrame {
    background-color: white !important;
}

/* PDF Control buttons */
#pdfViewer button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

#pdfViewer button:not(:disabled):hover {
    background-color: #f3f4f6;
    transform: none; /* Override global button hover transform */
}

/* PDF viewer scroll area */
#pdfViewer .overflow-auto {
    scrollbar-width: thin;
    scrollbar-color: #9ca3af #f3f4f6;
}

#pdfViewer .overflow-auto::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

#pdfViewer .overflow-auto::-webkit-scrollbar-track {
    background: #f3f4f6;
    border-radius: 4px;
}

#pdfViewer .overflow-auto::-webkit-scrollbar-thumb {
    background: #9ca3af;
    border-radius: 4px;
}

#pdfViewer .overflow-auto::-webkit-scrollbar-thumb:hover {
    background: #6b7280;
}

.pdf-link {
    transition: all 0.2s ease;
}

.pdf-link:hover {
    background-color: #eff6ff;
    padding: 0.125rem 0.25rem;
    border-radius: 0.25rem;
}

/* Source tag hover effects for PDFs */
.bg-blue-100.cursor-pointer:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(59, 130, 246, 0.15);
}

/* Conversation list item styling */
.group .opacity-0 {
    transition: opacity 0.2s ease;
}

.group:hover .opacity-0 {
    opacity: 1 !important;
}

/* Conversation action buttons */
.rename-btn:hover,
.delete-btn:hover {
    background-color: rgba(0, 0, 0, 0.05);
    transform: scale(1.1);
}

.delete-btn:hover {
    color: #dc2626 !important;
}

/* Context menu styling */
#conversation-context-menu {
    min-width: 140px;
    user-select: none;
    z-index: 1000;
}

#conversation-context-menu button {
    transition: all 0.15s ease;
}

#conversation-context-menu button:hover {
    transform: none;
}

/* Prevent text selection during right-click */
.conversation-main {
    user-select: none;
}

/* Custom utility classes */
.text-ellipsis {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.transition-fast {
    transition: all 0.15s ease;
}

.transition-slow {
    transition: all 0.5s ease;
}


/* ===== PRODUCTION UI POLISH ENHANCEMENTS ===== */

/* Enhanced loading container styling */
.loading-container {
    background: linear-gradient(135deg, rgba(106, 185, 201, 0.03), rgba(106, 185, 201, 0.08)) !important;
    border-radius: 16px !important;
    border: 1px solid rgba(106, 185, 201, 0.15) !important;
    backdrop-filter: blur(5px);
    position: relative;
    overflow: hidden;
}

.loading-container::before {
    content: "";
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
    animation: shimmerMove 2s infinite;
}

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

/* Enhanced message bubbles */
.message .bg-white {
    border-radius: 16px !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08) !important;
    border: 1px solid rgba(106, 185, 201, 0.1) !important;
    transition: all 0.2s ease !important;
}

.message:hover .bg-white {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12) !important;
    border-color: rgba(106, 185, 201, 0.2) !important;
    transform: translateY(-1px) !important;
}

/* Enhanced conversation list */
.group:hover {
    background: linear-gradient(135deg, rgba(106, 185, 201, 0.05), rgba(106, 185, 201, 0.02)) !important;
    transform: translateX(4px) !important;
    box-shadow: 0 2px 8px rgba(106, 185, 201, 0.15) !important;
    border-left: 3px solid #6ab9c9 !important;
}

/* Enhanced loading timer */
.loading-timer {
    background: rgba(255, 255, 255, 0.95) !important;
    padding: 0.5rem 1rem !important;
    border-radius: 12px !important;
    border: 1px solid rgba(106, 185, 201, 0.2) !important;
    font-weight: 600 !important;
    color: #6ab9c9 !important;
    box-shadow: 0 2px 4px rgba(106, 185, 201, 0.1) !important;
}

/* Enhanced source tags */
.source-tag:hover {
    transform: translateY(-2px) scale(1.02) !important;
    box-shadow: 0 4px 8px rgba(106, 185, 201, 0.2) !important;
}

/* Enhanced input focus states */
input:focus, textarea:focus, select:focus {
    box-shadow: 0 0 0 3px rgba(106, 185, 201, 0.1) !important;
    border-color: #6ab9c9 !important;
}

/* Heart animation for pilot modal */
.animated-heart {
    animation: heartBeat 1.5s infinite;
}

@keyframes heartBeat {
    0% {
        transform: scale(1);
    }
    20% {
        transform: scale(1.3);
    }
    40% {
        transform: scale(1);
    }
    60% {
        transform: scale(1.3);
    }
    80% {
        transform: scale(1);
    }
    100% {
        transform: scale(1);
    }
}

/* Professional button enhancements */
button:hover {
    transform: translateY(-1px) !important;
}

button:active {
    transform: translateY(0) scale(0.98) !important;
}

/* Streaming cursor animation */
.streaming-cursor {
    font-weight: bold;
    animation: blink 1s infinite;
    color: #3b82f6;
    font-size: 1.2em;
}

@keyframes blink {
    0%, 50% { opacity: 1; }
    51%, 100% { opacity: 0; }
}

/* Typewriter streaming animation */
.typewriter-text {
    white-space: pre-wrap;
    overflow: hidden;
    border-right: 2px solid #3b82f6;
    animation: typing 0.5s linear;
}

@keyframes typing {
    from { width: 0; }
    to { width: 100%; }
}

