/* ========================================
   RAG Chatbot - Botanical Tech Design
   Elegant Light Theme with Nature-Inspired Accents
   ======================================== */

/* Import Fonts */
@import url('https://fonts.googleapis.com/css2?family=Cormorant+Garamond:wght@400;500;600;700&family=DM+Sans:wght@400;500;600&display=swap');

/* ========================================
   CSS Custom Properties - Botanical Tech Palette (Light)
   ======================================== */

:root {
  /* Core Colors - Fresh Botanical Light */
  --bg-deep: #f4f7f5;
  --bg-base: #ffffff;
  --bg-surface: #fafdfb;
  --bg-elevated: #ffffff;
  --bg-hover: #edf5ef;

  /* Text */
  --text-primary: #1a2e1f;
  --text-secondary: #4a5d50;
  --text-muted: #7a8b7e;

  /* Primary - Botanical Green (from logo RGB(0, 96, 48)) */
  --primary: #006030;
  --primary-light: #008040;
  --primary-lighter: #00a050;
  --primary-glow: rgba(0, 160, 80, 0.15);
  --primary-subtle: rgba(0, 160, 80, 0.08);
  --primary-border: rgba(0, 160, 80, 0.25);

  /* Accent - Warm Gold */
  --accent: #b8903e;
  --accent-glow: rgba(196, 160, 82, 0.15);

  /* Status Colors */
  --danger: #c94040;
  --danger-bg: rgba(201, 64, 64, 0.1);
  --success: #2a9d5c;
  --success-bg: rgba(42, 157, 92, 0.1);
  --warning: #b8a030;
  --warning-bg: rgba(184, 160, 48, 0.1);

  /* UI Elements */
  --border: rgba(0, 160, 80, 0.12);
  --border-light: rgba(0, 160, 80, 0.06);
  --shadow: 0 25px 50px -12px rgba(0, 80, 40, 0.1);
  --shadow-lg: 0 35px 60px -15px rgba(0, 80, 40, 0.12);
  --radius: 12px;
  --radius-lg: 16px;
  --radius-sm: 8px;

  /* Typography */
  --font-display: 'Cormorant Garamond', Georgia, serif;
  --font-body: 'DM Sans', -apple-system, sans-serif;
}

/* ========================================
   Base Reset & Global Styles
   ======================================== */

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

html {
  scroll-behavior: smooth;
  font-size: 16px;
}

body {
  font-family: var(--font-body);
  background: var(--bg-deep);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ========================================
   Page Backgrounds
   ======================================== */

.page-background,
.auth-background {
  position: fixed;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  background: var(--bg-deep);
}

/* 3D Animated Background - Login Page */
.auth-background {
  perspective: 1000px;
  overflow: hidden;
}

.auth-background::before {
  content: '';
  position: absolute;
  inset: -50%;
  background: 
    radial-gradient(circle at 20% 80%, rgba(0, 160, 80, 0.15) 0%, transparent 50%),
    radial-gradient(circle at 80% 20%, rgba(0, 100, 60, 0.12) 0%, transparent 45%),
    radial-gradient(circle at 40% 40%, rgba(0, 140, 70, 0.08) 0%, transparent 40%),
    radial-gradient(circle at 70% 70%, rgba(0, 80, 50, 0.1) 0%, transparent 50%);
  animation: backgroundPulse 8s ease-in-out infinite;
  transform-style: preserve-3d;
}

.auth-background::after {
  content: '';
  position: absolute;
  inset: -50%;
  background: 
    radial-gradient(ellipse at 60% 30%, rgba(196, 160, 82, 0.08) 0%, transparent 50%),
    radial-gradient(ellipse at 30% 70%, rgba(0, 120, 60, 0.06) 0%, transparent 45%);
  animation: backgroundShift 12s ease-in-out infinite reverse;
  transform-style: preserve-3d;
}

/* 3D Floating Orbs */
.bg-orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(60px);
  opacity: 0.6;
  animation: orbFloat 20s ease-in-out infinite;
  transform-style: preserve-3d;
}

.bg-orb-1 {
  width: 600px;
  height: 600px;
  top: -200px;
  left: -200px;
  background: radial-gradient(circle, rgba(0, 160, 80, 0.4) 0%, transparent 70%);
  animation-delay: 0s;
  transform: translateZ(-100px);
}

