/* ===== LOANSPACE.AI - FINAL POLISH TO 9/10 ===== */
/* Chat-first layout + professional refinements */
/* Load this LAST, after all other CSS files */

/* ============================================
   CHAT-FIRST LAYOUT - HERO ELEMENT
   ============================================ */

/* Main container - prioritize chat */
.main-container {
    display: flex !important;
    flex-direction: column !important;
    max-width: 1200px !important;
    margin: 0 auto !important;
    padding: 24px !important;
}

/* Welcome banner - more prominent now that chat is hidden */
.welcome-banner {
    background: #ffffff !important;
    border: 1px solid #e2e8f0 !important;
    border-radius: 16px !important;
    padding: 48px 32px !important;
    margin-bottom: 32px !important;
    box-shadow: 0 2px 8px 0 rgb(0 0 0 / 0.05) !important;
}

/* Hide welcome banner after first message - must use !important to override tablet rules */
.welcome-banner.hidden {
    display: none !important;
    visibility: hidden !important;
    height: 0 !important;
    overflow: hidden !important;
    opacity: 0 !important;
}

/* Hero text - more compact */
.welcome-hero {
    max-width: 100% !important;
    margin: 0 auto 24px !important;
    text-align: center !important;
}

/* Headline - stronger, bolder */
.welcome-title,
h1 {
    font-size: 36px !important;
    font-weight: 800 !important;
    color: #0f172a !important;
    letter-spacing: -0.03em !important;
    line-height: 1.1 !important;
    margin-bottom: 12px !important;
}

/* Subtitle - darker, more readable */
.welcome-subtitle {
    font-size: 17px !important;
    font-weight: 500 !important;
    color: #334155 !important;
    line-height: 1.5 !important;
}

/* Features grid - more compact */
.features-grid {
    display: grid !important;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)) !important;
    gap: 16px !important;
    margin: 0 !important;
}

/* Feature cards - refined and interactive */
.feature-card-modern,
.feature-card {
    background: #ffffff !important;
    border: 1px solid #e2e8f0 !important;
    border-radius: 12px !important;
    padding: 20px !important;
    box-shadow: 0 1px 2px 0 rgb(0 0 0 / 0.05) !important;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1) !important;
    cursor: pointer !important;
}

.feature-card-modern:hover,
.feature-card:hover {
    border-color: #2563eb !important;
    box-shadow: 0 4px 12px 0 rgb(37 99 235 / 0.15) !important;
    transform: translateY(-2px) !important;
}

/* Icons - larger, more presence */
.feature-icon-wrapper {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    margin-bottom: 16px !important;
}

.feature-icon {
    width: 56px !important;
    height: 56px !important;
    background: linear-gradient(135deg, #eff6ff 0%, #dbeafe 100%) !important;
    border-radius: 12px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    box-shadow: 0 2px 8px 0 rgb(37 99 235 / 0.1) !important;
}

.feature-icon i {
    font-size: 28px !important;
    color: #2563eb !important;
}

/* Feature text - clear hierarchy */
.feature-title {
    font-size: 16px !important;
    font-weight: 700 !important;
    color: #0f172a !important;
    margin-bottom: 6px !important;
    text-align: center !important;
}

.feature-description {
    font-size: 14px !important;
    color: #64748b !important;
    line-height: 1.4 !important;
    text-align: center !important;
}

/* Remove emoji arrow from CTA */
.welcome-cta,
.cta-text {
    display: none !important;
}

/* ============================================
   CHAT BOX - CLEAN & EFFICIENT
   ============================================ */

/* Chat container - blends into background, no box */
#chatbox,
.chat-container,
.chat-area {
    background: transparent !important;
    border: none !important;
    border-radius: 0 !important;
    min-height: 0 !important;
    padding: 24px 0 !important;
    box-shadow: none !important;
    margin-top: 24px !important;
    display: flex !important;
    flex-direction: column !important;
    gap: 16px !important;
}

/* Hide empty chatbox completely */
#chatbox:empty {
    display: none !important;
}

/* Main content area - no box, just background */
.main-content,
.chat-wrapper {
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
}

/* Chat messages - clean and minimal, no boxes */
.message {
    margin-bottom: 24px !important;
    animation: fadeIn 0.3s ease !important;
}

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

