/* Modern Chat App Styles - Neuland Branding with Dark Mode */
:root {
  /* Neuland Brand Colors */
  --primary-color: #ea580c;
  --primary-dark: #c2410c;
  --primary-light: #fed7aa;
  --secondary-color: #f97316;
  --success-color: #107c10;
  --error-color: #d13438;
  --warning-color: #ff8c00;
  
  /* Light Mode Colors */
  --bg-primary: #ffffff;
  --bg-secondary: #f8f9fa;
  --bg-chat: linear-gradient(135deg, #fff7ed 0%, #f8f9fa 100%);
  --text-primary: #1f2937;
  --text-secondary: #6b7280;
  --text-muted: #9ca3af;
  --border-color: #e5e7eb;
  --bubble-bot-bg: #ffffff;
  --bubble-bot-text: #374151;
  --bubble-user-bg: #e9ebfa;
  --bubble-user-text: #374151;
  --input-bg: #ffffff;
  --shadow-light: rgba(0, 0, 0, 0.1);
  --shadow-medium: rgba(0, 0, 0, 0.15);
  
  /* Common */
  --card-shadow: 0 2px 8px var(--shadow-light);
  --border-radius: 8px;
  --transition: all 0.3s ease;
}

/* Dark Mode Variables */
[data-theme="dark"] {
  --bg-primary: #1f2937;
  --bg-secondary: #111827;
  --bg-chat: linear-gradient(135deg, #1f2937 0%, #111827 100%);
  --text-primary: #f9fafb;
  --text-secondary: #d1d5db;
  --text-muted: #9ca3af;
  --border-color: #374151;
  --bubble-bot-bg: #292929;
  --bubble-bot-text: #f3f4f6;
  --bubble-user-bg: #4f46e5;
  --bubble-user-text: #f9fafb;
  --input-bg: #374151;
  --shadow-light: rgba(0, 0, 0, 0.3);
  --shadow-medium: rgba(0, 0, 0, 0.4);
  --card-shadow: 0 2px 8px var(--shadow-medium);
}

/* Dark mode header override */
[data-theme="dark"] #greeting {
  background: #1f2937 !important;
  color: #f9fafb !important;
  border-bottom: 1px solid #374151 !important;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3) !important;
}

/* Dark mode theme toggle */
[data-theme="dark"] .theme-toggle {
  background: rgba(255, 255, 255, 0.1) !important;
  border: 1px solid rgba(255, 255, 255, 0.2) !important;
  color: white !important;
}

[data-theme="dark"] .theme-toggle:hover {
  background: rgba(255, 255, 255, 0.2) !important;
}

[data-theme="dark"] .theme-toggle .theme-icon {
  color: rgba(255, 255, 255, 0.8) !important;
}

[data-theme="dark"] .clear-history-btn {
  background: rgba(255, 255, 255, 0.1) !important;
  border: 1px solid rgba(255, 255, 255, 0.2) !important;
  color: white !important;
}

[data-theme="dark"] .clear-history-btn:hover {
  background: rgba(255, 255, 255, 0.2) !important;
}

/* Dark mode user name in header */
[data-theme="dark"] #greeting div[style*="color: #6b7280"] {
  color: rgba(255, 255, 255, 0.8) !important;
}

* {
  box-sizing: border-box;
}

html, body {
  height: 100vh;
  height: 100dvh; /* Better mobile viewport handling */
  margin: 0;
  padding: 0;
  font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, 'Roboto', 'Helvetica Neue', sans-serif;
  background: var(--bg-chat);
  color: var(--text-primary);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: var(--transition);
  -webkit-text-size-adjust: 100%; /* Prevent text scaling on iOS */
  -webkit-touch-callout: none; /* Disable iOS callout */
  -webkit-tap-highlight-color: transparent; /* Remove tap highlight */
  touch-action: manipulation; /* Improve touch response */
}

/* Smooth transitions for all elements */
* {
  transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease;
}

/* Loading Screen */
#loginStatus {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-chat);
  z-index: 1000;
}

.auth-card {
  background: var(--bg-primary);
  border-radius: 8px;
  padding: 2rem;
  box-shadow: var(--card-shadow);
  text-align: center;
  max-width: 400px;
  width: 90%;
  animation: slideInUp 0.6s ease-out;
  color: var(--text-primary);
}

.auth-card h2 {
  color: var(--primary-color);
  margin-bottom: 1rem;
  font-weight: 600;
}

.auth-card p {
  color: #666;
  margin-bottom: 2rem;
  line-height: 1.6;
}

/* Loading Animation */
.loading-spinner {
  width: 40px;
  height: 40px;
  border: 4px solid #fed7aa;
  border-top: 4px solid var(--primary-color);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 0 auto 1rem;
}

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

/* Main Container */
#container {
  flex: 1;
  display: none;
  flex-direction: column;
  width: 100%;
  max-width: 100vw;
  min-height: 0;
  animation: fadeIn 0.5s ease-in;
  overflow: hidden;
}