.bg-orb-2 {
  width: 500px;
  height: 500px;
  bottom: -150px;
  right: -150px;
  background: radial-gradient(circle, rgba(0, 100, 60, 0.35) 0%, transparent 70%);
  animation-delay: -5s;
  transform: translateZ(-50px);
}

.bg-orb-3 {
  width: 400px;
  height: 400px;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) translateZ(-150px);
  background: radial-gradient(circle, rgba(0, 140, 70, 0.25) 0%, transparent 70%);
  animation-delay: -10s;
}

/* 3D Mesh Grid */
.bg-mesh {
  position: absolute;
  inset: 0;
  background-image: 
    linear-gradient(rgba(0, 160, 80, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0, 160, 80, 0.03) 1px, transparent 1px);
  background-size: 80px 80px;
  transform: perspective(500px) rotateX(60deg);
  transform-origin: center top;
  animation: meshScroll 30s linear infinite;
  mask-image: linear-gradient(to bottom, transparent 0%, black 30%, black 70%, transparent 100%);
  -webkit-mask-image: linear-gradient(to bottom, transparent 0%, black 30%, black 70%, transparent 100%);
}

/* 3D Floating Particles */
.bg-particles {
  position: absolute;
  inset: 0;
  overflow: hidden;
}

.bg-particle {
  position: absolute;
  width: 4px;
  height: 4px;
  background: rgba(0, 160, 80, 0.6);
  border-radius: 50%;
  animation: particleFloat 15s ease-in-out infinite;
  box-shadow: 0 0 10px rgba(0, 160, 80, 0.3);
}

.bg-particle:nth-child(1) { left: 10%; top: 20%; animation-delay: 0s; animation-duration: 18s; }
.bg-particle:nth-child(2) { left: 20%; top: 80%; animation-delay: -2s; animation-duration: 22s; }
.bg-particle:nth-child(3) { left: 35%; top: 40%; animation-delay: -4s; animation-duration: 16s; }
.bg-particle:nth-child(4) { left: 50%; top: 60%; animation-delay: -6s; animation-duration: 20s; }
.bg-particle:nth-child(5) { left: 65%; top: 30%; animation-delay: -8s; animation-duration: 24s; }
.bg-particle:nth-child(6) { left: 75%; top: 70%; animation-delay: -10s; animation-duration: 19s; }
.bg-particle:nth-child(7) { left: 85%; top: 50%; animation-delay: -12s; animation-duration: 21s; }
.bg-particle:nth-child(8) { left: 90%; top: 15%; animation-delay: -14s; animation-duration: 17s; }

/* 3D Gradient Waves */
.bg-waves {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 50%;
  background: linear-gradient(to top, rgba(0, 160, 80, 0.05) 0%, transparent 100%);
  animation: wavePulse 6s ease-in-out infinite;
}

.bg-waves::before,
.bg-waves::after {
  content: '';
  position: absolute;
  inset: 0;
  background: inherit;
  animation: waveShift 8s ease-in-out infinite;
}

.bg-waves::after {
  animation-delay: -4s;
  opacity: 0.5;
}

/* 3D Glow Effect */
.bg-3d-glow {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 150%;
  height: 150%;
  background: radial-gradient(ellipse at center, rgba(0, 160, 80, 0.08) 0%, transparent 50%);
  animation: glowPulse 4s ease-in-out infinite;
  pointer-events: none;
}

/* 3D Animated Background Keyframes */
@keyframes backgroundPulse {
  0%, 100% {
    transform: scale(1) translateZ(0);
    opacity: 0.8;
  }
  50% {
    transform: scale(1.1) translateZ(50px);
    opacity: 1;
  }
}

@keyframes backgroundShift {
  0%, 100% {
    transform: translateX(0) translateY(0) rotateZ(0deg);
  }
  33% {
    transform: translateX(5%) translateY(-3%) rotateZ(2deg);
  }
  66% {
    transform: translateX(-5%) translateY(3%) rotateZ(-2deg);
  }
}

@keyframes orbFloat {
  0%, 100% {
    transform: translateY(0) translateX(0) translateZ(0) scale(1);
  }
  25% {
    transform: translateY(-30px) translateX(20px) translateZ(30px) scale(1.05);
  }
  50% {
    transform: translateY(-50px) translateX(-10px) translateZ(50px) scale(0.95);
  }
  75% {
    transform: translateY(-20px) translateX(30px) translateZ(20px) scale(1.02);
  }
}

