/* START OF FILE style.css */

/* ========== Loading Screen Styles ========== */
#loading-screen {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  z-index: 99999; /* Increased z-index to be absolutely sure it's on top */
  color: white;
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  opacity: 1; /* Add opacity for fade-out transition */
  transition: opacity 0.5s ease-out; /* Add transition for fade-out */
  pointer-events: auto; /* Ensure it's interactive */
}

/* Class to trigger fade-out, to be added via JS */
#loading-screen.fade-out {
  opacity: 0;
  pointer-events: none; /* Allow interaction with content below during fade-out */
}

.loading-circle {
  width: 80px;
  height: 80px;
  border: 4px solid rgba(255, 255, 255, 0.3);
  border-top: 4px solid white;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-bottom: 30px;
}

.loading-text {
  text-align: center;
  margin-bottom: 30px;
}

.loading-text h2 {
  margin: 0 0 10px 0;
  font-size: 24px;
  font-weight: 600; /* Added for better readability */
}

.loading-text p {
  margin: 0;
  font-size: 16px;
  opacity: 0.8;
}

.progress-container {
  width: 300px;
  max-width: 80%; /* Ensure it doesn't overflow on small screens */
  height: 8px; /* Slightly thicker */
  background: rgba(255, 255, 255, 0.25); /* Adjusted alpha */
  border-radius: 4px; /* Consistent with thicker bar */
  overflow: hidden;
  margin-bottom: 20px;
}

#progress-bar {
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, #4CAF50, #388E3C); /* Slightly darker green gradient */
  border-radius: 4px; /* Match container */
  transition: width 0.4s cubic-bezier(0.25, 0.1, 0.25, 1); /* Smoother transition */
}

#progress-text {
  font-size: 14px;
  opacity: 0.7;
  font-weight: 500; /* Added for better readability */
}