/* Header/Greeting */
#greeting {
  background: #ffffff;
  padding: 1.2rem 1.5rem;
  font-size: 1.3rem;
  font-weight: 600;
  color: #1f2937;
  text-align: left;
  flex-shrink: 0;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  border-bottom: 1px solid #e5e7eb;
  min-height: 60px;
  display: flex;
  align-items: center;
  position: relative;
  z-index: 100;
}

/* Chat Container */
#webchat {
  flex: 1;
  background: transparent;
  min-height: 0;
  overflow: hidden;
  position: relative;
  display: flex;
  flex-direction: column;
  padding: 1rem;
}

/* Custom Button Styles */
.btn {
  background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
  color: white;
  border: none;
  padding: 12px 24px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  transition: var(--transition);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(234, 88, 12, 0.3);
}

.btn:active {
  transform: translateY(0);
}

/* Error Styles */
.error-container {
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(20px);
  border-radius: var(--border-radius);
  padding: 2rem;
  margin: 2rem;
  box-shadow: var(--card-shadow);
  border-left: 4px solid var(--error-color);
  animation: slideInUp 0.5s ease-out;
}

.error-container h3 {
  color: var(--error-color);
  margin-top: 0;
  font-weight: 600;
}

.error-container p {
  color: #666;
  line-height: 1.6;
}

.error-container ol {
  color: #666;
  padding-left: 1.5rem;
}

.error-container ol li {
  margin-bottom: 0.5rem;
}

/* Success Message */
.success-message {
  background: rgba(16, 124, 16, 0.1);
  border: 1px solid var(--success-color);
  color: var(--success-color);
  padding: 1rem;
  border-radius: 8px;
  margin-bottom: 1rem;
  animation: slideInDown 0.5s ease-out;
}

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

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

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

/* Additional WebChat Responsive Fixes */
.webchat__send-box-send-button {
  background: #0078d4 !important;
  border: none !important;
  border-radius: 4px !important;
  margin-left: 0.5rem !important;
  padding: 0.5rem 1rem !important;
}

.webchat__send-box-send-button:hover {
  background: #005a9e !important;
}

/* Responsive Design */
@media (max-width: 768px) {
  .auth-card {
    padding: 1.5rem;
    margin: 1rem;
    width: calc(100% - 2rem);
    max-width: none;
  }
  
  #greeting {
    padding: 0.75rem 1rem;
    font-size: 1rem;
    min-height: 50px;
  }
  
  #greeting > div {
    flex-direction: column;
    align-items: flex-start !important;
    gap: 0.75rem;
  }
  
  #greeting > div > div:last-child {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    width: 100%;
    justify-content: flex-start;
  }
  
  .error-container {
    margin: 1rem;
    padding: 1.5rem;
  }
  
  .webchat__send-box {
    padding: 0.75rem 1rem !important;
  }
  
  .webchat__bubble {
    max-width: 85% !important;
  }
  
  #webchat {
    padding: 0.75rem;
  }
  
  .international-toggle {
    font-size: 11px;
    padding: 0.3rem 0.6rem;
    min-width: 85px;
  }
  
  .theme-toggle {
    font-size: 11px;
    padding: 0.3rem 0.6rem;
    min-width: 70px;
  }
  
  .clear-history-btn {
    font-size: 11px;
    padding: 0.3rem 0.6rem;
  }
}

@media (max-width: 480px) {
  body {
    font-size: 14px;
  }
  
  .auth-card {
    padding: 1rem;
    margin: 0.5rem;
    width: calc(100% - 1rem);
  }
  
  .auth-card h2 {
    font-size: 1.2rem;
  }
  
  #greeting {
    font-size: 0.9rem;
    padding: 0.6rem 0.8rem;
    min-height: 45px;
  }
  
  #greeting > div {
    flex-direction: column;
    align-items: flex-start !important;
    gap: 0.5rem;
  }
  
  #greeting > div > div:first-child {
    font-size: 0.9rem;
  }
  
  #greeting > div > div:first-child > div {
    font-size: 0.75rem;
    margin-top: 0.15rem;
  }
  
  #greeting > div > div:last-child {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 0.4rem;
    width: 100%;
  }
  
  .webchat__send-box {
    padding: 0.6rem 0.8rem !important;
  }
  
  .webchat__send-box-text-box {
    font-size: 14px !important;
    padding: 0.6rem 0.8rem !important;
    min-height: 36px !important;
  }
  
  .webchat__send-box-send-button {
    width: 36px !important;
    height: 36px !important;
  }
  
  .webchat__bubble {
    max-width: 90% !important;
    font-size: 14px !important;
  }
  
  #webchat {
    padding: 0.5rem;
  }
  
  .international-toggle {
    font-size: 10px;
    padding: 0.25rem 0.5rem;
    min-width: 75px;
  }
  
  .international-toggle .toggle-icon {
    font-size: 10px;
  }
  
  .theme-toggle {
    font-size: 10px;
    padding: 0.25rem 0.5rem;
    min-width: 60px;
  }
  
  .theme-toggle .theme-icon {
    font-size: 10px;
  }
  
  .clear-history-btn {
    font-size: 10px;
    padding: 0.25rem 0.5rem;
  }
  
  /* Citation modal mobile optimization */
  #citation-modal > div {
    max-width: 95vw !important;
    max-height: 90vh !important;
    margin: 1rem !important;
    padding: 1rem !important;
  }
  
  #citation-modal h3 {
    font-size: 1rem !important;
  }
}