@keyframes meshScroll {
  0% {
    transform: perspective(500px) rotateX(60deg) translateY(0);
  }
  100% {
    transform: perspective(500px) rotateX(60deg) translateY(80px);
  }
}

@keyframes particleFloat {
  0%, 100% {
    transform: translateY(0) translateX(0) scale(1);
    opacity: 0.6;
  }
  25% {
    transform: translateY(-100px) translateX(30px) scale(1.5);
    opacity: 1;
  }
  50% {
    transform: translateY(-200px) translateX(-20px) scale(1);
    opacity: 0.6;
  }
  75% {
    transform: translateY(-150px) translateX(40px) scale(1.3);
    opacity: 0.8;
  }
}

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

@keyframes waveShift {
  0%, 100% {
    transform: translateX(0);
  }
  50% {
    transform: translateX(20px);
  }
}

@keyframes glowPulse {
  0%, 100% {
    opacity: 0.5;
    transform: translate(-50%, -50%) scale(1);
  }
  50% {
    opacity: 0.8;
    transform: translate(-50%, -50%) scale(1.1);
  }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
  .bg-orb,
  .bg-particle,
  .bg-mesh,
  .bg-waves,
  .bg-3d-glow,
  .auth-background::before,
  .auth-background::after {
    animation: none;
  }
}

/* Original background elements - enhanced */
.bg-pattern {
  position: absolute;
  inset: 0;
  opacity: 0.3;
  background-image:
    linear-gradient(rgba(0, 160, 80, 0.15) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0, 160, 80, 0.15) 1px, transparent 1px);
  background-size: 60px 60px;
}

.bg-gradient {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 80% 60% at 50% -20%, rgba(0, 160, 80, 0.06) 0%, transparent 50%),
    radial-gradient(ellipse 60% 50% at 80% 100%, rgba(196, 160, 82, 0.04) 0%, transparent 50%);
}

.bg-glow {
  position: absolute;
  top: 30%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 800px;
  height: 800px;
  background: radial-gradient(circle, rgba(0, 160, 80, 0.04) 0%, transparent 70%);
  pointer-events: none;
}

/* ========================================
   Typography
   ======================================== */

h1, h2, h3 {
  font-family: var(--font-display);
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--text-primary);
}

h1 { font-size: 1.75rem; }
h2 { font-size: 1.35rem; }
h3 { font-size: 1.15rem; }

p { margin: 0; }

a {
  color: inherit;
  text-decoration: none;
}

/* ========================================
   Layout
   ======================================== */

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px;
  position: relative;
  z-index: 1;
}

/* ========================================
   Topbar
   ======================================== */

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 24px;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.sidebar-toggle {
  display: none;
  background: none;
  border: none;
  color: var(--text-primary);
  cursor: pointer;
  padding: 8px;
  border-radius: var(--radius-sm);
  transition: background 0.15s ease;
}

.sidebar-toggle:hover {
  background: var(--bg-hover);
}

@media (max-width: 768px) {
  .sidebar-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
  }
}

.topbar-logo {
  height: 36px;
  width: auto;
  object-fit: contain;
}

.topbar-title h1 {
  font-size: 1.25rem;
  font-weight: 600;
  font-family: var(--font-display);
}

.topbar-title .subtitle {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* ========================================
   Buttons
   ======================================== */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 9px 16px;
  font-family: var(--font-body);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  background: transparent;
  color: var(--text-secondary);
}

.btn:hover {
  background: var(--bg-elevated);
  border-color: var(--primary);
  color: var(--text-primary);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary) 0%, #004825 100%);
  border-color: var(--primary-border);
  color: #e8efe6;
  box-shadow: 0 4px 20px var(--primary-glow);
}

.btn-primary:hover:not(:disabled) {
  background: linear-gradient(135deg, var(--primary-light) 0%, var(--primary) 100%);
  box-shadow: 0 6px 30px var(--primary-glow);
  transform: translateY(-1px);
}

.btn-outline {
  background: transparent;
  border: 1px solid var(--border);
}

.btn-danger {
  background: linear-gradient(135deg, var(--danger) 0%, #a03030 100%);
  border-color: rgba(201, 64, 64, 0.3);
  color: #f5e6e6;
}

.btn-danger:hover:not(:disabled) {
  background: linear-gradient(135deg, #d05050 0%, var(--danger) 100%);
  box-shadow: 0 6px 25px rgba(201, 64, 64, 0.3);
}

.btn-sm {
  padding: 6px 12px;
  font-size: 0.75rem;
}

.btn-block {
  width: 100%;
}

.btn-logout {
  padding: 9px 10px;
}

/* ========================================
   Auth Page
   ======================================== */

.auth-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 24px;
}

.auth-container {
  width: 100%;
  max-width: 420px;
  padding: 48px 40px;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(30px);
  -webkit-backdrop-filter: blur(30px);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg), 0 0 80px rgba(0, 160, 80, 0.06);
  position: relative;
  overflow: hidden;
  animation: fadeSlideUp 0.6s ease-out;
}

