/* ===== LOANSPACE.AI - PROFESSIONAL NAVY + BLUE FINANCE THEME ===== */
/* Modern fintech-inspired design with trust and professionalism */

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    /* Primary Brand Colors - Navy + Blue */
    --primary-navy: #1e3a5f;
    --primary-navy-light: #2d4a6f;
    --primary-navy-dark: #152a47;
    --accent-blue: #2b7cc4;
    --accent-blue-light: #4A9FE8;
    --accent-blue-dark: #1e5a8a;
    
    /* Legacy aliases for compatibility */
    --primary-blue: #1e3a5f;
    --secondary-blue: #2d4a6f;
    --brand-orange: #f39c12;
    --brand-orange-dark: #e67e22;
    
    /* Background Colors - Clean & Professional */
    --bg-main: #f8fafc;
    --bg-sidebar: #ffffff;
    --bg-card: #ffffff;
    --bg-hover: #f1f5f9;
    --bg-light: #ffffff;
    --border-color: #e2e8f0;
    --border-light: #f1f5f9;
    
    /* Sidebar Colors - Light Professional Theme */
    --sidebar-dark: #f8fafc;
    --sidebar-mid: #ffffff;
    --sidebar-light: #ffffff;
    
    /* Text Colors - Slate palette */
    --text-primary: #1e293b;
    --text-secondary: #475569;
    --text-muted: #94a3b8;
    --text-light: #cbd5e1;
    --text-on-dark: #f1f5f9;
    
    /* Soft Accent Colors */
    --soft-blue: #e8f4fc;
    --soft-blue-dark: #d1e9f9;
    --soft-navy: #f0f4f8;
    --soft-navy-dark: #e2e8f0;
    
    /* Neutrals */
    --dark: #0f172a;
    --white: #FFFFFF;
    
    /* Gradients */
    --gradient-primary: linear-gradient(135deg, #1e3a5f 0%, #2d4a6f 100%);
    --gradient-blue: linear-gradient(135deg, #2b7cc4 0%, #1e5a8a 100%);
    --gradient-soft-blue: linear-gradient(135deg, #e8f4fc 0%, #d1e9f9 100%);
    --gradient-soft-navy: linear-gradient(135deg, #f0f4f8 0%, #e2e8f0 100%);
    --gradient-hero: linear-gradient(160deg, #f8fafc 0%, #f1f5f9 50%, #ffffff 100%);
    --gradient-sidebar: linear-gradient(180deg, var(--sidebar-dark) 0%, var(--sidebar-mid) 50%, var(--sidebar-light) 100%);
    
    /* Shadows */
    --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(15, 23, 42, 0.07), 0 2px 4px -1px rgba(15, 23, 42, 0.04);
    --shadow-lg: 0 10px 15px -3px rgba(15, 23, 42, 0.08), 0 4px 6px -2px rgba(15, 23, 42, 0.04);
    --shadow-xl: 0 20px 25px -5px rgba(15, 23, 42, 0.08), 0 10px 10px -5px rgba(15, 23, 42, 0.03);
    --shadow-glow-blue: 0 4px 20px rgba(43, 124, 196, 0.25);
    --shadow-glow-navy: 0 4px 20px rgba(30, 58, 95, 0.25);
}

/* ===== iOS SAFE AREA SUPPORT ===== */
.mobile-header {
    padding-top: max(12px, env(safe-area-inset-top));
    padding-left: max(16px, env(safe-area-inset-left));
    padding-right: max(16px, env(safe-area-inset-right));
}

.sidebar {
    padding-top: env(safe-area-inset-top);
}

.input-area {
    padding-bottom: max(20px, env(safe-area-inset-bottom));
}

/* ===== BRAND COLORS ===== */
.logo-loan {
    color: #2558B2;  /* Blue */
}

.logo-space {
    color: #D66D2B;  /* Orange */
}

/* ===== BASE STYLES ===== */
body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-main);
    min-height: 100vh;
    display: flex;
    color: var(--text-primary);
    position: relative;
    overflow-x: hidden;
}

/* Subtle background pattern */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    padding-top: env(safe-area-inset-top);
    background:
        radial-gradient(ellipse at 20% 20%, rgba(43, 124, 196, 0.03) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 80%, rgba(30, 58, 95, 0.02) 0%, transparent 50%);
    pointer-events: none;
    z-index: 0;
}

/* ===== SIDEBAR - LIGHT PROFESSIONAL THEME ===== */
.sidebar {
    position: fixed;
    left: 0;
    top: 0;
    height: 100vh;
    width: 250px;
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    transition: transform 0.3s ease;
    z-index: 1000;
    overflow-y: auto;
    overflow-x: hidden;
}

/* Sidebar Header */
.sidebar-header {
    padding: 0;
    flex-shrink: 0;
}

.logo-container {
    display: flex;
    align-items: center;
    justify-content: center;
}

.sidebar-logo {
    width: 100%;
    height: auto;
    object-fit: contain;
    display: block;
    /* Invert logo for dark sidebar if needed */
    /* filter: brightness(0) invert(1); */
}

.logo-text {
    font-size: 18px;
    font-weight: 700;
    display: flex;
    align-items: center;
    color: var(--white);
}

/* Sidebar Sections */
.sidebar-section {
    padding: 6px 10px 6px 10px;
    flex-shrink: 0;
}

.sidebar-section:last-of-type {
    border-bottom: none;
}

.sidebar-section-title {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    padding: 4px 10px;
    font-weight: 600;
}

/* Sidebar Items */
.sidebar-item,
.sidebar-item-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 10px;
    border-radius: 8px;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s ease;
    width: 100%;
    text-align: left;
    margin-bottom: 1px;
    font-size: 13px;
    font-weight: 500;
    text-decoration: none;
}

