/* ============================================
   CHATGPT-INSPIRED DESIGN SYSTEM
   FlaskWebHook - Modern Chat Interface
   ============================================ */

/* ============================================
   CSS VARIABLES - Color Palette & Design Tokens
   ============================================ */

 :root {
  /* ChatGPT Color Palette */
  --bg-main: #ffffff;
  --bg-alt: #f7f7f8;
  --bg-sidebar: #1a1a1a;
  --bg-sidebar-hover: #2a2a2a;
  
  /* Glass Design Variables */
  --glass-sidebar-bg: rgba(26, 26, 26, 0.85);
  --glass-sidebar-border: rgba(255, 255, 255, 0.1);
  --glass-sidebar-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
  --sidebar-text: #ffffff;
  --sidebar-text-secondary: #f0f0f0;
  --glass-header-bg: rgba(255, 255, 255, 0.8);
  --glass-header-border: rgba(0, 0, 0, 0.1);
   --glass-header-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    --glass-input-bg: rgba(255, 255, 255, 0.92);
    --glass-input-border: rgba(15, 23, 42, 0.08);
    --glass-input-hover: rgba(0, 0, 0, 0.05);
   
  --text-primary: #0d0d0d;
  --text-secondary: #5a5a5a;
  --text-tertiary: #767676;
  
  --border-light: #e5e5e5;
  --border-medium: #d1d1d1;
  
  --message-user-bg: #f7f7f8;
    --message-assistant-bg: #ffffff;
    --btn-bg: #ffffff;
  --message-hover-bg: rgba(0, 0, 0, 0.015);
  
    --accent-primary: #0d966f;
    --accent-secondary: #2dd4bf;
    --accent-hover: #0b7a5a;
    --accent-warning: #f59e0b;
    --accent-danger: #ef4444;
  
  --input-border: #d1d5db;
  --input-focus: #0d966f;
  --focus-outline: #084c3a;
  
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
  
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  
   --transition-fast: 150ms ease;
   --transition-normal: 200ms ease;
   --transition-slow: 300ms ease;
   
   /* Bootstrap variable mapping */
   --bs-body-bg: var(--bg-main);
   --bs-body-color: var(--text-primary);
   --bs-border-color: var(--border-light);
 }

 [data-bs-theme="dark"] {
  /* ChatGPT Color Palette - Dark Mode */
  --bg-main: #0f0f0f;
  --bg-alt: #1a1a1a;
  --bg-sidebar: #1a1a1a;
  --bg-sidebar-hover: #2a2a2a;
   
  /* Glass Design Variables - Dark Mode */
  --glass-sidebar-bg: rgba(26, 26, 26, 0.95);
  --glass-sidebar-border: rgba(255, 255, 255, 0.15);
  --glass-sidebar-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
   --sidebar-text: #ffffff;
   --sidebar-text-secondary: #f0f0f0;
  --glass-header-bg: rgba(15, 15, 15, 0.8);
  --glass-header-border: rgba(255, 255, 255, 0.15);
   --glass-header-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    --glass-input-bg: rgba(15, 15, 15, 0.8);
    --glass-input-border: rgba(255, 255, 255, 0.1);
    --glass-input-hover: rgba(255, 255, 255, 0.1);
    
  --text-primary: #e5e5e5;
   --text-secondary: #c0c0c0;
   --text-tertiary: #b0b0b0;
   
  --border-light: #2a2a2a;
  --border-medium: #3a3a3a;
   
   --message-user-bg: #1a1a1a;
   --message-assistant-bg: #0f0f0f;
   --btn-bg: #1a1a1a;
   --message-hover-bg: rgba(255, 255, 255, 0.05);
   
  --accent-primary: #10a37f;
  --accent-secondary: #2dd4bf;
  --accent-hover: #0e9070;
  --accent-warning: #f59e0b;
  --accent-danger: #ef4444;
    
    --input-border: #3a3a3a;
    --input-focus: #2dd4bf;
    --focus-outline: #2dd4bf;
    
   --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.3);
   --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4);
   --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.5);
   
   /* Bootstrap variable mapping for dark mode */
   --bs-body-bg: var(--bg-main);
   --bs-body-color: var(--text-primary);
   --bs-border-color: var(--border-light);
 }
 
/* ============================================
   ACCENT COLOR THEMES - Color Theory Based
   ============================================ */

/* Blue Accent Theme - Calming & Professional */
[data-accent="blue"] {
  --accent-primary: #2563eb;
  --accent-hover: #1d4ed8;
  --input-focus: #2563eb;
  --focus-outline: #1e40af;
  --bs-primary: var(--accent-primary);
  --bs-primary-rgb: 37, 99, 235;
}

[data-bs-theme="dark"][data-accent="blue"] {
  --accent-primary: #3b82f6;
  --accent-hover: #60a5fa;
  --input-focus: #3b82f6;
  --focus-outline: #93c5fd;
  --bs-primary: var(--accent-primary);
  --bs-primary-rgb: 59, 130, 246;
}

/* Purple Accent Theme - Creative & Modern */
[data-accent="purple"] {
  --accent-primary: #7c3aed;
  --accent-hover: #6d28d9;
  --input-focus: #7c3aed;
  --focus-outline: #5b21b6;
  --bs-primary: var(--accent-primary);
  --bs-primary-rgb: 124, 58, 237;
}

[data-bs-theme="dark"][data-accent="purple"] {
  --accent-primary: #8b5cf6;
  --accent-hover: #a78bfa;
  --input-focus: #8b5cf6;
  --focus-outline: #c4b5fd;
  --bs-primary: var(--accent-primary);
  --bs-primary-rgb: 139, 92, 246;
}

/* Amber Accent Theme - Warm & Energetic */
[data-accent="amber"] {
  --accent-primary: #f59e0b;
  --accent-hover: #d97706;
  --input-focus: #f59e0b;
  --focus-outline: #b45309;
  --bs-primary: var(--accent-primary);
  --bs-primary-rgb: 245, 158, 11;
}

[data-bs-theme="dark"][data-accent="amber"] {
  --accent-primary: #fbbf24;
  --accent-hover: #fcd34d;
  --input-focus: #fbbf24;
  --focus-outline: #fde68a;
  --bs-primary: var(--accent-primary);
  --bs-primary-rgb: 251, 191, 36;
}
/* Teal Accent Theme (Default) */
[data-accent="teal"] {
  --accent-primary: #0d966f;
  --accent-hover: #0b7a5a;
  --input-focus: #0d966f;
  --focus-outline: #084c3a;
  --bs-primary: var(--accent-primary);
  --bs-primary-rgb: 13, 150, 111;
}