.auth-container::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--primary), transparent);
}

.auth-header {
  text-align: center;
  margin-bottom: 36px;
}

.logo-wrapper {
  margin-bottom: 24px;
}

.logo-img {
  max-width: 280px;
  height: auto;
  object-fit: contain;
  filter: drop-shadow(0 4px 20px rgba(0, 160, 80, 0.3));
}

.auth-title {
  font-size: 2rem;
  font-weight: 600;
  font-family: var(--font-display);
  margin-bottom: 8px;
  color: var(--text-primary);
}

.auth-subtitle {
  font-size: 0.95rem;
  color: var(--text-muted);
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.auth-footer {
  margin-top: 32px;
  text-align: center;
}

.auth-footer p {
  font-size: 0.8rem;
  color: var(--text-muted);
  letter-spacing: 0.05em;
}

/* ========================================
   Form Fields
   ======================================== */

.field-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.field-label {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-secondary);
}

.input-wrapper {
  position: relative;
}

input,
textarea,
.form-input {
  width: 100%;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  font-family: var(--font-body);
  font-size: 0.95rem;
  color: var(--text-primary);
  transition: all 0.25s ease;
}

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

input:focus,
textarea:focus {
  outline: none;
  border-color: var(--primary);
  background: var(--bg-hover);
  box-shadow: 0 0 0 3px var(--primary-subtle), 0 4px 20px var(--primary-glow);
}

textarea {
  resize: vertical;
  min-height: 100px;
}

/* ========================================
   Alerts
   ======================================== */

.alert {
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  display: flex;
  align-items: center;
  gap: 10px;
  animation: fadeSlideDown 0.3s ease-out;
}

.alert-error {
  background: var(--danger-bg);
  color: #f5c6c6;
  border: 1px solid rgba(201, 64, 64, 0.25);
}

.alert-success {
  background: var(--success-bg);
  color: #c6f5d6;
  border: 1px solid rgba(64, 192, 112, 0.25);
}

/* ========================================
   Chat Page
   ======================================== */

.chat-page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.chat-layout {
  flex: 1;
  display: grid;
  grid-template-columns: 260px 1fr;
  grid-template-rows: 1fr auto;
  gap: 0;
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
  padding: 24px;
  padding-bottom: 40px;
}

.chat-sidebar {
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-right: 1px solid var(--border);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow-y: auto;
}

.new-chat-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 12px 16px;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}

.new-chat-btn:hover {
  background: var(--primary-light);
  transform: translateY(-1px);
}

.conversations-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.conversation-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s ease;
  background: transparent;
  border: none;
  width: 100%;
  text-align: left;
}

.conversation-item:hover {
  background: var(--bg-hover);
}

.conversation-item.active {
  background: var(--primary-subtle);
  border: 1px solid var(--primary-border);
}

.conversation-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  flex: 1;
}

.conversation-title {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.conversation-date {
  font-size: 0.7rem;
  color: var(--text-muted);
}

.conversation-delete {
  opacity: 0;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  transition: all 0.15s ease;
}

.conversation-item:hover .conversation-delete {
  opacity: 1;
}

.conversation-delete:hover {
  color: var(--danger);
  background: var(--danger-bg);
}

.no-conversations {
  padding: 16px;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.85rem;
}

.chat-window {
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 28px;
  overflow-y: auto;
  min-height: 450px;
  display: flex;
  flex-direction: column;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.06);
}

.chat-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  min-height: 350px;
  text-align: center;
  color: var(--text-muted);
}

.empty-logo {
  max-width: 200px;
  opacity: 0.25;
  margin-bottom: 24px;
  filter: grayscale(100%) opacity(0.5);
}

.chat-empty h2 {
  font-size: 1.5rem;
  font-family: var(--font-display);
  margin-bottom: 8px;
  color: var(--text-secondary);
}