/* WebChat Custom Overrides */
#webchat > div {
  height: 100% !important;
  display: flex !important;
  flex-direction: column !important;
  background: transparent !important;
}

.webchat__basic-transcript {
  flex: 1 !important;
  overflow-y: auto !important;
  padding: 0 !important;
  min-height: 0 !important;
  background: transparent !important;
}

.webchat__bubble {
  max-width: 75% !important;
  margin-bottom: 1rem !important;
  border-radius: 12px !important;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1) !important;
}

.webchat__bubble--from-user {
  background: var(--bubble-user-bg) !important;
  color: var(--bubble-user-text) !important;
}

.webchat__bubble--from-bot {
  background: var(--bubble-bot-bg) !important;
  border: 1px solid var(--border-color) !important;
  color: var(--bubble-bot-text) !important;
}

.webchat__send-box {
  flex-shrink: 0 !important;
  border: none !important;
  background: transparent !important;
  padding: 1rem 0 !important;
}

.webchat__send-box-text-box {
  border: 1px solid var(--border-color) !important;
  border-radius: 12px !important; /* Changed from 24px for better multi-line appearance */
  padding: 12px 16px !important;
  font-size: 14px !important;
  background: var(--input-bg) !important;
  color: var(--text-primary) !important;
  box-shadow: 0 1px 3px var(--shadow-light) !important;
  min-height: 40px !important;
  max-height: 120px !important;
  overflow-y: auto !important;
  white-space: pre-wrap !important;
  word-wrap: break-word !important;
  line-height: 1.4 !important;
}

/* Fix input text visibility in dark mode with more specific selectors */
.webchat__send-box-text-box input,
.webchat__send-box-text-box textarea,
.webchat__send-box-text-box[contenteditable] {
  color: var(--text-primary) !important;
  background: transparent !important;
}

/* Fix text wrapping in chat input */
.webchat__send-box-text-box,
.webchat__send-box-text-box input,
.webchat__send-box-text-box textarea,
.webchat__send-box-text-box[contenteditable] {
  white-space: pre-wrap !important;
  word-wrap: break-word !important;
  overflow-wrap: break-word !important;
  word-break: break-word !important;
}

/* Enable multi-line input for paragraph support */
.webchat__send-box-text-box {
  min-height: 40px !important;
  max-height: 120px !important;
  resize: none !important;
  overflow-y: auto !important;
}

/* Ensure proper line height for readability */
.webchat__send-box-text-box,
.webchat__send-box-text-box input,
.webchat__send-box-text-box textarea {
  line-height: 1.4 !important;
}

/* Fix text wrapping in chat bubbles */
.webchat__bubble,
.webchat__bubble__content {
  white-space: pre-wrap !important;
  word-wrap: break-word !important;
  overflow-wrap: break-word !important;
}

/* Fix placeholder text in dark mode */
.webchat__send-box-text-box input::placeholder,
.webchat__send-box-text-box textarea::placeholder {
  color: var(--text-muted) !important;
  opacity: 0.7 !important;
}

/* Additional WebChat input selectors */
.webchat__send-box .webchat__send-box-text-box__input {
  color: var(--text-primary) !important;
  background: transparent !important;
}

.webchat__send-box .webchat__send-box-text-box__input::placeholder {
  color: var(--text-muted) !important;
}

/* Mobile keyboard and input improvements */
@media (max-width: 768px) {
  .webchat__send-box-text-box {
    /* Ensure proper mobile keyboard interaction */
    resize: none !important;
    word-break: break-word !important;
    overflow-wrap: break-word !important;
  }
  
  /* Better touch scrolling for chat history */
  .webchat__basic-transcript {
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
  }
  
  /* Prevent page bounce on iOS */
  #container {
    overscroll-behavior: none;
    -webkit-overflow-scrolling: touch;
  }
}

.webchat__send-box-text-box:focus {
  border-color: var(--primary-color) !important;
  outline: none !important;
  box-shadow: 0 0 0 2px rgba(234, 88, 12, 0.2) !important;
}