[data-bs-theme="dark"][data-accent="teal"] {
  --accent-primary: #10a37f;
  --accent-hover: #0e9070;
  --input-focus: #2dd4bf;
  --focus-outline: #2dd4bf;
  --bs-primary: var(--accent-primary);
  --bs-primary-rgb: 16, 163, 127;
}

/* ============================================
   BASE STYLES
   ============================================ */

* {
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ============================================
   ACCESSIBILITY: FOCUS STATES
   ============================================ */

/* Global focus styles for keyboard navigation */
:focus-visible {
  outline: 2px solid var(--focus-outline);
  outline-offset: 2px;
  border-radius: 2px;
}

/* Remove default focus outline for mouse users */
:focus:not(:focus-visible) {
  outline: none;
}

/* Enhanced focus for interactive elements */
button:focus-visible,
a:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible,
[role="button"]:focus-visible {
  outline: 2px solid var(--focus-outline);
  outline-offset: 2px;
  box-shadow: 0 0 0 4px rgba(16, 163, 127, 0.2);
}



/* ============================================
   SCROLLBAR STYLING
   ============================================ */

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

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

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

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

/* Chat messages scrollbar - cleaner look */
.chat-messages::-webkit-scrollbar {
  width: 6px;
}

.chat-messages::-webkit-scrollbar-thumb {
  background: var(--border-light);
}

/* ============================================
   CHAT WRAPPER - Main Container
   ============================================ */

.chat-wrapper {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 64px);
  background: var(--bg-alt);
  position: relative;
  max-width: 960px;
  margin: 0 auto;
  width: 100%;
  overflow-x: hidden;
}

/* ============================================
   MESSAGES CONTAINER
   ============================================ */

.chat-messages {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  overflow-anchor: none;
  padding: 0 clamp(12px, 4vw, 32px) 120px;
  scroll-behavior: auto;
  touch-action: manipulation;
}

/* ============================================
   MESSAGE ROWS
   ============================================ */

.message-row {
  width: 100%;
  padding: 18px 0;
  border-bottom: 1px solid transparent;
  transition: background-color var(--transition-fast), transform var(--transition-fast);
  content-visibility: auto;
  contain-intrinsic-size: auto 100px;
}

.message-row + .message-row {
  margin-top: 4px;
}

.message-user {
  background-color: transparent;
}

.message-assistant {
  background-color: transparent;
}

.message-row:hover {
  background-color: var(--message-hover-bg);
  transform: translateY(-2px);
}

.message-row .message-content-wrapper {
  background: var(--message-assistant-bg);
  border: 1px solid rgba(15, 23, 42, 0.06);
  box-shadow: var(--shadow-md);
}

.message-row.message-user .message-content-wrapper {
  background: var(--message-user-bg);
  border-color: rgba(15, 23, 42, 0.08);
}

.message-row.message-assistant .message-content-wrapper {
  border-color: rgba(16, 163, 127, 0.12);
}

/* Message fade-in animation */
.message-row {
  animation: message-fade-in 0.3s ease-out;
}

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

/* ============================================
   MESSAGE CONTENT WRAPPER (Modern Layout)
   ============================================ */

.message-content-wrapper {
  max-width: 768px;
  margin: 0 auto;
  padding: 0 clamp(12px, 4vw, 32px);
  display: flex;
  gap: 16px;
  align-items: flex-start;
  border-radius: 18px;
  padding-block: clamp(16px, 3vw, 24px);
}

/* ============================================
   MESSAGE AVATARS (Circular)
   ============================================ */

.message-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 18px;
  color: white;
  background: rgba(15, 23, 42, 0.08);
}