/* Keyframes are fine */
@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* ========== CSS Variables :root ========== */
:root {
  /* Primary Colors - Good selection */
  --primary-50: #ecfdf5;
  --primary-100: #d1fae5;
  --primary-200: #a7f3d0;
  --primary-300: #6ee7b7;
  --primary-400: #34d399;
  --primary-500: #10b981;
  --primary-600: #059669;
  --primary-700: #047857;
  --primary-800: #065f46;
  --primary-900: #064e3b;

  /* Secondary accent colors - Good selection */
  --accent-blue: #3b82f6;
  --accent-purple: #8b5cf6;
  --accent-pink: #ec4899;
  --accent-orange: #f97316;

  /* Neutral Colors - Good selection */
  --white: #ffffff;
  --gray-25: #fcfcfd;
  --gray-50: #f8fafc;
  --gray-100: #f1f5f9;
  --gray-200: #e2e8f0;
  --gray-300: #cbd5e1;
  --gray-400: #94a3b8;
  --gray-500: #64748b;
  --gray-600: #475569;
  --gray-700: #334155;
  --gray-800: #1e293b;
  --gray-900: #0f172a;
  --black: #000000;

  /* Semantic Colors - Good selection */
  --success-50: #ecfdf5;
  --success-100: #d1fae5;
  --success-500: #10b981;
  --success-600: #059669;
  --success-700: #047857;

  --warning-50: #fffbeb;
  --warning-100: #fef3c7;
  --warning-500: #f59e0b;
  --warning-600: #d97706;
  --warning-700: #b45309;

  --error-50: #fef2f2;
  --error-100: #fee2e2;
  --error-500: #ef4444;
  --error-600: #dc2626;
  --error-700: #b91c1c;
  /* Added error-200 for borders on light error backgrounds */
  --error-200: #fecaca;


  --info-50: #eff6ff;
  --info-100: #dbeafe;
  --info-500: #3b82f6;
  --info-600: #2563eb;
  --info-700: #1d4ed8;

  /* Component Colors */
  --primary-color: var(--primary-500);
  --primary-hover: var(--primary-600);
  --primary-active: var(--primary-700); /* Added active state for primary */
  --primary-light: var(--primary-50);
  --primary-gradient: linear-gradient(135deg, var(--primary-500), var(--accent-blue)); /* Changed to use accent-blue for more pop */
  --primary-gradient-hover: linear-gradient(135deg, var(--primary-600), var(--accent-purple)); /* Changed hover to accent-purple */

  /* Renamed --user-bubble to --user-bubble-bg for clarity */
  --user-bubble-bg: var(--primary-500);
  --user-bubble-text: var(--white);
  /* Renamed --bot-bubble to --bot-bubble-bg for clarity */
  --bot-bubble-bg: var(--white);
  --bot-bubble-border: var(--gray-200);
  --bot-bubble-text: var(--gray-700); /* For bot messages */

  --border-color: var(--gray-200);
  --border-light: var(--gray-100); /* Often same as --gray-100 or --gray-200 */
  --text-color: var(--gray-800); /* Main text, slightly darker for better contrast on light bg */
  --text-secondary: var(--gray-600);
  --text-muted: var(--gray-500);
  --bg-color: var(--gray-50); /* Main page background, changed from gray-25 for a bit more substance */
  --bg-secondary: var(--white); /* For cards, modals, distinct sections */

  /* Glass morphism variables - good to have if used, ensure fallback for non-supporting browsers */
  --glass-bg: rgba(255, 255, 255, 0.6); /* Increased opacity slightly */
  --glass-border: rgba(255, 255, 255, 0.2);
  --glass-backdrop: blur(12px); /* Slightly reduced blur, can be intensive */

  /* Spacing - Comprehensive, good. Ensure consistent usage. */
  --space-0: 0;
  --space-px: 1px;
  --space-0_5: 0.125rem; /* 2px */
  --space-1: 0.25rem;   /* 4px */
  --space-1_5: 0.375rem;/* 6px */
  --space-2: 0.5rem;    /* 8px */
  --space-2_5: 0.625rem;/* 10px */
  --space-3: 0.75rem;   /* 12px */
  --space-3_5: 0.875rem;/* 14px */
  --space-4: 1rem;      /* 16px */
  --space-5: 1.25rem;   /* 20px */
  --space-6: 1.5rem;    /* 24px */
  --space-7: 1.75rem;   /* 28px */
  --space-8: 2rem;      /* 32px */
  --space-10: 2.5rem;   /* 40px */
  --space-12: 3rem;     /* 48px */
  --space-16: 4rem;     /* 64px */
  --space-20: 5rem;
  --space-24: 6rem;

  /* Legacy spacing for compatibility - Consider removing if not actively used to simplify */
  /* --space-xxs: var(--space-0_5); ... */

  /* Typography - Good selection */
  --font-family-sans: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Helvetica Neue', sans-serif;
  --font-family-display: 'Cal Sans', 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; /* Cal Sans might need to be imported */
  --font-family-mono: 'JetBrains Mono', 'Fira Code', Menlo, Monaco, Consolas, 'Liberation Mono', 'Courier New', monospace;

  --font-size-xs: 0.75rem;
  --font-size-sm: 0.875rem;
  --font-size-base: 1rem;
  --font-size-lg: 1.125rem;
  --font-size-xl: 1.25rem;
  --font-size-2xl: 1.5rem;
  --font-size-3xl: 1.875rem;
  --font-size-4xl: 2.25rem;
  --font-size-5xl: 3rem;
  --font-size-6xl: 3.75rem;

  --font-weight-thin: 100;
  --font-weight-light: 300;
  --font-weight-normal: 400;
  --font-weight-medium: 500;
  --font-weight-semibold: 600;
  --font-weight-bold: 700;
  --font-weight-extrabold: 800;
  --font-weight-black: 900;

  --line-height-none: 1;
  --line-height-tight: 1.25;
  --line-height-snug: 1.375;
  --line-height-normal: 1.5;
  --line-height-relaxed: 1.625;
  --line-height-loose: 2;

  --letter-spacing-tighter: -0.05em;
  --letter-spacing-tight: -0.025em;
  --letter-spacing-normal: 0em;
  --letter-spacing-wide: 0.025em;
  --letter-spacing-wider: 0.05em;
  --letter-spacing-widest: 0.1em;

  /* Shadows - Comprehensive. Ensure they are visually distinct enough. */
  --shadow-xs: 0 1px 2px 0 rgba(0, 0, 0, 0.03); /* Softer xs shadow */
  --shadow-sm: 0 2px 4px -1px rgba(0, 0, 0, 0.05), 0 1px 2px -1px rgba(0, 0, 0, 0.04); /* Adjusted for subtlety */
  --shadow-md: 0 4px 8px -2px rgba(0, 0, 0, 0.07), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -4px rgba(0, 0, 0, 0.06);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.08);
  --shadow-2xl: 0 25px 50px -12px rgba(0, 0, 0, 0.2); /* Reduced alpha for 2xl */
  --shadow-inner: inset 0 1px 2px 0 rgba(0, 0, 0, 0.04); /* Softer inner shadow */

  /* Colored shadows - Use sparingly, can be overpowering. */
  --shadow-primary: 0 6px 12px -3px color-mix(in srgb, var(--primary-500) 30%, transparent), 0 4px 8px -4px color-mix(in srgb, var(--primary-500) 20%, transparent);
  --shadow-error: 0 6px 12px -3px color-mix(in srgb, var(--error-500) 30%, transparent), 0 4px 8px -4px color-mix(in srgb, var(--error-500) 20%, transparent);

  /* Border Radius - Good range */
  --radius-none: 0px;
  --radius-sm: 0.125rem; /* 2px */
  --radius-base: 0.25rem; /* 4px */
  --radius-md: 0.375rem; /* 6px */
  --radius-lg: 0.5rem;   /* 8px */
  --radius-xl: 0.75rem;  /* 12px */
  --radius-2xl: 1rem;    /* 16px */
  --radius-3xl: 1.5rem;  /* 24px */
  --radius-full: 9999px;

  /* Transitions - Good set of options. */
  --transition-none: none;
  --transition-fast: all 150ms cubic-bezier(0.4, 0, 0.2, 1); /* Changed duration */
  --transition-normal: all 250ms cubic-bezier(0.4, 0, 0.2, 1); /* Changed duration */
  --transition-slow: all 400ms cubic-bezier(0.4, 0, 0.2, 1); /* Changed duration */
  --transition-slower: all 500ms cubic-bezier(0.4, 0, 0.2, 1);
  /* Renamed --transition-all to --transition-default for clarity or remove if --transition-normal is the default */
  --transition-default: var(--transition-normal);


  /* Easing curves - Good to have if used consistently. */
  --ease-linear: linear;
  --ease-in: cubic-bezier(0.4, 0, 1, 1);
  --ease-out: cubic-bezier(0, 0, 0.2, 1);
  --ease-in-out: cubic-bezier(0.4, 0, 0.2, 1);
  --ease-bounce: cubic-bezier(0.68, -0.55, 0.265, 1.55);

  /* Z-Index Scale - Comprehensive. */
  --z-index-hide: -1;
  --z-index-auto: auto;
  --z-index-base: 0;
  --z-index-docked: 10;
  --z-index-dropdown: 1000;
  --z-index-sticky: 1020; /* Adjusted for typical header/sticky elements */
  --z-index-banner: 1030;
  --z-index-overlay: 1040;
  --z-index-modal: 1050;
  --z-index-popover: 1060;
  --z-index-skipLink: 1070;
  --z-index-toast: 1080;
  --z-index-tooltip: 1090;
  --z-index-loading: 99999; /* Added for loading screen */
}