.sidebar-item:hover,
.sidebar-item-link:hover {
    background: var(--soft-blue);
    color: var(--text-primary);
    transform: translateX(4px);
}

.sidebar-item.active {
    background: var(--gradient-blue);
    color: var(--white);
    box-shadow: var(--shadow-glow-blue);
}

.sidebar-item.active .sidebar-icon {
    filter: brightness(0) invert(1);
}

.sidebar-icon {
    width: 18px;
    height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    flex-shrink: 0;
    opacity: 0.7;
}

.sidebar-text {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sidebar-badge {
    background: var(--accent-blue);
    color: var(--white);
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 12px;
    font-weight: 600;
    min-width: 20px;
    text-align: center;
    display: none;
}

.sidebar-item.active .sidebar-badge {
    background: rgba(255, 255, 255, 0.3);
}

/* Chat History in Sidebar */
.chat-history-container {
    padding: 0 10px;
    max-height: 400px;
    overflow-y: auto;
}

.chat-history-container ul {
    list-style: none;
    padding: 0;
}

.chat-history-container li {
    padding: 8px 10px;
    font-size: 12px;
    color: var(--text-secondary);
    cursor: pointer;
    border-radius: 8px;
    margin-bottom: 4px;
    transition: all 0.2s ease;
    background: var(--bg-hover);
    border: 1px solid var(--border-color);
}

.chat-history-container li:hover {
    background: var(--soft-blue);
    border-color: var(--accent-blue);
    transform: translateX(4px);
    color: var(--text-primary);
}

.chat-history-container li.selected {
    background: var(--gradient-blue);
    color: var(--white);
    font-weight: 600;
    box-shadow: var(--shadow-glow-blue);
}

.chat-history-container li.empty-state {
    cursor: default;
    background: transparent;
    border: 2px dashed var(--border-color);
    color: var(--text-muted);
}

.chat-history-container li.empty-state:hover {
    transform: none;
    background: transparent;
}

/* Sidebar Footer */
.sidebar-footer {
    margin-top: auto;
    padding: 8px 10px;
    flex-shrink: 0;
    border-top: 1px solid var(--border-color);
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 10px;
    border-radius: 8px;
    background: var(--bg-hover);
    margin-top: 4px;
}

.user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--gradient-blue);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--white);
    font-weight: 700;
    font-size: 14px;
    flex-shrink: 0;
}

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

.user-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.user-status {
    font-size: 12px;
    color: var(--text-muted);
}

.logout-btn {
    background: none;
    border: none;
    padding: 8px;
    cursor: pointer;
    border-radius: 6px;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
}

.logout-btn:hover {
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
}

/* ===== MOBILE HEADER (hidden on desktop) ===== */
.mobile-header {
    display: none;
    align-items: center;
    gap: 16px;
    padding: 12px 16px;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 100;
}

.mobile-menu-btn {
    display: flex;
    flex-direction: column;
    justify-content: space-around;
    width: 28px;
    height: 22px;
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 2px;
}

.mobile-menu-btn span {
    width: 100%;
    height: 2px;
    background: var(--text-primary);
    border-radius: 2px;
    transition: all 0.3s ease;
}

/* Mobile Dark Mode Toggle (moon icon in mobile header) */
.sidebar-mobile-dark-toggle {
    display: none;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    font-size: 18px;
    color: var(--text-secondary, #64748b);
    cursor: pointer;
    padding: 8px;
    border-radius: 8px;
    transition: color 0.3s ease, background 0.3s ease;
    margin-right: 4px;
    order: -1;
}

.sidebar-mobile-dark-toggle:hover {
    background: var(--bg-hover, #f1f5f9);
}

[data-theme="dark"] .sidebar-mobile-dark-toggle {
    color: #fbbf24;
}

[data-theme="dark"] .sidebar-mobile-dark-toggle:hover {
    background: rgba(251, 191, 36, 0.1);
}

@media (max-width: 768px) {
    .sidebar-mobile-dark-toggle {
        display: flex;
    }
}

.mobile-logo {
    flex: 1;
    display: flex;
    align-items: center;
}

.mobile-logo-img {
    height: 32px;
    width: auto;
    object-fit: contain;
    /* Invert for dark background if needed */
    /* filter: brightness(0) invert(1); */
}

/* Sidebar Overlay (for mobile) */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.5);
    z-index: 999;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.sidebar-overlay.active {
    opacity: 1;
    visibility: visible;
}

/* ===== MAIN CONTENT ===== */
.main-content {
    margin-left: 250px;
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    width: calc(100% - 250px);
    transition: margin-left 0.3s ease;
    position: relative;
    z-index: 1;
    background: var(--bg-main);
}

/* ===== CHAT CONTAINER ===== */
.chat-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    max-width: 900px;
    width: 100%;
    margin: 16px auto;
    padding: 0 20px;
    background: transparent;
}