.message-user .message-avatar {
  background: linear-gradient(135deg, #6366f1 0%, #a855f7 100%);
}

.message-assistant .message-avatar img {
  height: 32px;
  width: 32px;
  border-radius: 50%;
}

/* ============================================
   MESSAGE CONTENT (Modern Layout)
   ============================================ */

.message-content {
  flex: 1;
  min-width: 0;
  position: relative;
  color: var(--text-primary);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.message-header {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 2px;
}

.message-username {
  font-weight: 600;
  font-size: 15px;
  color: var(--text-primary);
}

.message-timestamp {
  font-size: 12px;
  color: var(--text-tertiary);
  flex-shrink: 0;
}

.message-status {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 10px;
  margin-left: 8px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.message-status.sending {
  background: rgba(59, 130, 246, 0.15);
  color: #3b82f6;
}

.message-status.streaming {
  background: rgba(16, 163, 127, 0.15);
  color: var(--accent-primary);
  animation: pulse 1.5s ease-in-out infinite;
}

.message-status.complete {
  background: rgba(34, 197, 94, 0.15);
  color: #22c55e;
}

.message-status i {
  font-size: 10px;
  line-height: 1;
  vertical-align: middle;
}

.message-body {
  color: var(--text-primary);
  font-size: clamp(15px, 1.15vw, 17px);
  line-height: 1.7;
}

.message-body > p {
  margin: 0 0 10px 0;
  line-height: 1.7;
  color: var(--text-primary);
}

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

 .message-body img {
   max-width: 100%;
   height: auto;
   border-radius: var(--radius-sm);
   border: 1px solid var(--border-light);
   margin: 0.5rem 0;
   transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
 }
 .message-body img:hover {
   border-color: var(--accent-primary);
   box-shadow: 0 0 0 2px rgba(13, 150, 111, 0.1);
 }

/* ============================================
   MESSAGE ACTIONS (Copy button, etc.)
   ============================================ */

.message-actions {
  opacity: 0;
  display: flex;
  gap: 8px;
  margin-top: 8px;
  transition: opacity var(--transition-normal), transform var(--transition-normal);
  transform: translateY(6px);
}

.message-row:hover .message-actions,
.message-row:focus-within .message-actions {
  opacity: 1;
  transform: translateY(0);
}

.action-btn {
  padding: 6px 12px;
   border: 1px solid rgba(15, 23, 42, 0.08);
   background: var(--btn-bg);
   border-radius: 999px;
  color: var(--text-secondary);
  font-size: 13px;
  cursor: pointer;
  transition: all var(--transition-fast);
  display: flex;
  align-items: center;
  gap: 6px;
  backdrop-filter: blur(4px);
}

.action-btn:hover {
  background: rgba(15, 23, 42, 0.05);
  border-color: rgba(15, 23, 42, 0.2);
  color: var(--text-primary);
}

.action-btn i {
  font-size: 12px;
}

/* Message edit button */
.edit-message-btn {
  color: var(--text-secondary);
  background: transparent;
  border: 1px solid transparent;
  transition: all var(--transition-fast);
}

.edit-message-btn:hover {
  color: var(--accent-primary);
  border-color: rgba(var(--accent-primary-rgb, 59, 130, 246), 0.2);
  background: rgba(var(--accent-primary-rgb, 59, 130, 246), 0.05);
}

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

.edit-message-btn .fa-edit {
  margin-right: 4px;
}

/* Message delete button */
.delete-message-btn {
  color: var(--text-secondary);
  background: transparent;
  border: 1px solid transparent;
  transition: all var(--transition-fast);
}

.delete-message-btn:hover {
  color: #dc3545;
  border-color: rgba(220, 53, 69, 0.2);
  background: rgba(220, 53, 69, 0.05);
}

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

.delete-message-btn .fa-trash {
  margin-right: 4px;
}

/* ============================================
   CHAT INPUT AREA (Sticky Bottom)
   ============================================ */

.chat-input-area {
  position: sticky;
  bottom: 0;
  background: transparent;
  padding: 20px clamp(12px, 4vw, 32px) calc(env(safe-area-inset-bottom, 0px) + 24px);
  z-index: 20;
  touch-action: manipulation;
}

@media (max-width: 640px) {
  .chat-input-area {
    padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 16px);
  }

  .chat-dock {
    gap: 8px;
    padding: 10px;
  }

  .chat-dock-bar {
    flex-wrap: nowrap;
    gap: 8px;
  }

  .chat-dock-meta {
    flex: 1;
    gap: 6px;
    justify-content: flex-start;
  }

  .chat-dock-actions {
    flex-shrink: 0;
    justify-content: flex-end;
    gap: 6px;
  }

  .meta-pill {
    font-size: 11px;
    padding: 4px 8px;
    min-width: 70px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex-shrink: 0;
  }

  .ghost-icon-btn,
  .meta-icon-btn {
    width: 34px;
    height: 34px;
  }

  .send-button {
    width: 40px;
    height: 40px;
  }

  #elapsed-time,
  #token-status,
  #dock-export-btn,
  #clear-chat {
    display: none !important;
  }
}

.chat-input-wrapper {
  max-width: 820px;
  margin: 0 auto;
  width: 100%;
}

/* ============================================
   INPUT CONTAINER
   ============================================ */

.chat-dock {
  width: 100%;
   background: var(--glass-input-bg);
  border-radius: 18px;
  padding: 14px;
  box-shadow: 0 12px 30px rgba(15, 23, 42, 0.08);
   backdrop-filter: blur(12px);
   border: 1px solid var(--glass-input-border);
   display: flex;
  flex-direction: column;
  gap: 12px;
  position: relative;
}


.chat-dock-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.chat-dock-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  flex: 1;
}

.meta-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-secondary);
  background: var(--bg-alt);
}

.meta-icon-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid rgba(15, 23, 42, 0.08);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  background: transparent;
}

.meta-icon-btn i {
  font-size: 14px;
}

.meta-icon-btn.token-personal {
  color: var(--accent-primary);
  border-color: rgba(16, 163, 127, 0.3);
}

.meta-icon-btn.token-shared {
  color: #d97706;
  border-color: rgba(217, 119, 6, 0.2);
}

.streaming-pill {
  color: var(--accent-primary);
  background: rgba(16, 163, 127, 0.15);
  border: 1px solid rgba(16, 163, 127, 0.3);
  padding: 6px;
  border-radius: 20px;
  font-weight: 600;
  font-size: 0.875rem;
  display: inline-flex;
  align-items: center;
  gap: 0;
  animation: pulse 1.5s ease-in-out infinite;
}

.streaming-pill i {
  font-size: 0.875rem;
}

.stop-pill {
  color: #dc2626;
  background: rgba(220, 38, 38, 0.15);
  border: 1px solid rgba(220, 38, 38, 0.3);
  padding: 6px 12px;
  border-radius: 20px;
  font-weight: 600;
  font-size: 0.875rem;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  transition: background var(--transition-fast);
}

.stop-pill:hover {
  background: rgba(220, 38, 38, 0.25);
}

.stop-pill.cancelling {
  background: rgba(245, 158, 11, 0.25);
  border-color: rgba(245, 158, 11, 0.4);
  color: #d97706;
}

.stop-pill.cancelling:hover {
  background: rgba(245, 158, 11, 0.35);
}

.stop-pill .stop-btn-text {
  font-size: 0.8rem;
}

.force-clear-btn {
  color: #d97706;
  background: rgba(245, 158, 11, 0.15);
  border: 1px solid rgba(245, 158, 11, 0.3);
  padding: 6px 12px;
  border-radius: 20px;
  font-weight: 600;
  font-size: 0.875rem;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  transition: background var(--transition-fast);
}

.force-clear-btn:hover {
  background: rgba(245, 158, 11, 0.25);
}

.elapsed-pill {
  color: #6b7280;
  background: rgba(107, 114, 128, 0.1);
  border: 1px solid rgba(107, 114, 128, 0.2);
  padding: 6px 10px;
  border-radius: 20px;
  font-weight: 500;
  font-size: 0.75rem;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.input-container {
  position: relative;
  display: flex;
  align-items: flex-end;
  gap: 12px;
  background: transparent;
  border: 1px solid var(--input-border);
  border-radius: var(--radius-lg);
  padding: 12px 16px;
  box-shadow: none;
  transition: border-color var(--transition-normal), box-shadow var(--transition-normal);
}

.input-container:focus-within {
  border-color: var(--input-focus);
  box-shadow: 0 10px 25px rgba(16, 163, 127, 0.12);
}

/* ============================================
   TEXTAREA
   ============================================ */

.chat-textarea {
  flex: 1;
  border: none;
  outline: none;
  resize: none;
  font-size: clamp(15px, 1.2vw, 16px);
  line-height: 1.5;
  color: var(--text-primary);
  background: transparent;
  max-height: 200px;
  overflow-y: auto;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  min-height: 24px;
}

.chat-textarea::placeholder {
  color: var(--text-tertiary);
}

/* ============================================
   SEND BUTTON
   ============================================ */

.send-button {
  width: 44px;
  height: 44px;
  border: none;
  background: var(--accent-primary);
  color: white;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform var(--transition-fast), background var(--transition-fast);
  flex-shrink: 0;
  box-shadow: 0 10px 20px rgba(16, 163, 127, 0.3);
}

.send-button:hover:not(:disabled) {
  background: var(--accent-hover);
  transform: scale(1.05);
}

.send-button:active:not(:disabled) {
  transform: scale(0.95);
}

.send-button:disabled {
  background: var(--border-medium);
  cursor: not-allowed;
  opacity: 0.5;
  box-shadow: none;
}

.send-button i {
  font-size: 14px;
}

/* ============================================
   INPUT FOOTER
   ============================================ */

.chat-dock-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  flex-shrink: 0;
  align-items: center;
}