.chat-empty p {
  font-size: 0.95rem;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 12px 8px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.chat-message {
  max-width: 80%;
  margin-bottom: 28px;
  padding: 20px 24px;
  border-radius: 22px 22px 6px 22px;
  line-height: 1.65;
  animation: messageSlide 0.4s cubic-bezier(0.3, 0.1, 0.4, 1);
  position: relative;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.06);
  border: 1px solid rgba(0, 160, 80, 0.1);
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.chat-message.user {
  margin-left: auto;
  background: linear-gradient(45deg, #006b35 0%, #008c47 100%);
  color: #ffffff;
  border-radius: 22px 6px 22px 22px;
  box-shadow: 0 6px 30px rgba(0, 96, 48, 0.35);
  position: relative;
  overflow: hidden;
  border: none;
}

.chat-message.user::before {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  width: 45%;
  height: 100%;
  background: linear-gradient(135deg, transparent, rgba(255, 255, 255, 0.25) 70%, transparent);
  pointer-events: none;
}

.chat-message.user::after {
  content: '';
  position: absolute;
  bottom: -10px;
  right: -8px;
  width: 24px;
  height: 24px;
  background: linear-gradient(45deg, #006b35 0%, #008c47 100%);
  border-radius: 0 0 22px 0;
  z-index: -1;
  filter: blur(4px);
  opacity: 0.6;
}

.chat-message.assistant {
  background: linear-gradient(135deg, #ffffff 0%, #f9fdfb 100%);
  color: var(--text-primary);
  border: 1px solid rgba(0, 160, 80, 0.15);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: 0 6px 25px rgba(0, 50, 25, 0.08);
}

.chat-message.assistant::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 45%;
  height: 100%;
  background: linear-gradient(45deg, transparent 60%, rgba(0, 120, 60, 0.05) 100%);
  pointer-events: none;
}

.chat-message.assistant::after {
  content: '';
  position: absolute;
  bottom: -10px;
  left: -8px;
  width: 24px;
  height: 24px;
  background: linear-gradient(45deg, #ffffff 0%, #f9fdfb 100%);
  border-radius: 0 0 0 22px;
  z-index: -1;
  filter: blur(4px);
  opacity: 0.4;
}

.chat-message.typing-bubble {
  /* Smaller bubble size when containing typing indicator */
  max-width: 150px;
  padding: 12px 16px;
}

.chat-message.content-appearing .chat-content {
  animation: contentFadeIn 0.3s ease-out;
}

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

/* Smooth bubble expansion animation */
.chat-message.typing-bubble {
  /* Smaller bubble size when containing typing indicator */
  max-width: 150px;
  padding: 12px 16px;
  transition: all 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.chat-message:not(.typing-bubble) {
  /* Expand to full width smoothly when typing indicator is removed */
  animation: bubbleExpand 0.5s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

@keyframes bubbleExpand {
  0% {
    max-width: 150px;
    padding: 12px 16px;
  }
  100% {
    max-width: 80%;
    padding: 20px 24px;
  }
}

.chat-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  min-height: 380px;
  text-align: center;
  color: var(--text-muted);
  flex: 1;
}

.chat-empty h2 {
  font-size: 1.6rem;
  font-family: var(--font-display);
  margin-bottom: 12px;
  color: var(--text-primary);
  font-weight: 600;
}

.chat-empty p {
  font-size: 1rem;
  color: var(--text-secondary);
  margin-bottom: 24px;
}

.chat-message.user {
  margin-left: auto;
  background: linear-gradient(135deg, var(--primary) 0%, #007a3d 100%);
  color: #ffffff;
  border: 1px solid var(--primary-border);
  box-shadow: 0 4px 20px var(--primary-glow);
}

.chat-message.assistant {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text-primary);
}

.chat-message .chat-content {
  word-break: break-word;
  position: relative;
  z-index: 1;
}

.chat-meta {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--border-light);
  font-size: 0.78rem;
  color: var(--text-secondary);
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
  background: rgba(255, 255, 255, 0.15);
  border-radius: 8px;
  padding: 6px 10px;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

/* Typing Indicator Animation */
.typing-indicator {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 6px;
  padding: 8px 12px;
  max-width: fit-content;
  width: auto;
}

.typing-indicator div {
  width: 10px;
  height: 10px;
  background: var(--text-muted);
  border-radius: 50%;
  opacity: 0.7;
  animation: typingAnimation 1.4s infinite ease-in-out;
  animation-fill-mode: both;
}

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

.typing-indicator div:nth-child(2) {
  animation-delay: 0.2s;
}

.typing-indicator div:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes typingAnimation {
  0%, 60%, 100% {
    transform: translateY(0);
    opacity: 0.7;
  }
  30% {
    transform: translateY(-6px);
    opacity: 1;
  }
}

.tip-cards {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 24px;
  justify-content: center;
}

.tip-card {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  background: rgba(255, 255, 255, 0.7);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  color: var(--text-secondary);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

/* Chat Input */
.chat-input-wrap {
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 18px;
  transition: all 0.3s ease;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.05);
}

.textarea-wrapper {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  position: relative;
}

#questionInput {
  flex: 1;
  min-height: 50px;
  max-height: 150px;
  resize: none;
  margin-bottom: 0;
  padding: 14px 16px 14px 16px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: rgba(250, 255, 252, 0.8);
  transition: all 0.2s ease;
}

#questionInput:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-subtle);
  background: rgba(255, 255, 255, 0.9);
}

.input-actions {
  display: flex;
  gap: 6px;
}

.send-btn {
  width: 46px;
  height: 46px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: linear-gradient(135deg, var(--primary) 0%, #007a3d 100%);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.send-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 15px var(--primary-glow);
  background: linear-gradient(135deg, var(--primary-light) 0%, var(--primary) 100%);
}

.send-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.input-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 12px;
}

.input-hints {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.input-hints small {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* Formatted Content in Chat Messages */
.chat-content {
  line-height: 1.75;
  font-size: 0.95rem;
}

/* Paragraphs */
.chat-content p {
  margin-bottom: 16px;
}

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

/* Lists - Modern styled */
.chat-content ul,
.chat-content ol {
  margin: 16px 0;
  padding-left: 20px;
}

.chat-content li {
  margin-bottom: 10px;
  line-height: 1.65;
  position: relative;
}

.chat-content li::marker {
  color: var(--primary);
  font-weight: 600;
}

/* Modern bullet points with custom marker */
.chat-content ul {
  list-style: none;
  padding-left: 8px;
}

.chat-content ul li {
  padding-left: 24px;
  position: relative;
}

.chat-content ul li::before {
  content: '';
  position: absolute;
  left: 0;
  top: 10px;
  width: 8px;
  height: 8px;
  background: var(--primary);
  border-radius: 50%;
  opacity: 0.7;
}

/* Numbered lists - styled */
.chat-content ol {
  counter-reset: item;
}

.chat-content ol li {
  display: block;
  position: relative;
  padding-left: 28px;
}

.chat-content ol li::before {
  content: counter(item);
  counter-increment: item;
  position: absolute;
  left: 0;
  background: var(--primary);
  color: white;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 600;
}

/* Bold text for emphasis */
.chat-content strong {
  font-weight: 600;
  color: var(--text-primary);
}

/* Headings in content */
.chat-content h1,
.chat-content h2,
.chat-content h3 {
  margin-top: 20px;
  margin-bottom: 12px;
}

.chat-content h1:first-child,
.chat-content h2:first-child,
.chat-content h3:first-child {
  margin-top: 0;
}

/* Source attribution - modern card style */
.chat-source {
  margin-top: 20px;
  padding: 12px 16px;
  background: linear-gradient(135deg, rgba(0, 160, 80, 0.08) 0%, rgba(0, 160, 80, 0.03) 100%);
  border: 1px solid var(--border-light);
  border-radius: 10px;
  font-size: 0.78rem;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 10px;
}

.chat-source svg {
  width: 16px;
  height: 16px;
  color: var(--primary);
  flex-shrink: 0;
}

/* Meta info (hidden for clients) */
.chat-meta {
  display: none !important;
}

/* Chat Input */
.chat-input-wrap {
  background: rgba(17, 26, 20, 0.9);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  transition: all 0.3s ease;
}

.chat-input-wrap:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 30px var(--primary-subtle);
}

.input-header {
  display: flex;
  justify-content: space-between;
  margin-bottom: 12px;
  color: var(--text-muted);
  font-size: 0.8rem;
}

.chat-controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 14px;
}

/* Spinner */
.spinner {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 2px solid var(--border);
  border-top-color: var(--primary);
  animation: spin 0.8s linear infinite;
}

.hidden {
  display: none !important;
}

/* ========================================
   Admin Dashboard
   ======================================== */

.admin-page {
  min-height: 100vh;
}

.admin-grid {
  display: grid;
  gap: 24px;
  padding-bottom: 48px;
}

/* Summary Stats */
.summary-bar {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
}

.summary-card {
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  transition: all 0.3s ease;
}

.summary-card:hover {
  transform: translateY(-2px);
  border-color: var(--primary-border);
  box-shadow: 0 8px 40px var(--primary-glow);
}

.summary-icon {
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--primary-subtle);
  border-radius: var(--radius-sm);
  margin-bottom: 16px;
  color: var(--primary-light);
}

.summary-card h2 {
  font-size: 2.25rem;
  font-weight: 700;
  font-family: var(--font-display);
  color: var(--primary-light);
  line-height: 1;
  margin-bottom: 4px;
}

.summary-card p {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-weight: 500;
}

/* Cards */
.card {
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
}

.card h2 {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1.1rem;
  font-weight: 600;
  font-family: var(--font-display);
  margin-bottom: 20px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-light);
}

.card h2 svg {
  color: var(--primary-light);
}

/* Dropzone */
.dropzone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  background: var(--bg-elevated);
  padding: 40px 24px;
  text-align: center;
  transition: all 0.3s ease;
  cursor: pointer;
}