/* Focus state for input elements inside */
.webchat__send-box-text-box:focus input,
.webchat__send-box-text-box:focus textarea,
.webchat__send-box-text-box:focus[contenteditable] {
  color: var(--text-primary) !important;
}

/* Comprehensive input text targeting for WebChat */
.webchat__send-box input[type="text"],
.webchat__send-box textarea,
.webchat__send-box [contenteditable="true"],
.webchat__send-box__input,
.webchat__send-box-main .webchat__send-box-text-box,
#webchat input,
#webchat textarea {
  color: var(--text-primary) !important;
  background: transparent !important;
}

/* Comprehensive placeholder targeting */
.webchat__send-box input[type="text"]::placeholder,
.webchat__send-box textarea::placeholder,
#webchat input::placeholder,
#webchat textarea::placeholder {
  color: var(--text-muted) !important;
  opacity: 0.7 !important;
}

.webchat__send-box-send-button {
  background: var(--primary-color) !important;
  border: none !important;
  border-radius: 50% !important;
  width: 40px !important;
  height: 40px !important;
  margin-left: 8px !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
}

.webchat__send-box-send-button:hover {
  background: var(--primary-dark) !important;
}

/* Login Section Styling */
.chat-login-section {
  background: white;
  border-radius: 12px;
  padding: 1.5rem;
  margin: 1rem 0;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  text-align: center;
}

.chat-login-button {
  background: var(--primary-color);
  color: white;
  border: none;
  border-radius: 8px;
  padding: 12px 24px;
  font-size: 16px;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  width: 100%;
  margin-top: 1rem;
}

.chat-login-button:hover {
  background: var(--primary-dark);
}

/* Feedback Buttons */
.feedback-buttons {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

.feedback-btn {
  background: transparent;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  padding: 6px 8px;
  cursor: pointer;
  font-size: 16px;
  transition: var(--transition);
}

.feedback-btn:hover {
  background: #f3f4f6;
}

/* Enhanced loading states */
.loading-text {
  background: linear-gradient(90deg, var(--primary-color), var(--secondary-color), var(--primary-color));
  background-size: 200% auto;
  background-clip: text;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  animation: shimmer 2s linear infinite;
  font-weight: 600;
}

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

/* Modern Button Styling */

/* International Context Toggle */
.international-toggle {
  background: #f3f4f6;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  padding: 0.4rem 0.8rem;
  font-size: 12px;
  cursor: pointer;
  color: #374151;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  transition: all 0.3s ease;
  min-width: 100px;
  justify-content: center;
  font-weight: 500;
}

.international-toggle:hover {
  background: #e5e7eb;
  border-color: #c1c9d2;
}

.international-toggle.active {
  background: linear-gradient(135deg, #10b981, #059669);
  border-color: #059669;
  color: white;
  box-shadow: 0 2px 8px rgba(16, 185, 129, 0.3);
}

.international-toggle.active:hover {
  background: linear-gradient(135deg, #059669, #047857);
}

.international-toggle .toggle-icon {
  font-size: 12px;
  font-weight: bold;
  transition: all 0.3s ease;
  color: #6b7280;
}

.international-toggle.active .toggle-icon {
  color: white;
}

.international-toggle .toggle-text {
  transition: all 0.3s ease;
}

/* Dark mode international toggle */
[data-theme="dark"] .international-toggle {
  background: rgba(255, 255, 255, 0.1) !important;
  border: 1px solid rgba(255, 255, 255, 0.2) !important;
  color: white !important;
}

[data-theme="dark"] .international-toggle:hover {
  background: rgba(255, 255, 255, 0.2) !important;
}

[data-theme="dark"] .international-toggle.active {
  background: linear-gradient(135deg, #10b981, #059669) !important;
  border-color: #059669 !important;
  color: white !important;
}

[data-theme="dark"] .international-toggle .toggle-icon {
  color: rgba(255, 255, 255, 0.8) !important;
}

[data-theme="dark"] .international-toggle.active .toggle-icon {
  color: white !important;
}

.theme-toggle {
  background: #f3f4f6;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  padding: 0.4rem 0.8rem;
  font-size: 12px;
  cursor: pointer;
  color: #374151;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  transition: all 0.3s ease;
  min-width: 80px;
  justify-content: center;
  font-weight: 500;
}

.theme-toggle:hover {
  background: #e5e7eb;
  border-color: #c1c9d2;
}

.theme-toggle .theme-icon {
  font-size: 12px;
  font-weight: bold;
  transition: all 0.3s ease;
  color: #6b7280;
}

.clear-history-btn {
  background: #f3f4f6;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  padding: 0.4rem 0.8rem;
  font-size: 12px;
  cursor: pointer;
  color: #374151;
  transition: all 0.3s ease;
  font-weight: 500;
}

.clear-history-btn:hover {
  background: #e5e7eb;
  border-color: #c1c9d2;
}

/* Animation for theme switch */
.theme-switching {
  pointer-events: none;
}

.theme-switching * {
  transition: all 0.5s cubic-bezier(0.4, 0, 0.2, 1) !important;
}

/* Subtle Drag and Drop Indication */
.drag-drop-overlay {
  position: absolute;
  top: 60px; /* Below the header */
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(234, 88, 12, 0.03); /* Very subtle background */
  border: 2px dashed transparent;
  border-radius: 12px;
  display: none; /* Hidden by default */
  z-index: 500; /* Lower z-index */
  pointer-events: none;
  transition: all 0.2s ease;
  margin: 1rem;
  align-items: center;
  justify-content: center;
}

/* Mobile drag and drop adjustments */
@media (max-width: 768px) {
  .drag-drop-overlay {
    top: 50px;
    margin: 0.75rem;
  }
  
  .drag-drop-content {
    font-size: 0.9rem;
  }
  
  .drag-drop-content .icon {
    font-size: 2.5rem;
  }
}

@media (max-width: 480px) {
  .drag-drop-overlay {
    top: 45px;
    margin: 0.5rem;
  }
  
  .drag-drop-content {
    font-size: 0.8rem;
  }
  
  .drag-drop-content .icon {
    font-size: 2rem;
  }
}

.drag-drop-overlay.active {
  display: flex;
  background: rgba(234, 88, 12, 0.05); /* Very subtle when active */
  border-color: rgba(234, 88, 12, 0.3); /* Subtle border */
}

/* Ensure container has relative positioning */
#container {
  position: relative;
  height: 100vh;
  display: flex;
  flex-direction: column;
}

.drag-drop-content {
  /* Hidden - we only want cursor indication */
  display: none !important;
}

.drag-drop-content .icon {
  font-size: 3rem;
  margin-bottom: 1rem;
  display: block;
  opacity: 0.8;
}

.drag-drop-content .text {
  margin-bottom: 0.5rem;
}

.drag-drop-content .subtext {
  font-size: 0.9rem;
  opacity: 0.7;
  font-weight: normal;
}

/* Removed dragPulse animation - keeping it subtle */

/* Enhanced drag states */
.chat-container {
  position: relative;
  transition: var(--transition);
}

.chat-container.drag-active {
  background: rgba(234, 88, 12, 0.02);
}

/* Primary drag indication via cursor */
#container.drag-active {
  cursor: copy !important;
  transition: background-color 0.2s ease;
}

#container.drag-active * {
  cursor: copy !important;
}

/* Very subtle background tint when dragging */
#container.drag-active #webchat {
  background: rgba(234, 88, 12, 0.02) !important;
  transition: background-color 0.2s ease;
}