.chat-dock-bar + .input-container {
  margin-top: 4px;
}

.ghost-icon-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid rgba(15, 23, 42, 0.08);
  background: transparent;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
}

.ghost-icon-btn:hover:not(:disabled) {
  color: var(--text-primary);
  border-color: rgba(15, 23, 42, 0.2);
  background: rgba(15, 23, 42, 0.04);
}

.ghost-icon-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}



@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* ============================================
   WELCOME MESSAGE
   ============================================ */

.welcome-message {
  max-width: 640px;
  margin: 24px auto 48px;
  padding: 0 24px;
  text-align: center;
  background: var(--message-assistant-bg);
  border-radius: 20px;
  padding: clamp(24px, 6vw, 40px);
  box-shadow: 0 30px 60px rgba(15, 23, 42, 0.08);
}

.welcome-message h2 {
  font-size: 24px;
  color: var(--text-primary);
  margin-bottom: 12px;
  font-weight: 600;
}

.welcome-message p {
  font-size: 16px;
  color: var(--text-secondary);
  line-height: 1.6;
  margin-bottom: 8px;
}

/* ============================================
   TYPING INDICATOR
   ============================================ */

.typing-indicator {
  display: inline-flex;
  gap: 6px;
  padding: 4px 0;
  background: rgba(15, 23, 42, 0.03);
  border-radius: 999px;
  padding: 6px 12px;
}

.typing-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-tertiary);
  animation: typing-bounce 1.4s infinite ease-in-out;
}

.typing-dot:nth-child(1) { animation-delay: 0s; }
.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }

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

/* ============================================
    STREAMING CURSOR
    ============================================ */

/* Simplified streaming styles to prevent blinking */
.streaming-raw-wrapper {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.streaming-textarea {
  width: 100%;
  min-height: min(50vh, 320px);
  resize: vertical;
  border: 1px solid var(--border-light);
  border-radius: 12px;
  padding: 12px;
  background: var(--bg-main);
  color: var(--text-primary);
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  font-size: 15px;
  line-height: 1.6;
  box-shadow: inset 0 1px 2px rgba(15, 23, 42, 0.08);
}

.streaming-textarea:focus {
  outline: none;
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 2px rgba(16, 163, 127, 0.2);
}

.streaming-progress {
  position: relative;
  height: 6px;
  margin-top: 8px; /* Reduced space since token counter removed */
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.08);
}

.streaming-progress-bar {
  position: absolute;
  inset: 0;
  width: 0%;
  border-radius: inherit;
  background: var(--accent-primary);
  transition: width 0.3s ease, background-color 0.3s ease;
}

.streaming-progress-bar.token-low {
  background: var(--accent-primary);
}

.streaming-progress-bar.token-medium {
  background: var(--accent-warning);
}

.streaming-progress-bar.token-high {
  background: var(--accent-danger);
}



@media (max-width: 640px) {
  .streaming-progress {
    margin-top: 6px;
  }
}

/* Cursor blink animation removed to prevent any potential blinking issues */


/* ============================================
    HEADER STYLING
    ============================================ */


.app-main {
  background: var(--bg-main);
}

.app-header {
  background: var(--glass-header-bg) !important;
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border-bottom: 1px solid var(--glass-header-border);
  box-shadow: var(--glass-header-shadow);
  padding: 1rem 1.5rem;
}

body[data-bs-theme="dark"] .app-header {
  background-color: #1a1a1a !important;
  background: var(--glass-header-bg, rgba(15, 15, 15, 0.8)) !important;
  border-bottom-color: var(--glass-header-border, rgba(255, 255, 255, 0.15)) !important;
}

header h2 {
  color: var(--text-primary);
  font-weight: 600;
}

.header-row {
  gap: 1rem;
}

.header-actions {
  gap: 1rem;
}

.header-actions > * + * {
  margin-left: 1rem;
}



@media (max-width: 768px) {
  .conversation-title {
    display: none;
  }

  .header-row {
    flex-wrap: wrap;
  }

  .header-actions {
    width: 100%;
    justify-content: space-between;
    gap: 0.75rem;
  }

  .header-webhook {
    flex: 1;
  }


}

#webhook-selector {
  background: var(--glass-input-bg);
  border: 1px solid var(--glass-header-border);
  border-radius: var(--radius-sm);
  padding: 8px 32px 8px 12px;
  font-size: 14px;
  color: var(--text-primary);
  transition: all var(--transition-fast);
}

#webhook-selector:focus {
  outline: none;
  border-color: var(--input-focus);
  box-shadow: 0 0 0 3px rgba(16, 163, 127, 0.1);
}
#theme-toggle {
  background: var(--glass-input-bg);
  border: 1px solid var(--glass-header-border);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  font-size: 14px;
  color: var(--text-primary);
  transition: all var(--transition-fast);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

#theme-toggle:hover {
  background: var(--glass-input-hover);
  border-color: var(--input-focus);
}

#theme-toggle:focus {
  outline: none;
  border-color: var(--input-focus);
  box-shadow: 0 0 0 3px rgba(16, 163, 127, 0.1);
}

#new-chat-button {
  background: var(--glass-input-bg);
  border: 1px solid var(--glass-header-border);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  font-size: 14px;
  color: var(--text-primary);
  transition: all var(--transition-fast);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

#new-chat-button:hover {
  background: var(--glass-input-hover);
  border-color: var(--input-focus);
}