/* ========== Base Styles ========== */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  border-width: 0; /* Reset border width by default */
  border-style: solid; /* Set border style so only color and width need to be set */
  border-color: transparent; /* Default border color */
}

html {
  scroll-behavior: smooth;
  text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent; /* Remove tap highlight on mobile */
  tab-size: 4;
}

body {
  margin: 0;
  font-family: var(--font-family-sans);
  /* Removed font-feature-settings and font-variation-settings unless 'Cal Sans' or specific features are actively used and tested */
  background: var(--bg-color);
  color: var(--text-color);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  line-height: var(--line-height-normal);
  font-weight: var(--font-weight-normal);
  font-size: var(--font-size-base);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility; /* Good for performance */
}

/* ========== Typography ========== */
h1, h2, h3, h4, h5, h6 {
  font-weight: var(--font-weight-bold);
  line-height: var(--line-height-tight);
  margin-bottom: var(--space-4); /* Consistent bottom margin */
  letter-spacing: var(--letter-spacing-tight);
  color: var(--text-color); /* Explicitly set color */
}

h1 { font-size: var(--font-size-4xl); }
h2 { font-size: var(--font-size-3xl); }
h3 { font-size: var(--font-size-2xl); }
h4 { font-size: var(--font-size-xl); }
h5 { font-size: var(--font-size-lg); }
h6 { font-size: var(--font-size-base); font-weight: var(--font-weight-semibold); } /* Bolder h6 */

p {
  margin-bottom: var(--space-4);
  line-height: var(--line-height-relaxed);
}

a { /* Basic link styling */
  color: var(--primary-600); /* Darker primary for links */
  text-decoration: none;
  transition: color var(--transition-fast);
}
a:hover {
  color: var(--primary-700);
  text-decoration: underline;
}

/* Typography utilities - Good, ensure they are used. */
.text-xs { font-size: var(--font-size-xs); }
/* ... other text utilities are fine */
.text-primary { color: var(--primary-color); }
/* ... other color utilities are fine */

/* ========== Layout Utilities ========== */
.container {
  width: 100%;
  max-width: 1280px; /* Slightly wider max-width */
  margin-left: auto;
  margin-right: auto;
  padding-left: var(--space-4);
  padding-right: var(--space-4);
}

/* Flex and Grid utilities are fine and comprehensive. */
.flex { display: flex; }
/* ... other flex/grid utilities are fine */
.gap-1 { gap: var(--space-1); }
/* ... other gap utilities are fine */
.w-full { width: 100%; }
/* ... other sizing utilities are fine */

/* ========== Header Styles ========== */
header {
  font-weight: var(--font-weight-semibold);
  font-size: var(--font-size-lg);
  padding: var(--space-3) var(--space-4);
  background: var(--glass-bg);
  backdrop-filter: var(--glass-backdrop);
  -webkit-backdrop-filter: var(--glass-backdrop);
  border-bottom: 1px solid var(--glass-border);
  color: var(--text-color);
  position: sticky;
  top: 0;
  z-index: var(--z-index-sticky);
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: var(--shadow-sm);
  transition: background-color var(--transition-default), border-color var(--transition-default), box-shadow var(--transition-default);
}

.header-left {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.header-title {
  background: var(--primary-gradient);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  font-weight: var(--font-weight-extrabold);
  letter-spacing: var(--letter-spacing-tight);
  font-size: var(--font-size-2xl);
  margin: 0;
}

.header-subtitle {
  color: var(--text-secondary);
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
}

.header-actions {
  display: flex;
  gap: var(--space-2);
  align-items: center;
}

/* Dropdown Styles */
.dropdown {
  position: relative;
  display: inline-block;
}

.dropdown-btn {
  background: var(--primary-color);
  border: none;
  color: white;
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-lg);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
  transition: all var(--transition-fast);
  box-shadow: var(--shadow-sm);
}

.dropdown-btn:hover {
  background: var(--primary-600);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.dropdown-arrow {
  font-size: 0.75rem;
  transition: transform var(--transition-fast);
}

.dropdown.active .dropdown-arrow {
  transform: rotate(180deg);
}

.dropdown-content {
  position: absolute;
  top: 100%;
  right: 0;
  background: white;
  min-width: 200px;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--gray-200);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-10px);
  transition: all var(--transition-default);
  z-index: 1000;
  margin-top: var(--space-1);
}