.dropzone:hover,
.dropzone.drag-active {
  border-color: var(--primary);
  background: var(--bg-hover);
}

.dropzone.drag-active {
  animation: pulse 1s ease-in-out infinite;
}

.dropzone-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.dropzone-content svg {
  color: var(--text-muted);
  opacity: 0.6;
}

.dropzone p {
  color: var(--text-muted);
  font-size: 0.95rem;
}

.link-btn {
  border: none;
  background: none;
  color: var(--primary-light);
  cursor: pointer;
  font-weight: 500;
  padding: 0;
  transition: color 0.2s ease;
}

.link-btn:hover {
  color: var(--primary-lighter);
  text-decoration: underline;
}

/* Progress Bar */
.progress-wrap {
  margin-top: 16px;
  width: 100%;
  height: 6px;
  background: var(--bg-elevated);
  border-radius: 999px;
  overflow: hidden;
}

.progress-bar {
  width: 0;
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--primary-light), var(--primary));
  background-size: 200% 100%;
  border-radius: 999px;
  transition: width 0.3s ease;
  animation: shimmer 1.5s linear infinite;
}

/* Status Log */
.status-log {
  margin-top: 14px;
  max-height: 120px;
  overflow-y: auto;
  font-size: 0.8rem;
  color: var(--text-secondary);
  padding: 8px;
  background: var(--bg-hover);
  border-radius: var(--radius-sm);
}