#new-chat-button:focus {
  outline: none;
  border-color: var(--input-focus);
  box-shadow: 0 0 0 3px rgba(16, 163, 127, 0.1);
}

/* ============================================
   SIDEBAR ENHANCEMENTS
   ============================================ */

.app-sidebar {
  width: 264px;
  background: var(--glass-sidebar-bg);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border-right: 1px solid var(--glass-sidebar-border);
  box-shadow: var(--glass-sidebar-shadow);
  transition: width var(--transition-normal), transform var(--transition-normal);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
}

.sidebar-inner {
  display: flex;
  flex-direction: column;
  height: 100%;
  padding: 1.5rem 1.25rem;
  gap: 1.5rem;
}

.sidebar-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--glass-sidebar-border);
}

.sidebar-logo {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.08);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08);
}

.sidebar-logo-img {
  width: 28px;
  height: 28px;
  border-radius: 8px;
}

.sidebar-title {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--sidebar-text);
}

.sidebar-subtitle {
  font-size: 0.85rem;
  color: var(--sidebar-text);
}

.sidebar-actions {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.sidebar-cta {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.85rem;
  border-radius: var(--radius-md);
  font-weight: 600;
  transition: transform var(--transition-fast), box-shadow var(--transition-fast);
  border: 1px solid transparent;
}

.sidebar-cta i {
  font-size: 0.9rem;
}

.sidebar-cta:hover {
  transform: translateY(-1px);
  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.25);
}

.sidebar-cta-primary {
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  color: white;
  box-shadow: 0 15px 30px rgba(37, 99, 235, 0.3);
}

.sidebar-cta-secondary {
  background: rgba(255, 255, 255, 0.15);
  color: #ffffff;
  border-color: rgba(255, 255, 255, 0.3);
}

.sidebar-conversations {
  flex: 1;
  overflow-y: auto;
  padding-right: 0.25rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.sidebar-section {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.sidebar-section-title {
  text-transform: uppercase;
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  color: var(--sidebar-text);
}

.sidebar-list {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.sidebar-footer {
  margin-top: auto;
  padding-top: 1rem;
  border-top: 1px solid var(--glass-sidebar-border);
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.sidebar-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 0.95rem;
}

.sidebar-username {
  font-weight: 600;
  color: var(--sidebar-text);
}

.sidebar-role {
  font-size: 0.75rem;
  color: var(--sidebar-text);
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.sidebar-nav-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.65rem 0.85rem;
  border-radius: var(--radius-md);
  color: var(--sidebar-text);
  transition: background-color var(--transition-fast), color var(--transition-fast);
}

.sidebar-nav-link:hover,
.sidebar-nav-link:focus-visible {
  background: var(--bg-sidebar-hover);
  color: var(--sidebar-text);
}

.sidebar-nav-link i {
  font-size: 0.9rem;
}

.sidebar-nav-link span {
  font-size: 0.9rem;
  font-weight: 500;
}

.conversation-item {
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  color: var(--sidebar-text);
  transition: all var(--transition-fast);
  border: 1px solid transparent;
  background: rgba(255, 255, 255, 0.02);
}

.conversation-item:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--sidebar-text);
  border-color: rgba(255, 255, 255, 0.1);
}

.conversation-item.active {
  background: rgba(255, 255, 255, 0.12);
  color: var(--sidebar-text);
  border-left: 3px solid var(--accent-primary);
  border-color: rgba(255, 255, 255, 0.15);
}

.sidebar-nav-link.active {
  background: rgba(255, 255, 255, 0.14);
  color: var(--sidebar-text);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08);
}

/* Sidebar Close Button */
.sidebar-close-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: var(--sidebar-text);
  font-size: 1rem;
  transition: all var(--transition-fast);
  cursor: pointer;
  margin-left: auto;
  flex-shrink: 0;
}

.sidebar-close-btn:hover {
  background: rgba(255, 255, 255, 0.2);
  transform: scale(1.05);
}

.sidebar-close-btn:active {
  transform: scale(0.95);
}

/* Show close button only on mobile */
@media (max-width: 768px) {
  .sidebar-close-btn {
    display: flex;
  }
}

@media (min-width: 769px) {
  .sidebar-close-btn {
    display: none;
  }
}

/* ============================================
   MARKDOWN CONTENT STYLING
   ============================================ */

/* Paragraphs */
.message-body p {
  margin-bottom: 0.75rem;
  line-height: 1.75;
}

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

/* Headings */
.message-body h1,
.message-body h2,
.message-body h3,
.message-body h4 {
  margin-top: 1.25rem;
  margin-bottom: 0.75rem;
  font-weight: 600;
  line-height: 1.3;
  color: var(--text-primary);
}

.message-body h1 { font-size: 1.5rem; }
.message-body h2 { font-size: 1.25rem; }
.message-body h3 { font-size: 1.1rem; }
.message-body h4 { font-size: 1rem; }

/* Lists */
.message-body ul,
.message-body ol {
  margin-left: 1.5rem;
  margin-bottom: 0.75rem;
  line-height: 1.75;
}

.message-body ul {
  list-style-type: disc;
}

.message-body ol {
  list-style-type: decimal;
}

.message-body li {
  margin-bottom: 0.25rem;
}

.message-body li > ul,
.message-body li > ol {
  margin-top: 0.25rem;
  margin-bottom: 0.25rem;
}

/* Blockquotes */
.message-body blockquote {
  border-left: 4px solid var(--border-medium);
  padding-left: 1rem;
  margin-left: 0;
  margin-bottom: 0.75rem;
  color: var(--text-secondary);
  font-style: italic;
}

/* Inline code */
.message-body code {
  background-color: rgba(175, 184, 193, 0.2);
  padding: 0.2em 0.4em;
  border-radius: 4px;
  font-size: 0.9em;
  font-family: 'Monaco', 'Menlo', 'Consolas', 'Courier New', monospace;
  color: #c7254e;
}

/* Code blocks */
.message-body pre {
  background-color: #0f172a;
  border-radius: var(--radius-md);
  padding: 1rem;
  overflow-x: auto;
  margin: 1rem 0;
  position: relative;
}

.message-body pre code {
  background-color: transparent;
  padding: 0;
  font-size: 0.875rem;
  color: #e6edf3;
  font-family: 'Monaco', 'Menlo', 'Consolas', 'Courier New', monospace;
  line-height: 1.6;
}