/* Subtle drag indication - no animations needed */

/* Dark mode adjustments for drag overlay */
[data-theme="dark"] .drag-drop-content {
  background: var(--bg-secondary);
  color: var(--primary-color);
  border-color: var(--primary-color);
}

[data-theme="dark"] .drag-drop-overlay {
  background: rgba(234, 88, 12, 0.15);
}

/* Notification animations for drag and drop */
@keyframes slideInRight {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

@keyframes slideOutRight {
  from {
    transform: translateX(0);
    opacity: 1;
  }
  to {
    transform: translateX(100%);
    opacity: 0;
  }
}

/* Mobile-specific improvements */
@media (hover: none) and (pointer: coarse) {
  /* Touch device optimizations */
  .btn, .theme-toggle, .clear-history-btn, button {
    min-height: 44px; /* iOS minimum touch target */
    min-width: 44px;
  }
  
  .webchat__send-box-send-button {
    min-width: 44px !important;
    min-height: 44px !important;
    width: 44px !important;
    height: 44px !important;
  }
  
  /* Remove hover effects on touch devices */
  .btn:hover,
  .theme-toggle:hover,
  .clear-history-btn:hover,
  button:hover {
    transform: none;
    box-shadow: initial;
    background: initial;
  }
  
  /* Enhanced tap feedback */
  .btn:active,
  .theme-toggle:active,
  .clear-history-btn:active,
  button:active {
    transform: scale(0.95);
    transition: transform 0.1s ease;
  }
}

/* Landscape orientation adjustments for mobile */
@media (max-height: 500px) and (orientation: landscape) {
  #greeting {
    padding: 0.5rem 1rem;
    min-height: 40px;
    font-size: 0.85rem;
  }
  
  #greeting > div {
    flex-direction: row !important;
    align-items: center !important;
    gap: 1rem;
  }
  
  #greeting > div > div:last-child {
    flex-direction: row;
    gap: 0.5rem;
    width: auto;
  }
  
  .webchat__send-box {
    padding: 0.5rem 0.8rem !important;
  }
  
  .webchat__send-box-text-box {
    min-height: 32px !important;
    padding: 0.5rem 0.8rem !important;
  }
  
  .webchat__send-box-send-button {
    width: 32px !important;
    height: 32px !important;
  }
}