.status-log p {
  margin: 0 0 4px;
  padding: 4px 8px;
  border-radius: 4px;
}

.status-success {
  color: var(--success);
  background: var(--success-bg);
}

.status-warning {
  color: var(--warning);
  background: var(--warning-bg);
}

.status-error {
  color: var(--danger);
  background: var(--danger-bg);
}

/* ========================================
   Tables
   ======================================== */

.table-wrap {
  overflow-x: auto;
  margin: 0 -8px;
  padding: 0 8px;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 600px;
}

th, td {
  text-align: left;
  padding: 14px 12px;
  border-bottom: 1px solid var(--border-light);
  font-size: 0.875rem;
}

th {
  color: var(--text-muted);
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

tr:hover td {
  background: var(--bg-elevated);
}

tr:last-child td {
  border-bottom: none;
}

.filename-cell {
  font-weight: 500;
  color: var(--text-primary);
}

.empty-cell {
  text-align: center;
  color: var(--text-muted);
  font-style: italic;
  padding: 32px !important;
}

/* ========================================
   Badges
   ======================================== */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: capitalize;
}

.badge-high {
  background: var(--success-bg);
  color: #80e8a8;
  border: 1px solid rgba(64, 192, 112, 0.25);
}

.badge-medium {
  background: var(--warning-bg);
  color: #e8d880;
  border: 1px solid rgba(192, 160, 64, 0.25);
}

.badge-low {
  background: var(--danger-bg);
  color: #e88080;
  border: 1px solid rgba(201, 64, 64, 0.25);
}

/* ========================================
   Modal
   ======================================== */

.modal {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  animation: fadeIn 0.2s ease-out;
}

.modal.hidden {
  display: none !important;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 40, 20, 0.5);
  backdrop-filter: blur(4px);
}