.dropdown.active .dropdown-content {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 12px 16px;
  color: black;
  text-decoration: none;
  transition: all var(--transition-fast);
  border-radius: var(--radius-md);
  margin: 2px 8px;
  font-size: 14px;
  font-weight: 500;
  border-bottom: 1px solid var(--gray-100);
}

.dropdown-item:hover {
  background: var(--gray-50);
  color: black;
  transform: translateX(2px);
}

.dropdown-item:last-child {
  border-bottom: none;
  margin-bottom: 8px;
}

.dropdown-item i {
  width: 16px;
  text-align: center;
  color: var(--text-secondary);
}

.dropdown-item:hover i {
  color: var(--primary-color);
}

.header-btn {
  background: transparent; /* Explicitly transparent */
  border: 1px solid transparent; /* For consistent sizing and focus outline */
  cursor: pointer;
  color: var(--text-secondary);
  font-size: var(--font-size-lg);
  padding: var(--space-2);
  border-radius: var(--radius-lg);
  transition: background-color var(--transition-fast), color var(--transition-fast), transform var(--transition-fast), box-shadow var(--transition-fast);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.75rem;
  height: 2.75rem;
  position: relative; /* For potential pseudo-elements or tooltips */
}

.header-btn:hover {
  background: var(--gray-100);
  color: var(--primary-color); /* Use primary color on hover */
  transform: translateY(-1px) scale(1.05); /* Add slight scale */
  box-shadow: var(--shadow-xs);
}

.header-btn:active {
  transform: translateY(0) scale(0.98);
  background: var(--gray-200); /* Slightly darker active state */
}

/* Focus visible already handled globally, but can be specific if needed */
/* .header-btn:focus-visible { ... } */

/* ========== Chat Interface ========== */
#chat-interface {
  display: flex;
  flex-direction: column;
  flex: 1; /* Crucial for taking available space */
  overflow: hidden; /* Prevent content overflow */
  background: var(--bg-color);
  position: relative; /* For potential absolute positioned children */
}

#chat-container {
  flex: 1; /* Allows chat container to grow and scroll */
  overflow-y: auto; /* Enable vertical scrolling */
  padding: var(--space-4) var(--space-4) var(--space-12) var(--space-4); /* Add more bottom padding to avoid overlap with input area */
  display: flex;
  flex-direction: column;
  gap: var(--space-4); /* Adjusted gap between messages */
  scroll-behavior: smooth;
  scroll-padding-top: var(--space-4); /* Ensure content isn't hidden by sticky header if applicable */
}

/* ========== Message Styles ========== */
.message {
  max-width: 70%; /* Restored original responsive width */
  padding: var(--space-3) var(--space-4); /* Adjusted padding */
  border-radius: var(--radius-xl); /* Slightly less rounded */
  line-height: var(--line-height-relaxed);
  white-space: normal; /* Fixed white space issue */
  word-wrap: break-word; /* Prevent long words from breaking layout */
  position: relative;
  animation: messageSlideIn 0.3s var(--ease-out) forwards; /* Smoother ease and forwards */
  font-size: var(--font-size-base);
  /* backdrop-filter and -webkit-backdrop-filter can be performance intensive. Use cautiously. */
  /* Consider removing if not essential for the design or if performance issues arise. */
   backdrop-filter: var(--glass-backdrop);
   -webkit-backdrop-filter: var(--glass-backdrop);
   box-shadow: var(--shadow-md); /* Consistent shadow */
}

@keyframes messageSlideIn {
  from {
    opacity: 0;
    transform: translateY(15px) scale(0.97); /* Adjusted for subtlety */
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.message.user { /* Ensure .user is used with .message */
  background: var(--user-bubble-bg);
  color: var(--user-bubble-text);
  align-self: flex-end;
  margin-left: auto; /* Good for alignment */
  border-bottom-right-radius: var(--radius-md);
}

/* Removed .user::before and .bot::before as they add visual noise and might not be intended for simple chat bubbles. */
/* If a subtle sheen is desired, ensure it's very minimal. */

.message.bot { /* Ensure .bot is used with .message */
  background: var(--bot-bubble-bg);
  color: var(--bot-bubble-text);
  border: 1px solid var(--bot-bubble-border);
  align-self: flex-start;
  margin-right: auto; /* Good for alignment */
  border-bottom-left-radius: var(--radius-md);
  /* box-shadow: var(--shadow-md); // Already has shadow */
}


.message.error { /* Ensure .error is used with .message */
  background: var(--error-50); /* Solid error background for clarity */
  border: 1px solid var(--error-200);
  color: var(--error-700);
  box-shadow: var(--shadow-error); /* Specific error shadow */
}

/* Optional: If you want to display message timestamps */
.message-time {
  display: block;
  font-size: var(--font-size-xs);
  color: var(--text-muted);
  margin-top: var(--space-1_5); /* Adjusted margin */
  text-align: right; /* Or left, depending on sender */
  opacity: 0.7; /* Reduced opacity */
  font-weight: var(--font-weight-normal); /* Normal weight */
}

/* Typing indicator - JS creates this, CSS styles it */
/* This assumes JS adds a div with class "typing-indicator" and three child divs with "typing-dot" */
.typing-indicator {
  display: flex; /* Use flex for dot alignment */
  align-items: center; /* Vertically center dots if they have different heights */
  gap: var(--space-1_5); /* Space between dots */
  padding: var(--space-3) var(--space-4); /* Match bot message padding */
  align-self: flex-start; /* Align like a bot message */
  background: var(--bot-bubble-bg);
  border: 1px solid var(--bot-bubble-border);
  border-radius: var(--radius-xl);
  border-bottom-left-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  animation: messageSlideIn 0.3s var(--ease-out) forwards; /* Reuse message animation */
  margin: var(--space-2) 0; /* Add some margin if needed */
}

.typing-dot {
  width: 8px;
  height: 8px;
  background-color: var(--gray-400); /* Muted color for dots */
  border-radius: var(--radius-full);
  animation: typingBounce 1.4s infinite ease-in-out;
}

.typing-dot:nth-child(1) { animation-delay: -0.32s; } /* Adjusted delays for smoother loop */
.typing-dot:nth-child(2) { animation-delay: -0.16s; }
.typing-dot:nth-child(3) { animation-delay: 0s; }

@keyframes typingBounce { /* Simplified bounce */
  0%, 80%, 100% {
    transform: scale(0.8);
    opacity: 0.5;
  }
  40% {
    transform: scale(1);
    opacity: 1;
  }
}

/* ========== Input Area ========== */
#input-area {
  display: flex;
  align-items: flex-end; /* Align items to bottom for multi-line text area */
  padding: var(--space-3) var(--space-4); /* Adjusted padding */
  background: var(--glass-bg); /* Using glass variables */
  backdrop-filter: var(--glass-backdrop);
  -webkit-backdrop-filter: var(--glass-backdrop);
  border-top: 1px solid var(--glass-border); /* Using glass variables */
  gap: var(--space-3); /* Adjusted gap */
  position: sticky;
  bottom: 0;
  z-index: var(--z-index-sticky);
  box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.05); /* Softer shadow */
  transition: background-color var(--transition-default), border-color var(--transition-default);
}