#chatbox {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 20px;
    padding: 20px 0;
    background: transparent;
}

/* ===== MESSAGES - CHAT BUBBLE LAYOUT ===== */
.message {
    display: flex;
    flex-direction: column;
    max-width: 80%;
    gap: 6px;
    animation: messageSlide 0.4s ease;
}

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

.message strong:first-child {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    padding: 4px 0;
    display: inline-block;
    width: fit-content;
}

/* User Messages - Right Aligned */
.message.human {
    align-self: flex-end;
    align-items: flex-end;
}

.message.human strong:first-child {
    background: transparent;
    color: var(--primary-navy);
    text-align: right;
}

.message.human .message-content {
    background: var(--gradient-primary);
    color: var(--white) !important;
    border: none;
    border-radius: 20px 20px 6px 20px;
    box-shadow: var(--shadow-glow-navy);
}

.message.human .message-content p,
.message.human .message-content strong,
.message.human .message-content a {
    color: var(--white);
}

.message.human .message-content a {
    text-decoration: underline;
}

.message.human .message-content a::after {
    display: none;
}

/* AI Messages - Left Aligned */
.message.assistant {
    align-self: flex-start;
    align-items: flex-start;
}

.message.assistant strong:first-child {
    background: transparent !important;
    color: var(--text-secondary) !important;
}

.message.assistant .message-content {
    background: var(--bg-card);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-md);
    border-radius: 20px 20px 20px 6px;
}

.message-content {
    padding: 18px 22px;
    line-height: 1.7;
    font-size: 15px;
    word-break: break-word;
}

/* Message Content Typography */
.message-content p {
    margin: 10px 0;
    font-size: 15px;
    color: var(--text-primary);
}

.message.human .message-content p {
    color: var(--white);
}

.message-content p:first-child {
    margin-top: 0;
}

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

/* Lists */
.message-content ul,
.message-content ol {
    list-style: none;
    margin: 14px 0;
    padding: 0;
}

.message-content ol {
    counter-reset: item;
}

.message-content ul li,
.message-content ol li {
    padding: 14px 18px 14px 48px;
    position: relative;
    margin-bottom: 10px;
    line-height: 1.6;
    font-size: 15px;
    background: var(--soft-blue);
    border-radius: 12px;
    border-left: 3px solid var(--accent-blue);
    transition: all 0.25s ease;
}

.message-content ul li:hover,
.message-content ol li:hover {
    background: var(--soft-blue-dark);
    transform: translateX(4px);
    box-shadow: var(--shadow-sm);
}

.message-content ol li {
    counter-increment: item;
}

.message-content ol li::before {
    content: counter(item);
    position: absolute;
    left: 14px;
    top: 14px;
    background: var(--gradient-blue);
    color: white;
    font-weight: 700;
    font-size: 11px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 6px rgba(43, 124, 196, 0.3);
}

.message-content ul li::before {
    content: '';
    position: absolute;
    left: 18px;
    top: 20px;
    width: 10px;
    height: 10px;
    background: var(--gradient-blue);
    border-radius: 50%;
    box-shadow: 0 2px 6px rgba(43, 124, 196, 0.3);
}

/* Links */
.message-content a {
    color: var(--accent-blue);
    text-decoration: none;
    font-weight: 600;
    position: relative;
    transition: color 0.25s ease;
    padding-bottom: 2px;
}

.message-content a::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 0;
    height: 2px;
    background: var(--gradient-blue);
    transition: width 0.3s ease;
    border-radius: 2px;
}

.message-content a:hover {
    color: var(--accent-blue-dark);
}

.message-content a:hover::after {
    width: 100%;
}

/* Strong/Bold */
.message-content strong {
    color: var(--text-primary);
    font-weight: 700;
}

.message-content li strong {
    color: var(--accent-blue-dark);
}

/* Headers */
.message-content h3,
.message-content .section-header {
    font-size: 18px;
    font-weight: 700;
    margin: 20px 0 12px 0;
    color: var(--primary-navy);
    line-height: 1.4;
}

.message-content h4,
.message-content .sub-header {
    font-size: 16px;
    font-weight: 600;
    margin: 16px 0 10px 0;
    color: var(--text-primary);
}

/* Tables */
.message-content table,
.response-table {
    width: 100%;
    border-collapse: collapse;
    margin: 16px 0;
    font-size: 14px;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: var(--shadow-md);
}