/* High DPI / Retina display optimizations */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
  .webchat__bubble {
    border-width: 0.5px !important;
  }
  
  .webchat__send-box-text-box {
    border-width: 0.5px !important;
  }
}

/* Safe area insets for devices with notches */
@supports (padding: max(0px)) {
  body {
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
  }
  
  #greeting {
    padding-left: max(1rem, env(safe-area-inset-left));
    padding-right: max(1rem, env(safe-area-inset-right));
  }
  
  .webchat__send-box {
    padding-left: max(1rem, env(safe-area-inset-left)) !important;
    padding-right: max(1rem, env(safe-area-inset-right)) !important;
    padding-bottom: max(1rem, env(safe-area-inset-bottom)) !important;
  }
}

/* iOS specific fixes */
@supports (-webkit-appearance: none) {
  .webchat__send-box-text-box {
    -webkit-appearance: none;
    appearance: none;
    border-radius: 12px !important;
  }
  
  /* Fix iOS zoom on input focus */
  .webchat__send-box-text-box input,
  .webchat__send-box-text-box textarea {
    font-size: 16px !important; /* Prevents zoom on iOS */
  }
}

/* File preview container styling */
.file-preview-container {
  transition: all 0.3s ease;
}

.file-preview-card {
  transition: all 0.3s ease;
}

.file-preview-card:hover {
  box-shadow: 0 2px 8px rgba(0,0,0,0.15) !important;
  transform: translateY(-1px);
}

.file-preview-card .remove-file:hover {
  background: rgba(0,0,0,0.1) !important;
  opacity: 1 !important;
}

/* Dark mode file preview */
[data-theme="dark"] .file-preview-card {
  background: var(--bg-secondary) !important;
  border-color: var(--border-color) !important;
  box-shadow: 0 1px 3px rgba(0,0,0,0.3) !important;
}

[data-theme="dark"] .file-preview-card:hover {
  box-shadow: 0 2px 8px rgba(0,0,0,0.4) !important;
}

[data-theme="dark"] .file-preview-card .remove-file:hover {
  background: rgba(255,255,255,0.1) !important;
}

/* Slide animations for file preview */
@keyframes slideOutDown {
  from {
    opacity: 1;
    transform: translateY(0);
  }
  to {
    opacity: 0;
    transform: translateY(20px);
  }
}

/* Fix WebChat markdown formatting and spacing */
.webchat__render-markdown p {
  margin-bottom: 1rem !important;
  line-height: 1.5 !important;
}

.webchat__render-markdown ol,
.webchat__render-markdown ul {
  margin: 1rem 0 !important;
  padding-left: 1.5rem !important;
}

.webchat__render-markdown li {
  margin-bottom: 0.5rem !important;
  line-height: 1.4 !important;
}

.webchat__render-markdown li p {
  margin-bottom: 0.5rem !important;
  margin-top: 0 !important;
}

.webchat__render-markdown li ul,
.webchat__render-markdown li ol {
  margin-top: 0.5rem !important;
  margin-bottom: 0.5rem !important;
}

.webchat__render-markdown strong {
  font-weight: 600 !important;
}

/* Ensure proper text wrapping */
.webchat__render-markdown {
  white-space: normal !important;
  word-wrap: break-word !important;
  overflow-wrap: break-word !important;
}

/* Hide WebChat reference/citation sections */
.webchat__link-definitions,
.webchat__link-definitions__list,
.webchat__link-definitions__header,
details.webchat__link-definitions {
  display: none !important;
}

/* Hide citation buttons in text */
.webchat__render-markdown__citation,
button[value*="cite:"] {
  display: none !important;
}

/* File preview mobile adjustments */
@media (max-width: 768px) {
  .file-preview-container {
    padding: 0.4rem 0.8rem !important;
  }
  
  .file-preview-card {
    max-width: 280px !important;
    padding: 0.35rem 0.5rem !important;
  }
  
  .file-preview-card .file-icon {
    font-size: 0.8rem !important;
  }
  
  .file-preview-card .file-name {
    font-size: 0.7rem !important;
  }
  
  .file-preview-card .file-details {
    font-size: 0.6rem !important;
  }
  
  .file-preview-card .remove-file {
    font-size: 0.7rem !important;
  }
}

/* Android specific adjustments */
@media (max-width: 480px) {
  /* Better keyboard handling */
  .webchat__send-box {
    position: relative;
    bottom: 0;
  }
  
  /* Improve scrolling performance */
  .webchat__basic-transcript {
    -webkit-overflow-scrolling: touch;
    scroll-behavior: smooth;
  }
}

/* Tablet specific optimizations */
@media (min-width: 481px) and (max-width: 1024px) {
  .webchat__bubble {
    max-width: 70% !important;
  }
  
  .auth-card {
    max-width: 500px;
    width: 80%;
  }
  
  #greeting {
    padding: 1rem 1.5rem;
    font-size: 1.1rem;
  }
  
  .webchat__send-box-text-box {
    font-size: 15px !important;
    padding: 0.8rem 1rem !important;
  }
}