#userInput {
  flex: 1; /* Allow it to grow */
  padding: var(--space-3) var(--space-4); /* Adjusted padding */
  font-size: var(--font-size-base);
  border-radius: var(--radius-lg); /* Consistent radius */
  border: 1px solid var(--gray-300); /* Clearer border */
  outline: none; /* Handled by focus-visible */
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast), background-color var(--transition-fast);
  resize: none; /* Keep if JS handles height, otherwise consider 'vertical' */
  min-height: calc(var(--line-height-normal) * 1em + var(--space-3) * 2 + 2px); /* Calculate based on line height and padding */
  line-height: var(--line-height-normal);
  font-family: var(--font-family-sans);
  background: var(--white);
  color: var(--text-color);
  box-shadow: var(--shadow-inner); /* Subtle inner shadow */
}

#userInput:focus { /* Use :focus for consistent styling if :focus-visible is not always triggered by JS focus */
  border-color: var(--primary-color);
  background-color: var(--white); /* Ensure background stays white on focus */
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary-color) 20%, transparent), var(--shadow-sm); /* Focus ring + subtle shadow */
  transform: none; /* Remove transform on focus as it can cause jitter with text */
}

#userInput::placeholder {
  color: var(--text-muted);
  font-weight: var(--font-weight-normal);
  opacity: 1; /* Ensure placeholder is fully visible */
}

#sendBtn {
  background: var(--primary-500);
  border: none; /* Consistent with border reset */
  padding: 0 var(--space-5); /* Adjusted padding */
  border-radius: var(--radius-lg); /* Consistent radius */
  color: var(--white);
  font-weight: var(--font-weight-semibold);
  cursor: pointer;
  font-size: var(--font-size-base);
  transition: background var(--transition-fast);
  white-space: nowrap; /* Prevent text wrapping */
  min-height: calc(var(--line-height-normal) * 1em + var(--space-3) * 2 + 2px); /* Match input height */
  height: auto; /* Allow button to size to content if needed, or set fixed height */
  width: 80px; /* Fixed width for consistent sizing */
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
}



#sendBtn:hover:not(:disabled) { /* Apply hover only if not disabled */
  background: var(--primary-600);
}

#sendBtn:active:not(:disabled) {
  background: var(--primary-700);
}

#sendBtn:disabled {
  background: var(--gray-200); /* Lighter disabled background */
  color: var(--gray-400); /* Muted text for disabled */
  cursor: not-allowed;
  opacity: 0.7; /* Slightly more opaque */
}
/* sendBtn:focus-visible already handled by global */

/* ========== Footer ========== */
footer {
  text-align: center;
  font-size: var(--font-size-sm);
  color: var(--text-muted);
  padding: var(--space-4) var(--space-2); /* Adjusted padding */
  border-top: 1px solid var(--border-light);
  background: var(--bg-secondary); /* Cleaner background for footer */
  /* Removed backdrop-filter for footer for simplicity and performance, unless essential */
}
footer a { /* Specific styling for footer links */
  font-weight: var(--font-weight-medium); /* Consistent with new primary link style */
  color: var(--primary-600);
  text-decoration: none;
  padding: var(--space-0_5) var(--space-1); /* Make clickable area slightly larger */
  margin: calc(-1 * var(--space-0_5)) calc(-1 * var(--space-1));
  border-radius: var(--radius-base);
}
footer a:hover {
  color: var(--primary-700);
  text-decoration: underline;
  background-color: var(--primary-50); /* Subtle background on hover */
}