/* Force remove all boxes, backgrounds, borders from messages */
.message-content,
.message .message-content,
.message.user .message-content,
.message.assistant .message-content {
    background: transparent !important;
    background-color: transparent !important;
    border: none !important;
    box-shadow: none !important;
    border-radius: 0 !important;
    padding: 0 !important;
    font-size: 16px !important;
    line-height: 1.7 !important;
    max-width: 100% !important;
}

/* User messages - dark text, visible - ULTRA NUCLEAR OVERRIDE */
.message.user,
.message.human {
    display: flex !important;
    justify-content: flex-start !important;
}

.message.user .message-content,
.message.human .message-content {
    color: #0f172a !important;
    font-weight: 500 !important;
    background: transparent !important;
}

/* Force all nested elements in user messages to be dark - beat base CSS */
.message.user .message-content *,
.message.user .message-content,
.message.user .message-content p,
.message.user .message-content div,
.message.user .message-content span,
.message.user .message-content strong,
.message.user .message-content em,
.message.human .message-content *,
.message.human .message-content,
.message.human .message-content p,
.message.human .message-content div,
.message.human .message-content span,
.message.human .message-content strong,
.message.human .message-content em,
.message.human .message-content a {
    color: #0f172a !important;
    background: transparent !important;
}

/* In case there's an inline style setting it to white */
.message.user[style],
.message.user .message-content[style],
.message.user .message-content *[style],
.message.human[style],
.message.human .message-content[style],
.message.human .message-content *[style] {
    color: #0f172a !important;
}

/* Assistant messages - no label needed, you already have username */
.message.assistant {
    display: flex !important;
    justify-content: flex-start !important;
}

.message.assistant .message-content {
    color: #334155 !important;
    font-weight: 400 !important;
}

.message.assistant .message-content * {
    color: #334155 !important;
}

/* Remove any nested elements that might have boxes */
.message-content p,
.message-content div,
.message-content span {
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    color: inherit !important;
}

/* ============================================
   INPUT AREA - PROMINENT & INVITING
   ============================================ */

.input-area {
    background: #ffffff !important;
    border-top: 2px solid #e2e8f0 !important;
    padding: 24px !important;
    box-shadow: 0 -4px 12px 0 rgb(0 0 0 / 0.05) !important;
}

/* Input wrapper */
.input-wrapper {
    display: flex !important;
    gap: 12px !important;
    align-items: center !important;
    max-width: 1000px !important;
    margin: 0 auto !important;
}

/* Text input - larger and more prominent */
#userInput {
    flex: 1 !important;
    background: #f8fafc !important;
    border: 2px solid #cbd5e1 !important;
    border-radius: 14px !important;
    padding: 16px 20px !important;
    font-size: 16px !important;
    color: #0f172a !important;
    transition: all 0.2s ease !important;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif !important;
}

#userInput:focus {
    outline: none !important;
    border-color: #2563eb !important;
    background: #ffffff !important;
    box-shadow: 0 0 0 4px rgb(37 99 235 / 0.1) !important;
}

#userInput::placeholder {
    color: #94a3b8 !important;
    font-weight: 400 !important;
}

/* Send button - modern pill with gradient */
#sendButton {
    background: linear-gradient(135deg, #2563eb, #1d4ed8) !important;
    color: white !important;
    border: none !important;
    border-radius: 50px !important;
    padding: 14px 26px !important;
    font-size: 15px !important;
    font-weight: 600 !important;
    cursor: pointer !important;
    transition: all 0.2s ease !important;
    box-shadow: 0 4px 14px rgba(37, 99, 235, 0.35) !important;
    white-space: nowrap !important;
    display: flex !important;
    align-items: center !important;
    gap: 8px !important;
    letter-spacing: 0.2px !important;
}

#sendButton span {
    display: inline !important;
    font-size: 15px !important;
    font-weight: 600 !important;
}

#sendButton:hover:not(:disabled) {
    background: linear-gradient(135deg, #1d4ed8, #1e40af) !important;
    transform: translateY(-2px) !important;
    box-shadow: 0 6px 20px rgba(37, 99, 235, 0.45) !important;
}

#sendButton:active:not(:disabled) {
    transform: translateY(0) !important;
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.3) !important;
}

#sendButton:disabled {
    opacity: 0.5 !important;
    cursor: not-allowed !important;
    transform: none !important;
}