/* ================================
   Chat Mode Tabs
   ================================ */

.chat-mode-tabs {
  display: flex;
  gap: 0.5rem;
  margin-right: auto;
  align-items: center;
}

.chat-mode-tab {
  background: #f3f4f6;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  padding: 0.5rem 1rem;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  color: #6b7280;
  transition: all 0.3s ease;
  white-space: nowrap;
}

.chat-mode-tab:hover {
  background: #e5e7eb;
  border-color: #c1c9d2;
}

.chat-mode-tab.active {
  background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
  border-color: var(--primary-color);
  color: white;
  box-shadow: 0 2px 8px rgba(234, 88, 12, 0.3);
}

/* Dark mode tabs */
[data-theme="dark"] .chat-mode-tab {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.2);
  color: rgba(255, 255, 255, 0.8);
}

[data-theme="dark"] .chat-mode-tab:hover {
  background: rgba(255, 255, 255, 0.15);
}

[data-theme="dark"] .chat-mode-tab.active {
  background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
  border-color: var(--primary-color);
  color: white;
}

/* ================================
   Experimental GPT Chat Interface
   ================================ */

#gpt-chat-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: transparent;
  padding: 1rem;
  min-height: 0;
}

#gpt-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 1rem 0;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  min-height: 0;
  -webkit-overflow-scrolling: touch;
}

.gpt-message {
  display: flex;
  width: 100%;
  animation: slideInUp 0.3s ease;
}

.gpt-message-user {
  justify-content: flex-end;
}

.gpt-message-bot {
  justify-content: flex-start;
}

.gpt-bubble {
  max-width: 75%;
  padding: 12px 16px;
  border-radius: 12px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  line-height: 1.5;
  word-wrap: break-word;
  overflow-wrap: break-word;
}

.gpt-bubble-user {
  background: var(--bubble-user-bg);
  color: var(--bubble-user-text);
  border-bottom-right-radius: 4px;
}

.gpt-bubble-bot {
  background: var(--bubble-bot-bg);
  color: var(--bubble-bot-text);
  border: 1px solid var(--border-color);
  border-bottom-left-radius: 4px;
}

.gpt-bubble-error {
  background: #fee;
  border-color: #fcc;
  color: #c00;
}

/* Message content formatting */
.gpt-bubble strong {
  font-weight: 600;
}

.gpt-bubble em {
  font-style: italic;
}

.gpt-bubble code {
  background: rgba(0, 0, 0, 0.05);
  padding: 2px 4px;
  border-radius: 3px;
  font-family: 'Courier New', monospace;
  font-size: 0.9em;
}

.gpt-bubble pre {
  background: rgba(0, 0, 0, 0.05);
  padding: 8px;
  border-radius: 6px;
  overflow-x: auto;
  margin: 8px 0;
}

.gpt-bubble pre code {
  background: none;
  padding: 0;
}

/* Enhanced markdown formatting */
.gpt-bubble h1,
.gpt-bubble h2,
.gpt-bubble h3,
.gpt-bubble h4,
.gpt-bubble h5,
.gpt-bubble h6 {
  margin: 12px 0 8px 0;
  font-weight: 600;
  line-height: 1.3;
}

.gpt-bubble h1 { font-size: 1.5em; }
.gpt-bubble h2 { font-size: 1.3em; }
.gpt-bubble h3 { font-size: 1.15em; }
.gpt-bubble h4 { font-size: 1.05em; }
.gpt-bubble h5 { font-size: 1em; }
.gpt-bubble h6 { font-size: 0.95em; }

.gpt-bubble p {
  margin: 8px 0;
}

.gpt-bubble p:first-child {
  margin-top: 0;
}

.gpt-bubble p:last-child {
  margin-bottom: 0;
}

.gpt-bubble ul,
.gpt-bubble ol {
  margin: 8px 0;
  padding-left: 24px;
}

.gpt-bubble li {
  margin: 4px 0;
  line-height: 1.5;
}

.gpt-bubble blockquote {
  border-left: 3px solid #ea580c;
  padding-left: 12px;
  margin: 8px 0;
  color: #666;
  font-style: italic;
}

.gpt-bubble hr {
  border: none;
  border-top: 1px solid rgba(0, 0, 0, 0.1);
  margin: 12px 0;
}

.gpt-bubble a {
  color: #ea580c;
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: border-color 0.2s;
}

.gpt-bubble a:hover {
  border-bottom-color: #ea580c;
}

.gpt-bubble table {
  border-collapse: collapse;
  width: 100%;
  margin: 8px 0;
  font-size: 0.9em;
}

.gpt-bubble table th,
.gpt-bubble table td {
  border: 1px solid rgba(0, 0, 0, 0.1);
  padding: 6px 10px;
  text-align: left;
}