/* ========== Code Blocks (Prism.js overrides) ========== */
/* Ensure this comes AFTER Prism's default stylesheet if you're using one */
pre[class*="language-"] { /* Target Prism's generated <pre> tags */
  background: var(--gray-800) !important; /* Dark background for code */
  color: var(--gray-100) !important; /* Light text for code */
  padding: var(--space-4) !important; /* Consistent padding */
  border-radius: var(--radius-lg) !important; /* Consistent radius */
  overflow-x: auto !important;
  margin: var(--space-4) 0 !important; /* Consistent margin */
  box-shadow: var(--shadow-lg) !important;
  font-family: var(--font-family-mono) !important;
  font-size: var(--font-size-sm) !important;
  line-height: var(--line-height-relaxed) !important;
  border: 1px solid var(--gray-700) !important; /* Subtle border */
  position: relative; /* For ::before if needed */
  white-space: pre-wrap !important; /* Allow wrapping but preserve spaces */
  word-break: break-all; /* Break long unbreakable strings if necessary */
}

/* Removing pre::before as it might conflict with Prism's line numbering or other plugins. */

code[class*="language-"] { /* Target Prism's generated <code> tags */
  font-family: var(--font-family-mono) !important;
  font-size: 1em !important; /* Inherit from pre */
  font-weight: var(--font-weight-normal) !important; /* Normal weight for code */
  background: none !important; /* Ensure no background on inline code if Prism adds it */
  color: inherit !important; /* Inherit color from pre */
  padding: 0 !important; /* Remove padding if Prism adds it */
  text-shadow: none !important; /* Remove Prism's text shadow if any */
}

/* ========== Code Container (Your custom wrapper) ========== */
.code-container {
  background: var(--gray-800); /* Match pre background */
  border-radius: var(--radius-lg); /* Match pre radius */
  overflow: hidden; /* Important for child elements */
  margin: var(--space-4) 0; /* Consistent margin */
  box-shadow: var(--shadow-lg); /* Consistent shadow */
  border: 1px solid var(--gray-700); /* Consistent border */
}

.code-header {
  background: var(--gray-700); /* Slightly lighter header */
  padding: var(--space-2_5) var(--space-4); /* Adjusted padding */
  color: var(--gray-300); /* Lighter text for header */
  font-family: var(--font-family-mono);
  font-size: var(--font-size-sm);
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--gray-600); /* Darker border */
  font-weight: var(--font-weight-medium);
}
.code-header span { /* Style the language text */
  display: flex;
  align-items: center;
  gap: var(--space-2);
}
.code-header i.fas.fa-code { /* Style FontAwesome icon if present */
 color: var(--primary-400); /* Primary color for icon */
}

.code-content { /* This div wraps the <pre> tag in your JS */
  /* Padding is handled by the pre tag itself now */
  overflow-x: auto; /* Ensure horizontal scroll if content is too wide */
  /* Background is handled by the pre tag */
}

/* Copy/Preview buttons in code header - Assuming these are styled by JS mostly. */
/* It's better to add classes via JS and style them here. */
.code-actions {
  display: flex;
  gap: var(--space-2);
}
.code-actions button { /* Generic styling for buttons in code-actions */
  background: var(--gray-600);
  border: 1px solid var(--gray-500);
  color: var(--gray-100);
  padding: var(--space-1_5) var(--space-3);
  border-radius: var(--radius-md);
  cursor: pointer;
  font-size: var(--font-size-xs);
  display: flex;
  align-items: center;
  gap: var(--space-1_5);
  transition: background-color var(--transition-fast), border-color var(--transition-fast), color var(--transition-fast), transform var(--transition-fast);
  font-weight: var(--font-weight-medium);
}
.code-actions button:hover {
  background: var(--gray-500);
  border-color: var(--gray-400);
  color: var(--white);
  transform: translateY(-1px);
}
.code-actions button:active {
  transform: translateY(0px) scale(0.98);
  background: var(--gray-600);
}
/* Preview container and tabs are fine as they are, assuming they are implemented correctly in HTML/JS. */

/* ========== Scrollbar (Global) ========== */
::-webkit-scrollbar {
  width: 10px; /* Slightly wider */
  height: 10px;
}
::-webkit-scrollbar-track {
  background: var(--gray-100); /* Lighter track */
  border-radius: var(--radius-full);
}
::-webkit-scrollbar-thumb {
  background: var(--gray-300); /* More distinct thumb */
  border-radius: var(--radius-full);
  border: 2px solid var(--gray-100); /* Creates a "channel" effect */
}
::-webkit-scrollbar-thumb:hover {
  background: var(--gray-400);
}
::-webkit-scrollbar-corner { /* Style the corner where vertical and horizontal scrollbars meet */
  background: var(--gray-100);
}
* { /* Firefox scrollbar */
  scrollbar-width: thin;
  scrollbar-color: var(--gray-300) var(--gray-100);
}

/* Animations - Keyframes are fine. */
/* Utility classes (shadows, borders, bg, display etc.) are fine and very comprehensive. */

/* ========== Responsive Design ========== */
@media (max-width: 1024px) { /* Tablet and smaller */
  .container {
    padding-left: var(--space-3);
    padding-right: var(--space-3);
  }
  #chat-container {
    padding: var(--space-3) var(--space-3) var(--space-10) var(--space-3); /* Adjust bottom padding */
    gap: var(--space-3);
  }
}