.message-content table th,
.response-table th {
    background: var(--gradient-primary);
    color: white;
    padding: 14px 16px;
    text-align: left;
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.message-content table td,
.response-table td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-light);
    background: var(--bg-card);
    transition: background 0.2s ease;
}

.message-content table tr:hover td {
    background: var(--soft-blue);
}

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

/* Welcome Message */
.message.welcome {
    max-width: 100%;
    width: 100%;
    margin: auto;
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 1;
}

.message.welcome strong:first-child {
    display: none !important;
}

.message.welcome .message-content {
    background: var(--primary-navy) !important;
    border: none !important;
    padding: 40px !important;
    box-shadow: var(--shadow-lg) !important;
    border-radius: 24px !important;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    width: 100%;
    max-width: 700px;
    position: relative;
    color: var(--white);
}

.message.welcome .message-content p {
    color: rgba(255, 255, 255, 0.9);
    text-align: center;
    font-size: 16px;
    line-height: 1.6;
}

.message.welcome .message-content h2,
.message.welcome .message-content h3 {
    color: var(--white);
    text-align: center;
}

/* Brand Name Styling in Welcome */
.welcome-brand {
    font-size: 32px;
    font-weight: 800;
    margin-bottom: 16px;
    letter-spacing: -0.5px;
}

.welcome-brand .brand-loan {
    color: #4A9FE8;  /* Bright blue for dark background */
}

.welcome-brand .brand-space {
    color: #F5A623;  /* Bright orange for dark background */
}


/* ============================================
   COMPACT WELCOME BANNER (50% SMALLER)
   ============================================ */

.welcome-banner {
  max-width: 900px;
  margin: 0 auto;
  padding: 1.5rem 1.5rem 1rem 1.5rem;
  text-align: center;
}

/* Hero Section - Compact */
.welcome-hero {
  margin-bottom: 1.25rem;
}

.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.35rem 0.75rem;
  background: linear-gradient(135deg, #D66D2B15, #2558B215);
  border: 1px solid #D66D2B30;
  border-radius: 50px;
  font-size: 0.7rem;
  font-weight: 600;
  color: #D66D2B;
  margin-bottom: 0.75rem;
}

.hero-badge svg {
  color: #D66D2B;
}

.welcome-title {
  font-size: 1.4rem;
  font-weight: 700;
  line-height: 1.3;
  margin: 0 0 0.65rem 0;
  color: #1e293b;
}

.welcome-subtitle {
  font-size: 0.85rem;
  line-height: 1.5;
  color: #64748b;
  margin: 0 auto;
  padding: 0.5rem 1rem;
  max-width: 650px;
}

/* Features Grid - 3 columns for balance */
.features-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.feature-card-modern {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 1rem 0.75rem;
  text-align: center;
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
}

.feature-card-modern::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, #D66D2B, #2558B2);
  transform: scaleX(0);
  transition: transform 0.3s ease;
}

.feature-card-modern:hover::before {
  transform: scaleX(1);
}

.feature-card-modern:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.08);
  border-color: #cbd5e1;
}

.feature-icon-wrapper {
  margin-bottom: 0.5rem;
}

.feature-icon {
  font-size: 1.75rem;
  display: inline-block;
}

.feature-title {
  font-size: 0.9rem;
  font-weight: 600;
  color: #1e293b;
  margin: 0 0 0.35rem 0;
}

.feature-description {
  font-size: 0.75rem;
  color: #64748b;
  line-height: 1.4;
  margin: 0;
}

/* Welcome CTA - Compact */
.welcome-cta {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid #e2e8f0;
}

.cta-text {
  font-size: 0.85rem;
  color: #64748b;
  font-weight: 500;
  margin: 0;
}

/* ============================================
   MOBILE RESPONSIVE - COMPACT
   ============================================ */