/* Floating copy button inside code block */
.code-block-copy-btn {
  position: absolute;
  top: 12px;
  right: 12px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(15, 23, 42, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.25);
  color: #f5f5f5;
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 999px;
  cursor: pointer;
  transition: all var(--transition-fast);
  opacity: 0;
  backdrop-filter: blur(4px);
}

.message-body pre:hover .code-block-copy-btn,
.code-block-copy-btn:focus-visible,
.code-block-copy-btn.copied {
  opacity: 1;
}

.code-block-copy-btn:hover {
  background: rgba(255, 255, 255, 0.2);
  border-color: rgba(255, 255, 255, 0.35);
}

.code-block-copy-btn i {
  font-size: 11px;
}

.code-block-copy-btn.copied {
  background: var(--accent-primary);
  border-color: var(--accent-primary);
  color: white;
}

/* Code block header with language label */
.code-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #2d2d2d;
  padding: 8px 16px;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  margin: 1rem 0 0;
}

.code-language {
  font-size: 12px;
  color: #8e8e8e;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

.code-copy-btn {
  padding: 4px 12px;
  background: #3a3a3a;
  border: 1px solid #4a4a4a;
  color: #d1d1d1;
  border-radius: 4px;
  font-size: 12px;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.code-copy-btn:hover {
  background: #4a4a4a;
  color: white;
}

.code-copy-btn.copied {
  background: var(--accent-primary);
  border-color: var(--accent-primary);
  color: white;
}

/* Code block wrapper with header */
.code-block-wrapper {
  position: relative;
  margin: 1rem 0;
}

.code-block-wrapper pre {
  margin: 0;
  border-radius: 0 0 var(--radius-sm) var(--radius-sm);
}

/* Tables */
.message-body table {
  border-collapse: collapse;
  width: 100%;
  margin-bottom: 1rem;
  font-size: 0.9rem;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.message-body table th,
.message-body table td {
  border: 1px solid var(--border-light);
  padding: 0.5rem 0.75rem;
  text-align: left;
}

.message-body table th {
  background-color: var(--bg-alt);
  font-weight: 600;
  color: var(--text-primary);
}

.message-body table tr:nth-child(even) {
  background-color: var(--bg-alt);
}

/* Table scroll wrapper for horizontal overflow */
.table-scroll-wrapper {
  overflow-x: auto;
  max-width: 100%;
  margin-bottom: 1rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-light);
}

.table-scroll-wrapper::-webkit-scrollbar {
  height: 8px;
}

.table-scroll-wrapper::-webkit-scrollbar-track {
  background: var(--bg-alt);
  border-radius: 4px;
}

.table-scroll-wrapper::-webkit-scrollbar-thumb {
  background: var(--border-light);
  border-radius: 4px;
}

.table-scroll-wrapper::-webkit-scrollbar-thumb:hover {
  background: var(--accent-primary);
}

/* Links */
.message-body a {
  color: var(--accent-primary);
  text-decoration: none;
  transition: color var(--transition-fast);
}

.message-body a:hover {
  color: var(--accent-hover);
  text-decoration: underline;
}

/* Horizontal rules */
.message-body hr {
  border: none;
  border-top: 1px solid var(--border-light);
  margin: 1.5rem 0;
}

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

/* Emphasis/Italic */
.message-body em {
  font-style: italic;
}

/* ============================================
   EQUATION STYLING (MathJax)
   ============================================ */

.message-body .MathJax {
  font-size: 1.05em;
}

.message-body mjx-container[jax="CHTML"][display="true"] {
  margin: 1rem 0;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 0.5rem 0;
  text-align: left;
}

.message-body mjx-container[jax="CHTML"][display="true"] > mjx-math {
  text-align: left;
}

/* ============================================
   PROFILE PAGE STYLING
   ============================================ */

.profile-page .bg-white {
  background: rgba(255, 255, 255, 0.8);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.profile-page .bg-green-50,
.profile-page .bg-yellow-50,
.profile-page .bg-blue-50,
.profile-page .bg-purple-50 {
  background: rgba(255, 255, 255, 0.6);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.profile-page #n8n_token {
  background: rgba(255, 255, 255, 0.9);
}

.profile-page .bg-blue-600 {
  background: rgba(37, 99, 235, 0.8);
}
.profile-page .bg-blue-600:hover {
  background: rgba(37, 99, 235, 1);
}

.profile-page .bg-purple-600 {
  background: rgba(124, 58, 237, 0.8);
}
.profile-page .bg-purple-600:hover {
  background: rgba(124, 58, 237, 1);
}

.profile-page .bg-red-600 {
  background: rgba(220, 38, 38, 0.8);
}
.profile-page .bg-red-600:hover {
  background: rgba(220, 38, 38, 1);
}

/* ============================================
   LOGIN PAGE STYLING
   ============================================ */

.login-page .max-w-md {
  background: rgba(255, 255, 255, 0.8);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border-radius: var(--radius-lg);
  border: 1px solid rgba(255, 255, 255, 0.2);
  box-shadow: var(--glass-sidebar-shadow);
  padding: 2.5rem;
}

.login-page input[type="text"],
.login-page input[type="password"] {
  background: rgba(255, 255, 255, 0.9);
  border-color: rgba(0, 0, 0, 0.1);
}

.login-page input[type="text"]:focus,
.login-page input[type="password"]:focus {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px rgba(16, 163, 127, 0.1);
}

.login-page .bg-blue-600 {
  background: rgba(37, 99, 235, 0.8);
}
.login-page .bg-blue-600:hover {
  background: rgba(37, 99, 235, 1);
}

/* ============================================
   MOBILE RESPONSIVE
   ============================================ */

@media (max-width: 768px) {
  body {
    overflow-x: hidden;
  }
  
  main,
  .chat-wrapper {
    width: 100%;
    max-width: 100vw;
  }
  
  header {
    padding: 12px 16px 12px 60px;
  }
  
  header > div {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }
  
  #webhook-selector {
    flex: 1;
  }
  
  #sidebar-toggle {
    position: fixed;
    top: 12px;
    left: 12px;
    z-index: 1001;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-radius: 8px;
    padding: 8px;
    box-shadow: 0 10px 20px rgba(0,0,0,0.15);
    border: 1px solid rgba(0, 0, 0, 0.1);
  }
  
  .message-content-wrapper {
    padding: 0 16px;
    gap: 12px;
  }
  
  .chat-input-area {
    padding: 12px 16px calc(env(safe-area-inset-bottom, 0px) + 18px);
  }
  
  .chat-dock {
    padding: 12px;
    border-radius: 16px;
  }
  
  .chat-dock-meta {
    flex-direction: column;
    align-items: flex-start;
  }
  
  .ghost-icon-btn {
    width: 36px;
    height: 36px;
  }
  
  .message-row {
    padding: 14px 0;
  }
  
  .message-avatar {
    width: 32px;
    height: 32px;
  }
  
  .input-container {
    padding: 10px 12px;
  }
  
  .chat-textarea {
    font-size: 16px; /* Prevent iOS zoom on focus */
  }
  
  .message-body pre {
    font-size: 0.8rem;
  }
  
  aside,
  .app-sidebar {
    height: 100vh;
    top: 0;
    display: flex !important;
    flex-direction: column;
    touch-action: pan-y;
  }

  /* Sidebar inner padding adjustments for mobile */
  .sidebar-inner {
    padding-top: max(1.5rem, env(safe-area-inset-top, 0px));
    padding-bottom: max(1.5rem, env(safe-area-inset-bottom, 0px));
    padding-left: max(1.25rem, env(safe-area-inset-left, 0px));
    padding-right: max(1.25rem, env(safe-area-inset-right, 0px));
  }
}



@media (max-width: 480px) {
  .action-btn {
    padding: 4px 8px;
    font-size: 12px;
  }
  
  .send-button {
    width: 40px;
    height: 40px;
  }
  
  #webhook-selector {
    font-size: 13px;
    padding: 6px 24px 6px 10px;
  }
  
  header {
    padding: 8px 12px 8px 52px;
  }
  
  header > div {
    gap: 8px;
  }
  
  .chat-dock {
    gap: 8px;
  }
  
  .chat-dock-bar {
    flex-wrap: nowrap;
  }
  
  .chat-dock-meta {
    flex: 1;
    justify-content: flex-start;
  }
  
  .chat-dock-actions {
    flex-shrink: 0;
    justify-content: flex-end;
  }

  .meta-pill {
    min-width: 60px;
  }

  #elapsed-time,
  #token-status,
  #dock-export-btn,
  #clear-chat {
    display: none !important;
  }
}