@media (max-width: 768px) { /* Mobile */
  :root { /* Adjust base sizes for mobile */
    --font-size-base: 0.9375rem; /* 15px */
    --font-size-lg: 1.0625rem; /* 17px */
    --font-size-xl: 1.1875rem; /* 19px */
    --space-4: 0.875rem;   /* 14px */
    --space-6: 1.25rem;    /* 20px */
  }
  header {
    padding: var(--space-2_5) var(--space-3); /* Tighter header padding */
    font-size: var(--font-size-base); /* Smaller header font */
  }
  .message {
    max-width: 90%; /* Allow messages to take more width */
    padding: var(--space-2_5) var(--space-3_5);
    border-radius: var(--radius-lg); /* Slightly smaller radius */
  }
  #input-area {
    padding: var(--space-2_5) var(--space-3);
    gap: var(--space-2_5);
  }
  #userInput, #sendBtn { /* Ensure consistent height for input and button */
    min-height: calc(var(--line-height-normal) * 1em + var(--space-2_5) * 2 + 2px);
    padding-top: var(--space-2_5);
    padding-bottom: var(--space-2_5);
  }
  #sendBtn {
    padding-left: var(--space-4); /* Adjust button padding */
    padding-right: var(--space-4);
    font-size: var(--font-size-sm);
  }
  /* .preview-content height already adjusted */
  /* .tab padding already adjusted */
}

@media (max-width: 480px) { /* Very small screens */
  .message {
    max-width: 95%;
    font-size: var(--font-size-sm); /* Smaller message text */
  }
  header { padding: var(--space-2) var(--space-2_5); }
  .header-btn { width: 2.25rem; height: 2.25rem; font-size: var(--font-size-base); } /* Smaller header buttons */
  #chat-container { padding: var(--space-2_5) var(--space-2_5) var(--space-8) var(--space-2_5); }
  #input-area { padding: var(--space-2); }
  #userInput, #sendBtn { font-size: var(--font-size-sm); }
}

/* ========== Dark Mode ========== */
@media (prefers-color-scheme: dark) {
  :root {
    --primary-color: var(--primary-400);
    --primary-hover: var(--primary-300);
    --primary-active: var(--primary-500); /* Darker active for dark mode */
    --primary-light: color-mix(in srgb, var(--primary-400) 10%, transparent); /* Mix for light bg */
    --primary-gradient: linear-gradient(135deg, var(--primary-400), var(--accent-purple)); /* Dark mode gradient */
    --primary-gradient-hover: linear-gradient(135deg, var(--primary-300), var(--accent-pink));

    --user-bubble-bg: var(--primary-500);
    --user-bubble-text: var(--gray-900); /* Darker text for better contrast on brighter gradient */
    --bot-bubble-bg: var(--gray-800);
    --bot-bubble-border: var(--gray-700);
    --bot-bubble-text: var(--gray-100); /* Light text for bot */

    --border-color: var(--gray-700);
    --border-light: var(--gray-800);
    --text-color: var(--gray-100);
    --text-secondary: var(--gray-400);
    --text-muted: var(--gray-500);
    --bg-color: var(--gray-900);
    --bg-secondary: var(--gray-800);

    --glass-bg: rgba(30, 41, 59, 0.6); /* Dark glass, e.g., --gray-800 with alpha */
    --glass-border: rgba(255, 255, 255, 0.1);

    --shadow-primary: 0 6px 12px -3px color-mix(in srgb, var(--primary-400) 25%, transparent), 0 4px 8px -4px color-mix(in srgb, var(--primary-400) 15%, transparent);
    --shadow-error: 0 6px 12px -3px color-mix(in srgb, var(--error-500) 25%, transparent), 0 4px 8px -4px color-mix(in srgb, var(--error-500) 15%, transparent);
    /* Error colors for dark mode text/bg were missing, using semantic variables now */
    --error-bg-dark: var(--error-500); /* Example, or use a specific dark error bg */
    --error-text-dark: var(--white);

  }

  body {
    /* Using solid color for dark mode, radial gradient can be distracting */
    background: var(--bg-color);
    color: var(--text-color);
  }

  header, #input-area {
    background: var(--glass-bg);
    border-color: var(--glass-border);
    color: var(--text-color); /* Ensure header text is light */
  }
  .header-btn:hover { background: var(--gray-700); color: var(--primary-color); }

  #userInput {
    background: var(--gray-800); /* Darker input */
    border-color: var(--gray-600); /* Darker border */
    color: var(--text-color);
  }
  #userInput:focus {
    border-color: var(--primary-color);
    background-color: var(--gray-700); /* Slightly lighter on focus */
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary-color) 25%, transparent), var(--shadow-sm);
  }

  #sendBtn:disabled { background: var(--gray-700); color: var(--gray-500); }

  footer {
    background: var(--bg-secondary); /* Match other secondary backgrounds */
    border-color: var(--border-color);
    color: var(--text-muted); /* Use variable for muted text */
  }
  footer a { /* Footer links in dark mode */
    color: var(--primary-400); /* Use dark mode primary */
  }
  footer a:hover {
    color: var(--primary-300);
    background-color: var(--primary-light); /* Use dark mode light primary */
  }

  /* Dark mode for tabs and preview would follow similar logic, using dark theme variables. */
  /* Example for tabs: */
  .tab-container { background: var(--gray-800); border-bottom-color: var(--gray-700); }
  .tab { color: var(--gray-400); }
  .tab:hover { background: var(--gray-700); color: var(--gray-100); }
  .tab.active { background: var(--bg-secondary); color: var(--primary-color); }
  .tab.active::after { background: var(--primary-gradient); }
  .tab-content { background: var(--bg-secondary); border-color: var(--border-color); }

  /* Dark mode for Prism (pre/code) - Ensure this doesn't conflict with Prism's own dark theme if used */
  pre[class*="language-"] {
    background: var(--gray-900) !important; /* Even darker for code in dark mode */
    color: var(--gray-200) !important;
    border-color: var(--gray-700) !important;
  }
  .code-container { background: var(--gray-900); border-color: var(--gray-700); }
  .code-header { background: var(--gray-800); color: var(--gray-300); border-bottom-color: var(--gray-700); }
  .code-actions button { background: var(--gray-700); border-color: var(--gray-600); color: var(--gray-100); }
  .code-actions button:hover { background: var(--gray-600); border-color: var(--gray-500); }


  ::-webkit-scrollbar-track { background: var(--gray-800); }
  ::-webkit-scrollbar-thumb { background: var(--gray-600); border-color: var(--gray-800); }
  ::-webkit-scrollbar-thumb:hover { background: var(--gray-500); }
  * { scrollbar-color: var(--gray-600) var(--gray-800); }
}