/* Secondary buttons (upload, voice, dark mode toggle) - modern pill style */
.upload-button,
#speechButton,
#darkModeToggle {
    background: #f0f4ff !important;
    border: 1.5px solid #c7d7fd !important;
    border-radius: 50px !important;
    padding: 14px 18px !important;
    cursor: pointer !important;
    transition: all 0.2s ease !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    /* Override fixed positioning from base styles */
    position: static !important;
    top: auto !important;
    right: auto !important;
    width: auto !important;
    height: auto !important;
    box-shadow: none !important;
    z-index: auto !important;
    font-size: 16px !important;
    color: #3b82f6 !important;
}

.upload-button:hover,
#speechButton:hover,
#darkModeToggle:hover {
    background: #dbeafe !important;
    border-color: #93c5fd !important;
    transform: translateY(-2px) !important;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.15) !important;
}

.upload-button.has-document {
    background: #dbeafe !important;
    border-color: #3b82f6 !important;
}

/* Mic button - active/recording state */
#speechButton.recording {
    background: #fef2f2 !important;
    border-color: #fca5a5 !important;
    color: #ef4444 !important;
}

#speechButton.recording:hover {
    background: #fee2e2 !important;
    border-color: #f87171 !important;
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.2) !important;
}

/* ============================================
   SIDEBAR - REFINED
   ============================================ */

.sidebar {
    background: #ffffff !important;
    border-right: 1px solid #e2e8f0 !important;
}

/* Rate widget - cleaner */
.rate-widget {
    background: #f8fafc !important;
    border: 1px solid #e2e8f0 !important;
    border-radius: 12px !important;
    padding: 16px !important;
    margin: 12px !important;
}

.rate-widget-header {
    font-size: 12px !important;
    font-weight: 700 !important;
    text-transform: uppercase !important;
    letter-spacing: 0.08em !important;
    color: #64748b !important;
    margin-bottom: 12px !important;
}

.rate-row {
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
    padding: 8px 0 !important;
}

.rate-label {
    font-size: 14px !important;
    font-weight: 500 !important;
    color: #475569 !important;
}

.rate-value {
    font-size: 18px !important;
    font-weight: 800 !important;
    color: #0f172a !important;
}

/* Sidebar items - refined */
.sidebar-item,
.sidebar-item-link {
    padding: 12px 16px !important;
    border-radius: 10px !important;
    font-size: 15px !important;
    font-weight: 600 !important;
    color: #475569 !important;
    transition: all 0.15s ease !important;
    text-decoration: none !important;
}

.sidebar-item:hover:not(.active),
.sidebar-item-link:hover {
    background: #f1f5f9 !important;
    color: #0f172a !important;
}

.sidebar-item.active {
    background: #2563eb !important;
    color: white !important;
    box-shadow: 0 2px 8px 0 rgb(37 99 235 / 0.25) !important;
}

/* ============================================
   HEADER - REFINED
   ============================================ */

header {
    background: #ffffff !important;
    border-bottom: 1px solid #e2e8f0 !important;
    padding: 16px 24px !important;
    box-shadow: 0 1px 3px 0 rgb(0 0 0 / 0.05) !important;
}

header img.logo {
    height: 60px !important;
    filter: drop-shadow(0 2px 4px rgb(0 0 0 / 0.05)) !important;
}

/* ============================================
   LOADING STATES - REFINED
   ============================================ */

.thinking,
.loading {
    background: #f8fafc !important;
    border: 1px solid #e2e8f0 !important;
    border-radius: 12px !important;
    padding: 14px 18px !important;
    color: #64748b !important;
    display: flex !important;
    align-items: center !important;
    gap: 12px !important;
}

.spinner {
    border: 3px solid #e2e8f0 !important;
    border-top-color: #2563eb !important;
    width: 20px !important;
    height: 20px !important;
    border-radius: 50% !important;
    animation: spinAnimation 0.8s linear infinite !important;
}