/* Tablet/Medium screens - 2 column grid */
@media (max-width: 968px) {
  .features-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* Mobile - Compact spacing */
@media (max-width: 768px) {
  .welcome-banner {
    padding: 0.75rem 1rem 0.5rem 1rem;
  }

  .welcome-hero {
    margin-bottom: 0.5rem;
  }

  .hero-badge {
    padding: 0.25rem 0.6rem;
    font-size: 0.65rem;
    margin-bottom: 0.3rem;
  }

  .welcome-title {
    font-size: 1.1rem;
    line-height: 1.1;
    margin: 0 0 0.05rem 0;
  }

  .welcome-subtitle {
    font-size: 0.75rem;
    line-height: 1.3;
    margin: 0 auto 0.75rem auto;
    padding: 0.4rem 0.75rem;
  }

  .features-grid {
    gap: 0.5rem;
    margin-top: 0;
    margin-bottom: 0.75rem;
  }

  .feature-card-modern {
    padding: 0.65rem 0.5rem;
  }

  .feature-icon-wrapper {
    margin-bottom: 0.35rem;
  }

  .feature-icon {
    font-size: 1.4rem;
  }

  .feature-title {
    font-size: 0.8rem;
    margin: 0 0 0.25rem 0;
  }

  .feature-description {
    font-size: 0.68rem;
    line-height: 1.3;
  }

  .welcome-cta {
    margin-top: 0.75rem;
    padding-top: 0.75rem;
  }

  .cta-text {
    font-size: 0.8rem;
  }

  /* Hide sidebar rate widget on mobile */
  .sidebar .rate-widget {
    display: none !important;
  }
}

/* Small Mobile - Extra compact */
@media (max-width: 480px) {
  .welcome-banner {
    padding: 0.5rem 0.85rem 0.35rem 0.85rem;
  }

  .welcome-hero {
    margin-bottom: 0.4rem;
  }

  .hero-badge {
    padding: 0.2rem 0.5rem;
    font-size: 0.6rem;
    margin-bottom: 0.25rem;
  }

  .welcome-title {
    font-size: 1rem;
    line-height: 1.1;
    margin: 0 0 0.05rem 0;
  }

  .welcome-subtitle {
    font-size: 0.7rem;
    line-height: 1.25;
    margin: 0 auto 0.6rem auto;
    padding: 0.35rem 0.65rem;
  }

  .features-grid {
    gap: 0.4rem;
    margin-top: 0;
    margin-bottom: 0.6rem;
  }

  .feature-card-modern {
    padding: 0.55rem 0.4rem;
  }

  .feature-icon {
    font-size: 1.25rem;
  }

  .feature-title {
    font-size: 0.75rem;
  }

  .feature-description {
    font-size: 0.65rem;
  }

  .welcome-cta {
    margin-top: 0.6rem;
    padding-top: 0.6rem;
  }

  .cta-text {
    font-size: 0.75rem;
  }
}

/* Starter Buttons */
.starter-buttons {
    display: grid !important;
    grid-template-columns: repeat(3, 1fr) !important;
    gap: 16px !important;
    margin: 0 auto !important;
    max-width: 900px;
    width: 100%;
    padding: 30px 20px;
    justify-items: center;
}

.starter-btn {
    aspect-ratio: 1 / 1;
    width: 100%;
    max-width: 240px;
    padding: 24px 20px;
    background: var(--bg-card);
    border: 2px solid var(--border-color);
    border-radius: 20px;
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    box-shadow: var(--shadow-md);
    text-align: center;
}

.starter-btn:hover {
    background: var(--soft-blue);
    border-color: var(--accent-blue);
    transform: translateY(-8px);
    box-shadow: var(--shadow-glow-blue);
}

.starter-btn:active {
    transform: translateY(-4px);
}

.starter-icon {
    font-size: 42px;
    line-height: 1;
}

.starter-content {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.starter-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.3;
}

.starter-desc {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    line-height: 1.4;
}

/* Document Status */
.document-status {
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--soft-blue);
    border: 1px solid rgba(43, 124, 196, 0.2);
    border-radius: 14px;
    padding: 12px 18px;
    margin-bottom: 16px;
    font-size: 14px;
    font-weight: 500;
}

.document-status .doc-icon {
    font-size: 20px;
}

.document-status #docFilename {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--accent-blue-dark);
    font-weight: 600;
}

.clear-doc-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 18px;
    padding: 4px 8px;
    border-radius: 6px;
    transition: all 0.2s ease;
}

.clear-doc-btn:hover {
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
}

/* ===== INPUT AREA ===== */
.input-area {
    padding: 20px 0;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

#input {
    width: 100%;
    padding: 16px 20px;
    border: 2px solid var(--border-color);
    border-radius: 16px;
    font-size: 16px;
    font-family: 'Inter', sans-serif;
    resize: none;
    outline: none;
    transition: all 0.3s ease;
    min-height: 56px;
    max-height: 180px;
    background: var(--bg-card);
    color: var(--text-primary);
    line-height: 1.5;
}

#input::placeholder {
    color: var(--text-muted);
}

#input:focus {
    border-color: var(--accent-blue);
    background: var(--bg-card);
    box-shadow: 0 0 0 4px rgba(43, 124, 196, 0.1);
}

.button-group {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

#sendButton {
    padding: 14px 28px;
    background: var(--gradient-blue);
    color: var(--white);
    border: none;
    border-radius: 14px;
    font-weight: 700;
    font-size: 15px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 10px;
    box-shadow: var(--shadow-glow-blue);
}

#sendButton span {
    display: none;
}

#sendButton:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 28px rgba(43, 124, 196, 0.35);
}

#sendButton:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

#speechButton,
.upload-button {
    padding: 14px 18px;
    background: var(--bg-card);
    border: 2px solid var(--border-color);
    border-radius: 14px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

#speechButton:hover,
.upload-button:hover {
    background: var(--soft-blue);
    border-color: var(--accent-blue);
    transform: translateY(-2px);
}

#speechButton img {
    height: 22px;
    width: 22px;
}

.upload-button svg {
    width: 22px;
    height: 22px;
    stroke: var(--text-secondary);
    transition: stroke 0.3s ease;
}