.gpt-bubble table th {
  background: rgba(0, 0, 0, 0.05);
  font-weight: 600;
}

.gpt-bubble img {
  max-width: 100%;
  height: auto;
  border-radius: 8px;
  margin: 8px 0;
}

/* Typing indicator */
.gpt-typing-animation {
  display: flex;
  gap: 4px;
  align-items: center;
  padding: 4px 0;
}

.gpt-typing-animation span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-secondary);
  opacity: 0.4;
  animation: typingDot 1.4s infinite;
}

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

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

@keyframes typingDot {
  0%, 60%, 100% {
    opacity: 0.4;
    transform: scale(1);
  }
  30% {
    opacity: 1;
    transform: scale(1.2);
  }
}

/* Input box */
#gpt-input-box {
  flex-shrink: 0;
  display: flex;
  align-items: flex-end;
  gap: 0.5rem;
  padding: 1rem 0;
  background: transparent;
  border-top: 1px solid var(--border-color);
}

#gpt-text-input {
  flex: 1;
  min-height: 40px;
  max-height: 120px;
  padding: 12px 16px;
  border: 1px solid var(--border-color);
  border-radius: 12px;
  background: var(--input-bg);
  color: var(--text-primary);
  font-size: 14px;
  font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, sans-serif;
  resize: none;
  overflow-y: auto;
  transition: all 0.3s ease;
}

#gpt-text-input:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 2px rgba(234, 88, 12, 0.2);
}

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

.gpt-upload-btn,
.gpt-send-btn {
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 16px;
  transition: all 0.3s ease;
  flex-shrink: 0;
}

.gpt-upload-btn {
  background: transparent;
  color: var(--primary-color);
  border: none;
}

.gpt-upload-btn:hover {
  transform: scale(1.1);
}

.gpt-upload-btn:active {
  transform: scale(0.95);
}

/* Dark mode upload button */
[data-theme="dark"] .gpt-upload-btn {
  color: var(--primary-color);
}

.gpt-send-btn {
  background: transparent;
  color: var(--primary-color);
}

.gpt-send-btn:hover {
  background: rgba(234, 88, 12, 0.1);
  transform: scale(1.05);
}

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

/* File preview */
.gpt-file-preview-container {
  position: relative;
  margin: 0 0 0.5rem 0;
  padding: 0.5rem 1rem;
  animation: slideInUp 0.3s ease;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.gpt-file-card {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.6rem;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  font-size: 0.8rem;
  max-width: 300px;
  margin-bottom: 0;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  animation: slideInUp 0.3s ease;
  transition: all 0.3s ease;
}

.gpt-file-card:hover {
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15) !important;
  transform: translateY(-1px);
}

.gpt-file-icon {
  font-size: 0.9rem;
  color: var(--primary-color);
}

.gpt-file-info {
  flex: 1;
  min-width: 0;
  overflow: hidden;
}

.gpt-file-name {
  font-weight: 500;
  font-size: 0.75rem;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 0.1rem;
}

.gpt-file-details {
  font-size: 0.65rem;
  color: var(--text-secondary);
  opacity: 0.7;
}

.gpt-file-remove {
  background: none;
  border: none;
  font-size: 0.8rem;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 0.2rem;
  border-radius: 3px;
  opacity: 0.6;
  transition: all 0.2s ease;
}

.gpt-file-remove:hover {
  background: rgba(0, 0, 0, 0.05);
  opacity: 1;
}

/* Dark mode file preview */
[data-theme="dark"] .gpt-file-card {
  background: var(--bg-secondary);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

[data-theme="dark"] .gpt-file-remove:hover {
  background: rgba(255, 255, 255, 0.1);
}

/* Mobile adjustments for GPT chat */
@media (max-width: 768px) {
  .chat-mode-tabs {
    gap: 0.3rem;
  }
  
  .chat-mode-tab {
    padding: 0.4rem 0.8rem;
    font-size: 11px;
  }
  
  #gpt-chat-container {
    padding: 0.75rem;
  }
  
  .gpt-bubble {
    max-width: 85%;
  }
  
  #gpt-text-input {
    font-size: 14px;
    padding: 10px 12px;
  }
  
  .gpt-upload-btn,
  .gpt-send-btn {
    width: 36px;
    height: 36px;
    font-size: 14px;
  }
}

@media (max-width: 480px) {
  .chat-mode-tab {
    padding: 0.3rem 0.6rem;
    font-size: 10px;
  }
  
  #gpt-chat-container {
    padding: 0.5rem;
  }
  
  .gpt-bubble {
    max-width: 90%;
    padding: 10px 12px;
    font-size: 14px;
  }
  
  #gpt-input-box {
    padding: 0.75rem 0;
  }
  
  #gpt-text-input {
    min-height: 36px;
    font-size: 14px;
  }
}