@keyframes spinAnimation {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* ============================================
   MOBILE + TABLET OPTIMIZATIONS (No Sidebar)
   ============================================ */

@media (max-width: 1024px) {
    /* Force full width - override everything */
    body {
        padding: 0 !important;
        margin: 0 !important;
    }
    
    /* Hide sidebar by default on mobile and tablet */
    .sidebar {
        display: flex !important;
        transform: translateX(-100%) !important;
        transition: transform 0.3s ease !important;
    }
    
    /* Show sidebar when opened via hamburger */
    .sidebar.open {
        transform: translateX(0) !important;
    }
    
    /* Tighten up sidebar spacing on mobile/tablet */
    .sidebar {
        width: 240px !important;
    }
    
    .sidebar-section {
        padding: 8px 8px 16px 8px !important;
    }
    
    .sidebar-section-title {
        font-size: 10px !important;
        padding: 6px 10px !important;
    }
    
    .sidebar-item,
    .sidebar-item-link {
        padding: 8px 10px !important;
        font-size: 13px !important;
        gap: 10px !important;
        margin-bottom: 2px !important;
    }
    
    .sidebar-icon {
        width: 18px !important;
        height: 18px !important;
        font-size: 16px !important;
    }
    
    .sidebar-footer {
        padding: 12px 8px !important;
    }
    
    .user-profile {
        padding: 8px 10px !important;
    }
    
    .user-avatar {
        width: 28px !important;
        height: 28px !important;
        font-size: 12px !important;
    }
    
    .user-name {
        font-size: 13px !important;
    }
    
    .user-status {
        font-size: 11px !important;
    }
    
    .rate-widget {
        margin: 8px 8px 0 8px !important;
        padding: 10px 12px !important;
    }
    
    .rate-widget-header {
        font-size: 10px !important;
        margin-bottom: 8px !important;
    }
    
    .rate-row {
        padding: 4px 0 !important;
    }
    
    .rate-label {
        font-size: 12px !important;
    }
    
    .rate-value {
        font-size: 14px !important;
    }
    
    .rate-widget-footer {
        font-size: 9px !important;
        margin-top: 8px !important;
        padding-top: 6px !important;
    }
    
    .chat-history-container {
        padding: 0 8px !important;
    }
    
    .chat-history-container li {
        padding: 10px 12px !important;
        font-size: 12px !important;
        margin-bottom: 4px !important;
    }
    
    /* Login/Register links - prevent from sticking to bottom */
    .sidebar-footer {
        margin-top: 20px !important; /* Override margin-top: auto */
        position: relative !important;
        padding: 12px 8px !important;
    }
    
    /* User profile - if exists, add spacing */
    .user-profile {
        margin-bottom: 12px !important;
        padding: 8px 10px !important;
    }
    
    /* Remove flex auto spacing on sidebar to prevent bottom sticking */
    .sidebar {
        justify-content: flex-start !important;
    }
    
    /* Show mobile header with hamburger on mobile and tablet */
    .mobile-header {
        display: flex !important;
    }
    
    /* Show sidebar overlay on mobile and tablet */
    .sidebar-overlay {
        display: block !important;
    }
    
    /* Main container - full width (no sidebar offset) */
    .main-container,
    .main-content {
        padding: 0 !important;
        margin-left: 0 !important;
        margin-right: 0 !important;
        width: 100% !important;
        max-width: 100% !important;
    }
    
    .chat-container {
        padding: 0 16px !important;
        margin: 12px auto !important;
        max-width: 100% !important;
        width: 100% !important;
        box-sizing: border-box !important;
    }
    
    /* Welcome banner - comfortable padding */
    .welcome-banner {
        padding: 16px !important;
        margin: 0 16px 12px 16px !important;
        border-radius: 12px !important;
        max-width: calc(100% - 32px) !important;
        width: calc(100% - 32px) !important;
        box-sizing: border-box !important;
    }
    
    .welcome-hero {
        margin-bottom: 0 !important;
        padding: 0 !important;
    }
    
    .welcome-title,
    h1 {
        font-size: 24px !important;
        margin-bottom: 8px !important;
        padding: 0 !important;
    }
    
    .welcome-subtitle {
        font-size: 15px !important;
        margin-bottom: 0 !important;
        padding: 0 !important;
    }
    
    /* FORCE HIDE feature cards - multiple selectors */
    .features-grid,
    .feature-cards,
    .feature-card-modern,
    .feature-card {
        display: none !important;
        visibility: hidden !important;
        height: 0 !important;
        overflow: hidden !important;
        opacity: 0 !important;
    }
    
    /* Hide the "Ask me anything" CTA text */
    .welcome-cta,
    .cta-text {
        display: none !important;
        visibility: hidden !important;
    }
    
    /* Chat area - comfortable padding */
    #chatbox,
    .chat-area {
        padding: 12px 0 !important;
        width: 100% !important;
        max-width: 100% !important;
    }
    
    /* Input area - comfortable side padding */
    .input-area {
        padding: 12px 16px !important;
        width: 100% !important;
        max-width: 100% !important;
        box-sizing: border-box !important;
    }
    
    .input-wrapper {
        gap: 8px !important;
        max-width: 100% !important;
        width: 100% !important;
    }
    
    #userInput {
        font-size: 16px !important;
        padding: 14px 16px !important;
        width: 100% !important;
        box-sizing: border-box !important;
    }
    
    #sendButton {
        padding: 14px 20px !important;
        font-size: 15px !important;
    }
    
    /* Secondary buttons */
    .upload-button,
    #speechButton {
        padding: 14px !important;
    }
    
    /* Mobile header - comfortable padding */
    .mobile-header {
        padding: 12px 16px !important;
        width: 100% !important;
        max-width: 100% !important;
        box-sizing: border-box !important;
    }
    
    /* Rate widget in header */
    .mobile-rates {
        font-size: 10px !important;
    }
    
    /* Messages - comfortable margins */
    .message {
        max-width: 95% !important;
    }
    
    .message-content {
        padding: 14px 16px !important;
    }
}