.upload-button:hover svg {
    stroke: var(--accent-blue);
}

.upload-button.has-document {
    background: var(--soft-blue);
    border-color: var(--accent-blue);
}

.upload-button.has-document svg {
    stroke: var(--accent-blue);
}

/* Powered By */
.powered-by {
    padding: 14px 0;
    text-align: center;
    font-size: 12px;
    color: var(--text-muted);
    font-style: italic;
}

/* Loading States */
.thinking {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 18px 22px;
    background: var(--soft-blue);
    border: 1px solid rgba(43, 124, 196, 0.2);
    border-radius: 16px;
    color: var(--accent-blue-dark);
    font-weight: 600;
    max-width: 80%;
    align-self: flex-start;
}

.spinner {
    border: 3px solid var(--border-color);
    border-top: 3px solid var(--accent-blue);
    border-radius: 50%;
    width: 22px;
    height: 22px;
    animation: spin 0.8s linear infinite;
}

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

.error {
    background: rgba(239, 68, 68, 0.08);
    color: #dc2626;
    border: 1px solid rgba(239, 68, 68, 0.2);
    border-radius: 16px;
    padding: 18px 22px;
    font-weight: 500;
    max-width: 80%;
    align-self: flex-start;
}

/* Scrollbar Styling */
#chatbox::-webkit-scrollbar,
.sidebar::-webkit-scrollbar,
.chat-history-container::-webkit-scrollbar {
    width: 6px;
}

#chatbox::-webkit-scrollbar-track,
.sidebar::-webkit-scrollbar-track,
.chat-history-container::-webkit-scrollbar-track {
    background: transparent;
}

#chatbox::-webkit-scrollbar-thumb,
.sidebar::-webkit-scrollbar-thumb,
.chat-history-container::-webkit-scrollbar-thumb {
    background: rgba(148, 163, 184, 0.3);
    border-radius: 8px;
}

#chatbox::-webkit-scrollbar-thumb:hover,
.sidebar::-webkit-scrollbar-thumb:hover,
.chat-history-container::-webkit-scrollbar-thumb:hover {
    background: rgba(148, 163, 184, 0.5);
}

.sidebar::-webkit-scrollbar-thumb {
    background: rgba(148, 163, 184, 0.3);
}

.sidebar::-webkit-scrollbar-thumb:hover {
    background: rgba(148, 163, 184, 0.5);
}

/* ===== RATE WIDGET ===== */
.rate-widget {
    background: var(--soft-blue);
    border-radius: 10px;
    padding: 8px 12px;
    margin: 4px 10px 0 10px;
    border: 1px solid rgba(43, 124, 196, 0.15);
    cursor: pointer;
    transition: all 0.3s ease;
    flex-shrink: 0;
}

.rate-widget:hover {
    background: var(--soft-blue-dark);
    border-color: var(--accent-blue);
}

.rate-widget-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--text-muted);
    margin-bottom: 4px;
    font-weight: 600;
}

.rate-expand-icon {
    font-size: 14px;
    transition: transform 0.3s ease;
    display: inline-block;
    color: var(--text-muted);
}

.rate-widget.expanded .rate-expand-icon {
    transform: rotate(90deg);
}

.rate-widget-content {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

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

.rate-label {
    font-size: 12px;
    color: var(--text-secondary);
    font-weight: 500;
}

.rate-value {
    font-weight: 700;
    font-size: 13px;
    color: var(--text-primary);
    margin-left: auto;
    margin-right: 6px;
}

.rate-arrow {
    font-size: 12px;
    width: 16px;
    text-align: center;
}

.rate-arrow.up {
    color: #ef4444;
}

.rate-arrow.down {
    color: #10b981;
}

.rate-arrow.unchanged {
    color: var(--text-muted);
}

.rate-widget-footer {
    font-size: 10px;
    color: var(--text-muted);
    margin-top: 6px;
    padding-top: 6px;
    border-top: 1px solid rgba(43, 124, 196, 0.15);
}

.rate-widget.loading .rate-value {
    opacity: 0.5;
}

.rate-expanded {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid rgba(43, 124, 196, 0.15);
}

.rate-chat-btn {
    width: 100%;
    margin-top: 12px;
    padding: 10px 14px;
    background: var(--gradient-blue);
    border: none;
    border-radius: 8px;
    color: white;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.rate-chat-btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-glow-blue);
}