/* ========== Accessibility & Focus ========== */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

@media (prefers-contrast: high) { /* Basic high contrast adjustments */
  :root {
    --border-color: var(--gray-900); /* Darker borders */
    --text-color: var(--black); /* Ensure text is black */
    --primary-color: #005a9e; /* Darker primary for contrast */
  }
  @media (prefers-color-scheme: dark) {
    :root {
      --border-color: var(--gray-100); /* Lighter borders in dark high contrast */
      --text-color: var(--white);
      --primary-color: #60a5fa; /* Brighter primary */
    }
  }
}

*:focus-visible { /* Global focus style, very important for accessibility */
  outline: 3px solid var(--primary-600); /* More prominent outline */
  outline-offset: 1px; /* Slight offset */
  border-radius: var(--radius-base); /* Consistent radius for focus */
  box-shadow: 0 0 0 3px var(--bg-color), 0 0 0 5px var(--primary-600); /* Inner and outer ring effect */
}
/* Remove default outline for elements that have custom box-shadow focus rings */
#userInput:focus-visible, #sendBtn:focus-visible, .header-btn:focus-visible, footer a:focus-visible, .code-actions button:focus-visible, .tab:focus-visible {
  outline: none;
}


/* Chat Container Specific Scrollbar - This is good */
#chat-container::-webkit-scrollbar { width: 8px; } /* Slightly thicker for easier grabbing */
#chat-container::-webkit-scrollbar-track { background: transparent; }
#chat-container::-webkit-scrollbar-thumb { background: var(--gray-300); border-radius: var(--radius-full); }
#chat-container::-webkit-scrollbar-thumb:hover { background: var(--gray-400); }
@media (prefers-color-scheme: dark) {
  #chat-container::-webkit-scrollbar-thumb { background: var(--gray-600); }
  #chat-container::-webkit-scrollbar-thumb:hover { background: var(--gray-500); }
}


/* ========== Print Styles ========== */
@media print {
  header, footer, #input-area, .header-actions, #clearChat, .code-actions, .tab-container { /* Hide more non-essential elements */
    display: none !important;
  }
  .message {
    break-inside: avoid;
    box-shadow: none !important;
    border: 1px solid #ccc !important; /* Simple border for print */
    padding: var(--space-2) !important;
    background: var(--white) !important; /* Ensure white background for messages */
    color: var(--black) !important; /* Ensure black text */
    backdrop-filter: none !important; /* Remove filters */
    -webkit-backdrop-filter: none !important;
  }
  body {
    background: white !important;
    color: black !important;
    font-size: 10pt; /* Readable print size */
    line-height: 1.3; /* Tighter line height for print */
  }
  #chat-container {
    padding: 0 !important;
    gap: var(--space-2) !important;
    overflow: visible !important; /* Show all content */
  }
  .code-container, pre[class*="language-"] {
    page-break-inside: avoid;
    box-shadow: none !important;
    border: 1px solid #ddd !important;
    background: #f8f8f8 !important; /* Light background for code */
    color: #333 !important; /* Dark text for code */
  }
  a { text-decoration: none; color: inherit !important; }
  code[class*="language-"] { /* Ensure code text is visible */
    color: #333 !important;
    text-shadow: none !important;
  }
}

#stopBtn {
  background: var(--error-500);
  border: none; /* Consistent with border reset */
  padding: 0 var(--space-5); /* Adjusted padding */
  border-radius: var(--radius-lg); /* Consistent radius */
  color: var(--white);
  font-weight: var(--font-weight-semibold);
  cursor: pointer;
  font-size: var(--font-size-base);
  transition: background var(--transition-fast);
  white-space: nowrap; /* Prevent text wrapping */
  min-height: calc(var(--line-height-normal) * 1em + var(--space-3) * 2 + 2px); /* Match input height */
  height: auto; /* Allow button to size to content if needed, or set fixed height */
  width: 80px; /* Fixed width for consistent sizing */
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
}

#stopBtn:hover {
  background: var(--error-600);
}

#stopBtn:active {
  background: var(--error-700);
}