/* Tablet specific (769px-1024px) - slightly larger text */
@media (min-width: 769px) and (max-width: 1024px) {
    .welcome-title,
    h1 {
        font-size: 28px !important;
    }
    
    .welcome-subtitle {
        font-size: 17px !important;
    }
    
    .chat-container {
        max-width: 700px !important;
        padding: 0 24px !important;
    }
    
    .welcome-banner {
        padding: 20px !important;
        margin: 0 24px 16px 24px !important;
        max-width: calc(100% - 48px) !important;
    }
    
    .input-area {
        padding: 16px 24px !important;
    }
}

/* Small mobile - still comfortable padding */
@media (max-width: 375px) {
    .welcome-title,
    h1 {
        font-size: 22px !important;
    }
    
    .welcome-subtitle {
        font-size: 14px !important;
    }
    
    .chat-container {
        padding: 0 14px !important;
    }
    
    .welcome-banner {
        margin: 0 14px 12px 14px !important;
        padding: 14px !important;
        max-width: calc(100% - 28px) !important;
        width: calc(100% - 28px) !important;
    }
    
    .input-area {
        padding: 12px 14px !important;
    }
    
    .mobile-header {
        padding: 12px 14px !important;
    }
}

/* ============================================
   ACCESSIBILITY - FOCUS STATES
   ============================================ */

button:focus-visible,
input:focus-visible,
a:focus-visible,
.sidebar-item:focus-visible {
    outline: 2px solid #2563eb !important;
    outline-offset: 2px !important;
}

/* ============================================
   SCROLLBAR - REFINED
   ============================================ */

#chatbox::-webkit-scrollbar {
    width: 8px !important;
}

#chatbox::-webkit-scrollbar-track {
    background: #f8fafc !important;
    border-radius: 10px !important;
}

#chatbox::-webkit-scrollbar-thumb {
    background: #cbd5e1 !important;
    border-radius: 10px !important;
}

#chatbox::-webkit-scrollbar-thumb:hover {
    background: #94a3b8 !important;
}

/* ============================================
   POWERED BY - SUBTLE
   ============================================ */

.powered-by {
    display: none !important;
}

/* Or if you want to keep it but make it better: */
/*
.powered-by {
    font-size: 13px !important;
    font-weight: 500 !important;
    color: #94a3b8 !important;
    text-align: center !important;
    padding: 12px !important;
}
*/

/* ============================================
   FINAL TOUCHES
   ============================================ */

/* Remove any remaining visual clutter */
.hero-badge,
.ai-badge,
[class*="powered-badge"] {
    display: none !important;
}

/* Ensure consistent spacing */
* {
    margin: 0;
    padding: 0;
}

/* Smooth scrolling */
html {
    scroll-behavior: smooth;
}

/* Better text rendering */
body {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

/* ============================================
   END - 9/10 DESIGN
   ============================================ */

/*
 * CHANGES MADE FOR 9/10:
 * 
 * 1. Chat is now the hero - prominent, inviting, front-and-center
 * 2. Stronger typography - bolder headlines, better contrast
 * 3. Larger icons with better styling
 * 4. Improved hover states - clear feedback
 * 5. Removed emoji arrow from CTA
 * 6. Better input area - more prominent, inviting
 * 7. Refined cards - better shadows, smoother interactions
 * 8. Cleaner sidebar - refined spacing and colors
 * 9. Professional throughout - no gimmicks, just clarity
 * 10. Optimized for conversion - chat is the focus
 */