/* ===== RESPONSIVE - MOBILE (768px and below) ===== */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-250px);
        display: flex;
        flex-direction: column;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        padding-bottom: 100px;
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .sidebar-overlay {
        display: block;
    }

    .main-content {
        margin-left: 0;
        width: 100%;
    }

    .mobile-header {
        display: flex;
    }

    .sidebar-header {
        display: none;
    }

    .sidebar-footer {
        order: 1;
        margin-top: 0;
        margin-bottom: 4px;
        padding-top: 0;
        padding-bottom: 4px;
        flex-shrink: 0;
    }

    .rate-widget {
        order: 2;
        margin: 2px 10px;
        padding: 8px 12px;
        flex-shrink: 0;
    }

    .sidebar-section {
        order: 3;
        padding: 2px 10px;
        flex-shrink: 0;
    }

    /* Move "Chats / View History" section up on mobile so it's not cut off */
    .sidebar-section:last-of-type {
        order: 2;
        padding-top: 0;
        padding-bottom: 1px;
    }

    .sidebar-section-title {
        margin-bottom: 1px;
        font-size: 10px;
    }

    .sidebar-item,
    .sidebar-item-link {
        padding: 5px 8px;
        margin-bottom: 0;
        font-size: 12.5px;
    }

    .chat-history-container {
        order: 4;
        flex: 0 0 auto;
        max-height: none;
        overflow-y: visible;
        padding-bottom: 12px;
    }

    .chat-container {
        margin: 16px auto;
        padding: 0 16px;
    }

    #chatbox {
        padding: 16px 0;
    }

    .input-area {
        padding: 16px 0;
    }

    .powered-by {
        padding: 10px 0;
        font-size: 11px;
    }

    .message {
        max-width: 90%;
    }

    .message.welcome {
        max-width: 100%;
    }

    .thinking,
    .error {
        max-width: 90%;
    }

    .starter-buttons {
        display: flex !important;
        flex-direction: row !important;
        overflow-x: auto !important;
        scroll-snap-type: x mandatory !important;
        gap: 16px !important;
        max-width: 100%;
        padding: 20px 16px;
        margin: 0 -16px;
        -webkit-overflow-scrolling: touch;
    }

    .starter-buttons::-webkit-scrollbar {
        display: none;
    }

    .starter-btn {
        flex: 0 0 240px;
        min-height: 240px;
        padding: 20px 16px;
        scroll-snap-align: center;
    }

    .starter-btn:first-child {
        margin-left: 16px;
    }

    .starter-btn:last-child {
        margin-right: 16px;
    }

    .starter-icon {
        font-size: 36px;
    }

    .starter-title {
        font-size: 15px;
    }

    .starter-desc {
        font-size: 12px;
    }

    .message.welcome .message-content::after {
        content: '';
        position: absolute;
        right: 0;
        top: 0;
        bottom: 0;
        width: 60px;
        background: linear-gradient(to left, rgba(248, 250, 252, 0.95), transparent);
        pointer-events: none;
        z-index: 1;
    }

    .message.welcome .message-content {
        min-height: auto !important;
    }

    #sendButton span {
        display: none;
    }
}

/* ===== RESPONSIVE - TABLET (481px - 768px) ===== */
@media (min-width: 481px) and (max-width: 768px) {
    .chat-container {
        padding: 0 20px;
    }

    #sendButton span {
        display: inline;
    }

    .starter-buttons {
        grid-template-columns: repeat(2, 1fr) !important;
        max-width: 600px;
        justify-items: center;
    }
}

/* ===== RESPONSIVE - DESKTOP (769px+) ===== */
@media (min-width: 769px) {
    #sendButton span {
        display: inline;
    }
}

/* ===== RESPONSIVE - TABLET WITH SIDEBAR (769px - 1024px) ===== */
@media (min-width: 769px) and (max-width: 1024px) {
    .sidebar {
        width: 200px;
    }
    
    .main-content {
        margin-left: 200px;
        width: calc(100% - 200px);
    }
    
    .sidebar-section-title {
        font-size: 10px;
    }
    
    .sidebar-item,
    .sidebar-item-link {
        font-size: 13px;
        padding: 8px 10px;
    }
    
    .sidebar-icon {
        width: 18px;
        height: 18px;
        font-size: 16px;
    }
    
    .sidebar-footer {
        padding-bottom: 60px;
    }
    
    .starter-buttons {
        grid-template-columns: repeat(2, 1fr) !important;
        max-width: 600px;
        justify-items: center;
    }
}

/* ===== RESPONSIVE - LARGE DESKTOP (1025px+) ===== */
@media (min-width: 1025px) {
    .sidebar-logo {
        width: 100%;
        height: auto;
    }
    
    .sidebar-header {
        padding: 0;
    }
}

/* ===== RESPONSIVE - EXTRA LARGE DESKTOP (1400px+) ===== */
@media (min-width: 1400px) {
    .starter-buttons {
        max-width: 800px;
    }
    
    .starter-btn {
        max-width: 250px;
    }
}

/* Enhanced list styling for chat responses */
.chat-message ul.chat-list,
.chat-message ol.chat-list {
    margin: 1em 0;
    padding-left: 1.5em;
    line-height: 1.6;
}

.chat-message ul.chat-list li,
.chat-message ol.chat-list li {
    margin: 0.5em 0;
    padding-left: 0.3em;
}

.chat-message ol.chat-list {
    counter-reset: item;
    list-style: none;
    padding-left: 2em;
}

.chat-message ol.chat-list li {
    counter-increment: item;
    position: relative;
}