.modal-panel {
  position: relative;
  width: min(900px, 94vw);
  max-height: 86vh;
  background: rgba(255, 255, 255, 0.98);
  backdrop-filter: blur(30px);
  -webkit-backdrop-filter: blur(30px);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  animation: modalSlideUp 0.3s ease-out;
}

.modal-header,
.modal-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.modal-header h3 {
  font-size: 1.15rem;
  font-family: var(--font-display);
}

.modal-table-wrap {
  max-height: 50vh;
  overflow: auto;
}

.chunk-content {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: 'DM Mono', 'Consolas', monospace;
  font-size: 0.8rem;
  line-height: 1.5;
  color: var(--text-secondary);
  background: var(--bg-elevated);
  padding: 12px;
  border-radius: var(--radius-sm);
  max-width: 500px;
}

/* ========================================
   Actions
   ======================================== */

.actions-inline {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

/* ========================================
   Custom Scrollbars
   ======================================== */

::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 999px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* ========================================
   Animations
   ======================================== */

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

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

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

@keyframes modalSlideUp {
  from {
    opacity: 0;
    transform: translateY(20px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

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

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

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 var(--primary-glow); }
  50% { box-shadow: 0 0 25px 8px var(--primary-glow); }
}

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ========================================
   Responsive Design
   ======================================== */

@media (max-width: 768px) {
  .topbar {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
    padding: 12px 16px;
  }

  .topbar-right {
    width: 100%;
    justify-content: flex-start;
  }

  .auth-container {
    padding: 32px 24px;
  }

  .logo-img {
    max-width: 200px;
  }

  .auth-title {
    font-size: 1.5rem;
  }

  .chat-layout {
    grid-template-columns: 1fr;
    padding: 16px;
    gap: 16px;
  }

  .chat-sidebar {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 280px;
    z-index: 100;
    transform: translateX(-100%);
    transition: transform 0.3s ease;
    padding-top: 60px;
  }

  .chat-sidebar.open {
    display: flex;
    transform: translateX(0);
  }

  .chat-message {
    max-width: 90%;
  }

  .summary-bar {
    grid-template-columns: 1fr;
  }

  .card {
    padding: 16px;
  }

  .modal-panel {
    padding: 16px;
  }

  th, td {
    padding: 10px 8px;
    font-size: 0.8rem;
  }
}

@media (max-width: 480px) {
  .btn {
    padding: 8px 12px;
    font-size: 0.8rem;
  }

  .actions {
    gap: 6px;
  }

  .chat-message {
    max-width: 95%;
    padding: 12px 14px;
  }

  .summary-card h2 {
    font-size: 1.75rem;
  }
}

/* Source attribution for ChatGPT-style UI */
.cgpt-source {
  margin-top: 16px;
  padding: 10px 14px;
  background: rgba(0, 0, 0, 0.05);
  border-radius: 8px;
  font-size: 13px;
  color: #6e6e80;
  display: flex;
  align-items: center;
  gap: 8px;
}

.cgpt-source svg {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}

.cgpt-message-content p {
  margin-bottom: 12px;
}

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

.cgpt-message-content ul,
.cgpt-message-content ol {
  margin: 12px 0;
  padding-left: 20px;
}

.cgpt-message-content li {
  margin-bottom: 6px;
}

/* Loading skeleton for messages */
.cgpt-loading-messages {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 16px 0;
}

.cgpt-message-skeleton {
  height: 80px;
  background: linear-gradient(
    90deg,
    rgba(0, 160, 80, 0.05) 25%,
    rgba(0, 160, 80, 0.08) 50%,
    rgba(0, 160, 80, 0.05) 75%
  );
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.5s ease-in-out infinite;
  border-radius: var(--radius);
  border: 1px solid var(--border-light);
}

@keyframes skeleton-shimmer {
  0% {
    background-position: 200% 0;
  }
  100% {
    background-position: -200% 0;
  }
}

/* Typing indicator animation */
.cgpt-typing {
  display: flex;
  gap: 4px;
  padding: 8px 0;
}

.cgpt-typing span {
  width: 8px;
  height: 8px;
  background-color: var(--accent);
  border-radius: 50%;
  animation: typing-bounce 1.4s ease-in-out infinite;
}

.cgpt-typing span:nth-child(1) {
  animation-delay: 0s;
}

.cgpt-typing span:nth-child(2) {
  animation-delay: 0.2s;
}

.cgpt-typing span:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes typing-bounce {
  0%, 60%, 100% {
    transform: translateY(0);
  }
  30% {
    transform: translateY(-8px);
  }
}