/* ============================================
   UTILITY CLASSES
   ============================================ */

.hidden {
  display: none !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.skip-to-content {
  position: absolute;
  top: -40px;
  left: 0;
  background: var(--accent-primary);
  color: white;
  padding: 8px 16px;
  border-radius: 4px;
  text-decoration: none;
  z-index: 9999;
  opacity: 0;
  transition: top 0.2s, opacity 0.2s;
}

.skip-to-content:focus {
  top: 8px;
  opacity: 1;
  outline: 2px solid var(--focus-outline);
}

@media (max-width: 768px) {
  aside.hidden {
    display: flex !important;
    transform: translateX(-100%);
  }
}

.no-underline {
  text-decoration: none !important;
}

.loading-dots {
  display: inline-block;
}

.loading-dots::after {
  content: '.';
  animation: dots 1.5s steps(5, end) infinite;
}

@keyframes dots {
  0%, 20% { content: '.'; }
  40% { content: '..'; }
  60%, 100% { content: '...'; }
}

 .mw-md { max-width: 28rem; }

/* ============================================
   CONVERSATION ACTION BUTTONS
   ============================================ */

.conversation-action-btn {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all var(--transition-fast);
    opacity: 0.6;
    color: var(--sidebar-text);
    background: transparent;
    border: none;
    padding: 0;
    font-size: 12px;
}

.conversation-action-btn:hover {
    opacity: 1;
    background: rgba(255, 255, 255, 0.15);
    color: var(--sidebar-text);
    transform: scale(1.1);
}

.conversation-export-btn:hover {
    color: #34d399;
}

.conversation-hide-btn:hover {
    color: #f87171;
}

/* Mobile touch target improvements */
@media (max-width: 768px) {
    .conversation-item {
        padding: 16px 14px;
        min-height: 52px;
    }
    
    .conversation-action-btn {
        width: 32px;
        height: 32px;
        font-size: 14px;
    }
    
    .conversation-item .conversation-action-btn {
        opacity: 0.8;
    }
}

.conversation-item {
    transition: background-color var(--transition-fast);
}

 .conversation-item:hover .conversation-action-btn {
    opacity: 0.8;
}

/* ============================================
   NOTIFICATION TOASTS
   ============================================ */

.notification-toast {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 1050;
    max-width: 350px;
    box-shadow: var(--shadow-lg);
    border: none;
    opacity: 1;
    transition: opacity 0.3s ease;
}

 .notification-toast.fade-out {
    opacity: 0;
}

/* ============================================
   PROFILE PAGE SCROLLING
   ============================================ */

.profile-scrollable {
    height: calc(100vh - 64px);
    overflow-y: auto;
    padding-right: 0.5rem;
}

.profile-scrollable::-webkit-scrollbar {
    width: 6px;
}

 .profile-scrollable::-webkit-scrollbar-thumb {
    background: var(--border-light);
    border-radius: 3px;
}

/* ============================================
   ONBOARDING SETUP PAGE
   ============================================ */

.theme-toggle-btn {
    width: 2.5rem;
    height: 2.5rem;
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 5;
}

.setup-icon {
    width: 5rem;
    height: 5rem;
}

.strength-bar-container {
    height: 0.5rem;
}

.strength-bar {
    transition: all 0.3s ease;
}

/* ============================================
   SSE CONNECTION STATUS INDICATORS
   ============================================ */

.sse-status-indicator {
    display: inline-flex;
    align-items: center;
    gap: 0;
    font-size: 11px;
    padding: 2px 6px;
    border-radius: 10px;
    margin-left: 8px;
    font-weight: 500;
    transition: all 0.3s ease;
}

.sse-status-indicator i {
    font-size: 10px;
    line-height: 1;
}

.sse-status-indicator.connecting {
    background: rgba(59, 130, 246, 0.1);
    color: #3b82f6;
}

.sse-status-indicator.connected {
    background: rgba(34, 197, 94, 0.1);
    color: #22c55e;
}

.sse-status-indicator.reconnecting {
    background: rgba(245, 158, 11, 0.1);
    color: #f59e0b;
    animation: pulse 1.5s ease-in-out infinite;
}

.sse-status-indicator.completed {
    background: rgba(34, 197, 94, 0.1);
    color: #22c55e;
    opacity: 0.5;
}

.sse-status-indicator.error,
.sse-status-indicator.failed {
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* Dark mode adjustments */
[data-bs-theme="dark"] .sse-status-indicator.connecting {
    background: rgba(59, 130, 246, 0.2);
    color: #60a5fa;
}

[data-bs-theme="dark"] .sse-status-indicator.connected {
    background: rgba(34, 197, 94, 0.2);
    color: #4ade80;
}

[data-bs-theme="dark"] .sse-status-indicator.reconnecting {
    background: rgba(245, 158, 11, 0.2);
    color: #fbbf24;
}

[data-bs-theme="dark"] .sse-status-indicator.completed {
    background: rgba(34, 197, 94, 0.2);
    color: #4ade80;
}

[data-bs-theme="dark"] .sse-status-indicator.error,
[data-bs-theme="dark"] .sse-status-indicator.failed {
    background: rgba(239, 68, 68, 0.2);
    color: #f87171;
}

/* ============================================
   MOBILE-FIRST RESPONSIVE OVERRIDES
   ============================================ */

@media (max-width: 768px) {
  /* Flatter messages — remove card look */
  .message-row {
    padding: 14px 0 !important;
    border-bottom: 1px solid var(--border-light);
    animation: none !important;
  }
  .message-row:hover {
    transform: none !important;
  }
  .message-row .message-content-wrapper {
    border: none !important;
    box-shadow: none !important;
    border-radius: 0 !important;
    padding: 0 12px !important;
    background: transparent !important;
    gap: 10px;
  }
  .message-row.message-user .message-content-wrapper,
  .message-row.message-assistant .message-content-wrapper {
    border: none !important;
  }
  .message-avatar { width: 28px; height: 28px; font-size: 14px; }
  .message-avatar img { width: 22px; height: 22px; }
  .message-content { gap: 2px; }
  .message-header { margin-bottom: 0; }
  .message-username { font-size: 13px; }
  .message-timestamp { font-size: 11px; }
  .message-body { font-size: 15px; line-height: 1.6; }
  .message-actions { display: none !important; }

  /* Compact welcome */
  .welcome-message {
    padding: 20px 16px !important;
    margin: 12px auto 24px !important;
    box-shadow: none !important;
    border: 1px solid var(--border-light);
    border-radius: 12px;
  }
  .welcome-message h2 { font-size: 18px; }
  .welcome-message p { font-size: 14px; }

  /* Slim chat dock */
  .chat-dock {
    padding: 8px !important;
    gap: 4px !important;
    border-radius: 14px !important;
  }
  .chat-dock-bar {
    gap: 6px !important;
  }
  .chat-dock-meta {
    gap: 4px !important;
  }
  .chat-dock-actions {
    gap: 4px !important;
  }

  /* Smaller dock buttons */
  .ghost-icon-btn,
  .meta-icon-btn {
    width: 30px !important;
    height: 30px !important;
  }
  .ghost-icon-btn i,
  .meta-icon-btn i {
    font-size: 12px !important;
  }
  .meta-pill {
    font-size: 10px !important;
    padding: 3px 6px !important;
    min-width: auto !important;
  }
  .stop-pill { padding: 3px 8px !important; }
  .stop-pill .stop-btn-text { display: none; }
  .force-clear-btn .force-clear-btn-text { display: none; }

  /* Input area */
  .input-container {
    padding: 8px 10px !important;
    border-radius: 12px !important;
    gap: 8px !important;
  }
  .chat-textarea {
    font-size: 15px !important;
    max-height: 120px !important;
    min-height: 22px !important;
  }
  .send-button {
    width: 34px !important;
    height: 34px !important;
  }
  .send-button i { font-size: 12px !important; }

  /* Hide non-essential header elements */
  #dock-export-btn,
  #clear-chat { display: none !important; }
  #agentic-badge {
    font-size: 0 !important;
    padding: 0 4px !important;
  }
  #agentic-badge::before {
    content: "🤖";
    font-size: 15px;
  }
  #elapsed-time,
  #token-status { display: none !important; }

  /* Chat wrapper */
  .chat-wrapper {
    height: calc(100vh - 56px);
  }
  .chat-messages {
    padding: 0 8px 100px !important;
  }

  /* Sidebar: hidden by default, overlay on toggle */
  .app-sidebar {
    position: fixed !important;
    left: -280px;
    top: 0;
    bottom: 0;
    width: 280px;
    z-index: 1050;
    transition: left 0.25s ease;
    box-shadow: 4px 0 20px rgba(0,0,0,0.2);
  }
  .app-sidebar.sidebar-open {
    left: 0;
  }
  .app-sidebar.sidebar-open + .app-main::before {
    content: '';
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 1049;
  }
  .header-webhook .form-select {
    font-size: 13px;
    padding: 4px 24px 4px 8px;
    max-width: 140px;
  }

  /* Modal on mobile */
  dialog#rag-file-modal {
    width: 96% !important;
    max-height: 90vh !important;
    margin: 0 auto;
  }
  .upload-dropzone {
    padding: 24px 12px !important;
  }
  .upload-dropzone i { font-size: 32px; }
}

/* Extra small devices (<480px) */
@media (max-width: 480px) {
  .chat-messages {
    padding: 0 4px 90px !important;
  }
  .message-row {
    padding: 10px 0 !important;
  }
  .message-row .message-content-wrapper {
    padding: 0 8px !important;
    gap: 8px;
  }
  .chat-dock { padding: 6px !important; }
  .input-container { padding: 6px 8px !important; }
  .send-button { width: 30px !important; height: 30px !important; }

  /* Compact webhook selector on tiny screens */
  .header-webhook .form-select {
    font-size: 11px;
    padding: 3px 20px 3px 6px;
    max-width: 110px;
  }
  .header-webhook .position-absolute i { font-size: 10px; }

  /* Sidebar width */
  .app-sidebar { width: 260px; }
}

/* ============================================
   WIDE SCREEN FLUID SCALING
   ============================================ */

@media (min-width: 1400px) {
  .chat-wrapper {
    max-width: min(85%, 1400px) !important;
  }
  .message-content-wrapper {
    max-width: min(88%, 1000px);
  }
  .chat-input-wrapper {
    max-width: min(90%, 1100px);
  }
  .welcome-message {
    max-width: min(80%, 900px);
  }
}