.chat-message ol.chat-list li:before {
    content: counter(item) ".";
    position: absolute;
    left: -2em;
    width: 1.5em;
    text-align: right;
    font-weight: 600;
    color: var(--accent-blue);
}

.chat-message ul.chat-list li {
    position: relative;
}

.chat-message ul.chat-list li:before {
    content: "•";
    position: absolute;
    left: -1.2em;
    color: var(--accent-blue);
    font-weight: bold;
}

/* ===== QUESTION LIMIT WARNING STYLES ===== */
.question-warning {
    display: none;
    align-items: center;
    padding: 12px 16px;
    margin-bottom: 1rem;
    border-radius: 8px;
    gap: 12px;
    font-size: 14px;
    animation: slideDown 0.3s ease-out;
}

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

.question-warning.warning-medium {
    background-color: #fffbeb;
    border: 1px solid #fde68a;
    color: #92400e;
}

.question-warning.warning-high {
    background-color: #fef2f2;
    border: 1px solid #fecaca;
    color: #991b1b;
}

.warning-icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

.question-warning a {
    color: inherit;
    text-decoration: underline;
    font-weight: 600;
}

.question-warning a:hover {
    text-decoration: none;
}

/* ===== LIMIT REACHED MODAL ===== */
.limit-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.limit-modal.active {
    display: flex;
}

.limit-modal-content {
    background: white;
    border-radius: 12px;
    padding: 32px;
    max-width: 400px;
    margin: 20px;
    text-align: center;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
}

.limit-modal-icon {
    font-size: 48px;
    margin-bottom: 16px;
}

.limit-modal h2 {
    margin: 0 0 12px 0;
    font-size: 24px;
    color: #1f2937;
}

.limit-modal p {
    color: #6b7280;
    margin: 0 0 24px 0;
    line-height: 1.6;
}

.limit-modal-buttons {
    display: flex;
    gap: 12px;
    justify-content: center;
}

.limit-modal-btn {
    padding: 12px 24px;
    border-radius: 8px;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    border: none;
    transition: all 0.2s;
}

.limit-modal-btn.primary {
    background: var(--accent-blue);
    color: white;
}

.limit-modal-btn.primary:hover {
    background: var(--accent-blue-dark);
}

.limit-modal-btn.secondary {
    background: #f3f4f6;
    color: #374151;
}

.limit-modal-btn.secondary:hover {
    background: #e5e7eb;
}

/* ===== FONT AWESOME ICON COLORS ===== */
/* Starter button icons - colorful */
.starter-icon i {
    font-size: 24px;
}

.starter-btn:nth-child(1) .starter-icon i { color: #ef4444; } /* Red - house */
.starter-btn:nth-child(2) .starter-icon i { color: #22c55e; } /* Green - chart */
.starter-btn:nth-child(3) .starter-icon i { color: #f59e0b; } /* Amber - hand holding dollar */
.starter-btn:nth-child(4) .starter-icon i { color: #eab308; } /* Yellow - key */
.starter-btn:nth-child(5) .starter-icon i { color: #3b82f6; } /* Blue - check */
.starter-btn:nth-child(6) .starter-icon i { color: #ec4899; } /* Pink - piggy bank */

.starter-btn:hover .starter-icon i {
    transform: scale(1.1);
    transition: transform 0.2s ease;
}

/* Sidebar icons - blue theme */
.sidebar-icon i {
    font-size: 18px;
    color: var(--accent-blue);
}

.sidebar-item:hover .sidebar-icon i,
.sidebar-item-link:hover .sidebar-icon i {
    color: var(--accent-blue-dark);
}

.sidebar-item.active .sidebar-icon i {
    color: #ffffff;
}

/* Login & Register custom icon colors - gradient */
.sidebar-login .sidebar-icon i {
    background: linear-gradient(135deg, #10b981, #059669);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}
.sidebar-login:hover .sidebar-icon i {
    background: linear-gradient(135deg, #059669, #047857);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}
.sidebar-register .sidebar-icon i {
    background: linear-gradient(135deg, #f59e0b, #ea580c);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}
.sidebar-register:hover .sidebar-icon i {
    background: linear-gradient(135deg, #ea580c, #c2410c);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* ===== MOBILE RATES DISPLAY ===== */
.mobile-rates {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 11px;
    color: var(--text-secondary);
    white-space: nowrap;
}

.mobile-rate-item {
    display: flex;
    align-items: center;
    gap: 3px;
}

.mobile-rate-label {
    font-weight: 500;
    color: var(--text-muted);
}

.mobile-rate-value {
    font-weight: 600;
    color: var(--text-primary);
}

.mobile-rate-arrow {
    font-size: 10px;
}

.mobile-rate-arrow.up {
    color: #ef4444;
}

.mobile-rate-arrow.down {
    color: #10b981;
}

.mobile-rate-divider {
    color: var(--text-light);
    font-weight: 300;
}

/* Hide mobile rates on desktop */
@media (min-width: 769px) {
    .mobile-rates {
        display: none !important;
    }
}
