/**
 * FieldChat Widget CSS v2.3
 * - Mobile-first design
 * - Highly visible send & close buttons
 * - Scrollable chat area
 * - Markdown rendering support
 * - Navigation buttons
 * - Glass morphism design
 */

/* ═══════════════════════════════════════════════════════════════════════
   CSS VARIABLES
   ═══════════════════════════════════════════════════════════════════════ */

:root {
  --fc-bg-body: #020617;
  --fc-bg-surface: rgba(15, 23, 42, 0.96);
  --fc-bg-surface-elevated: rgba(15, 23, 42, 0.98);
  
  --fc-text-primary: #e5e7eb;
  --fc-text-secondary: #9ca3af;
  --fc-text-muted: #6b7280;
  --fc-text-inverse: #f9fafb;
  
  --fc-color-primary: #10B981;
  --fc-color-primary-dark: #059669;
  --fc-color-primary-light: #34D399;
  --fc-color-accent: #6366F1;
  --fc-color-chlorophyll: #00FF9D;
  --fc-color-danger: #ef4444;
  
  --fc-gradient-primary: linear-gradient(135deg, #059669 0%, #10B981 40%, #6366F1 100%);
  
  --fc-glass-bg: rgba(15, 23, 42, 0.85);
  --fc-glass-bg-strong: rgba(15, 23, 42, 0.95);
  --fc-glass-border: rgba(148, 163, 184, 0.4);
  --fc-glass-blur: blur(20px);
  
  --fc-shadow-sm: 0 2px 8px rgba(15, 23, 42, 0.55);
  --fc-shadow-md: 0 10px 35px rgba(15, 23, 42, 0.75);
  --fc-shadow-lg: 0 20px 60px rgba(15, 23, 42, 0.9);
  --fc-shadow-glow: 0 4px 15px rgba(16, 185, 129, 0.4);
  --fc-shadow-glow-strong: 0 6px 24px rgba(16, 185, 129, 0.6);
  
  --fc-radius-sm: 8px;
  --fc-radius-md: 12px;
  --fc-radius-lg: 16px;
  --fc-radius-xl: 24px;
  --fc-radius-full: 9999px;
  
  --fc-transition-fast: 150ms ease;
  --fc-transition-base: 250ms ease;
  --fc-transition-slow: 400ms ease;
  
  --fc-z-backdrop: 9998;
  --fc-z-container: 9999;
  
  /* Mobile-first touch targets (minimum 44px) */
  --fc-touch-target: 44px;
  --fc-touch-target-lg: 48px;
}

/* ═══════════════════════════════════════════════════════════════════════
   BACKDROP
   ═══════════════════════════════════════════════════════════════════════ */

.fieldchat-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--fc-transition-base), visibility var(--fc-transition-base);
  z-index: var(--fc-z-backdrop);
}

.fieldchat-backdrop.open {
  opacity: 1;
  visibility: visible;
}

/* ═══════════════════════════════════════════════════════════════════════
   CONTAINER - Mobile First
   ═══════════════════════════════════════════════════════════════════════ */

.fieldchat-container {
  position: fixed;
  /*
   * Mobile bottom-sheet layout.
   *
   * WHY top + bottom instead of height: calc(100vh - X):
   *   • 100vh on iOS Safari equals the layout viewport (doesn't shrink when
   *     the URL bar is visible), so calc(100vh - 60px) can be taller than
   *     the actual visible area, pushing the header/close button behind
   *     the browser chrome.
   *   • Using top + bottom: 0 makes the browser determine the height from
   *     real edge positions, which is always correct regardless of URL bar
   *     visibility or virtual keyboard state.
   *
   * --fc-top-offset: pages set this CSS custom property to match their
   *   navigation height. Playground pages set it to ~108px (site nav +
   *   workspace nav). Falls back to 60px for non-playground pages.
   */
  top: var(--fc-top-offset, 60px);
  bottom: 0;
  left: 0;
  right: 0;
  width: 100%;
  height: auto;      /* height is derived from top + bottom — no 100vh needed */
  max-height: none;

  display: flex;
  flex-direction: column;

  background: var(--fc-glass-bg-strong);
  backdrop-filter: var(--fc-glass-blur);
  -webkit-backdrop-filter: var(--fc-glass-blur);
  border: 1px solid var(--fc-glass-border);
  border-bottom: none;
  border-radius: var(--fc-radius-xl) var(--fc-radius-xl) 0 0;
  box-shadow: var(--fc-shadow-lg);

  opacity: 0;
  visibility: hidden;
  transform: translateY(100%);
  transition:
    opacity var(--fc-transition-base),
    visibility var(--fc-transition-base),
    transform var(--fc-transition-base);

  z-index: var(--fc-z-container);
  overflow: hidden;
}

.fieldchat-container.open {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

/* ── Desktop / tablet ≥ 768px: anchored floating card (bottom-right) ──────── */
@media (min-width: 768px) {
  .fieldchat-container {
    /*
     * CRITICAL: reset top to auto so that bottom + height drive placement.
     * Without this, the inherited top: var(--fc-top-offset, 60px) from the
     * mobile base fights with bottom: 1.5rem and wins, making the widget
     * appear 60px from the top of the viewport instead of the bottom-right.
     */
    top: auto;
    bottom: 1.5rem;
    right: 1.5rem;
    left: auto;
    width: min(420px, calc(100vw - 3rem));
    /* Responsive height: shrinks gracefully on shorter viewports */
    height: min(600px, calc(100vh - 5rem));
    max-height: calc(100vh - 3rem);
    border-radius: var(--fc-radius-xl);
    border: 1px solid var(--fc-glass-border);
    border-bottom: 1px solid var(--fc-glass-border); /* restore full border */
    transform: translateY(20px) scale(0.95);
  }

  .fieldchat-container.open {
    transform: translateY(0) scale(1);
  }
}

/* Docked mode — side panel, always full height */
.fieldchat-container.docked {
  top: 0;          /* override: docked panel runs full viewport height */
  bottom: 0;
  right: 0;
  left: auto;
  height: auto;    /* top + bottom determine height */
  max-height: none;
  width: 100%;
  border-radius: 0;
  border: none;
  border-left: 1px solid var(--fc-glass-border);
}

@media (min-width: 768px) {
  .fieldchat-container.docked {
    width: min(48vw, 1040px);
  }
}

/* Resizer for docked mode */
.fieldchat-resizer {
  display: none;
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 6px;
  cursor: ew-resize;
  background: transparent;
  transition: background var(--fc-transition-fast);
  z-index: 10;
}

.fieldchat-container.docked .fieldchat-resizer {
  display: block;
}

.fieldchat-resizer:hover {
  background: var(--fc-color-primary);
}

/* ═══════════════════════════════════════════════════════════════════════
   MOBILE DRAG HANDLE — appears above the header on small screens.
   Signals to mobile users that the bottom sheet can be pulled down to
   dismiss. Hidden on desktop (where the close button is sufficient).
   ═══════════════════════════════════════════════════════════════════════ */

.fieldchat-container::before {
  content: '';
  display: block;
  width: 40px;
  height: 4px;
  background: rgba(148, 163, 184, 0.45);
  border-radius: var(--fc-radius-full);
  margin: 10px auto 6px;
  flex-shrink: 0;
}

@media (min-width: 768px) {
  /* No drag handle on desktop — the widget is a floating card, not a sheet */
  .fieldchat-container::before { display: none; }
}

/* ═══════════════════════════════════════════════════════════════════════
   HEADER - Always-visible, sticky close button
   ═══════════════════════════════════════════════════════════════════════ */

.fieldchat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  background: rgba(15, 23, 42, 0.97); /* fully opaque so it reads over any content */
  border-bottom: 1px solid var(--fc-glass-border);
  flex-shrink: 0;     /* never compress — always visible */
  min-height: 56px;
  /*
   * Safety net: even if some browser quirk causes the container to scroll
   * internally, the header stays pinned at the top so the close button is
   * always reachable. z-index keeps it above the thread content.
   */
  position: sticky;
  top: 0;
  z-index: 5;
}

.fieldchat-header-title {
  display: flex;
  align-items: center;
  gap: 0.625rem;
}

.fieldchat-avatar {
  width: 32px;
  height: 32px;
  border-radius: var(--fc-radius-full);
  object-fit: cover;
  border: 2px solid var(--fc-color-primary);
  box-shadow: 0 0 12px rgba(16, 185, 129, 0.5);
}

.fieldchat-title {
  font-family: 'Space Grotesk', system-ui, sans-serif;
  font-size: 1rem;
  font-weight: 600;
  color: var(--fc-text-primary);
  letter-spacing: -0.01em;
}

.fieldchat-header-right {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* ═══════════════════════════════════════════════════════════════════════
   HEADER BUTTONS - HIGHLY VISIBLE
   ═══════════════════════════════════════════════════════════════════════ */

.fieldchat-btn-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  /* Mobile touch target */
  width: var(--fc-touch-target);
  height: var(--fc-touch-target);
  min-width: var(--fc-touch-target);
  min-height: var(--fc-touch-target);
  padding: 0;
  background: rgba(148, 163, 184, 0.15);
  border: 1px solid rgba(148, 163, 184, 0.3);
  border-radius: var(--fc-radius-md);
  color: var(--fc-text-secondary);
  font-size: 1rem;
  cursor: pointer;
  transition: all var(--fc-transition-fast);
  -webkit-tap-highlight-color: transparent;
}

.fieldchat-btn-icon:hover {
  background: rgba(148, 163, 184, 0.25);
  border-color: rgba(148, 163, 184, 0.5);
  color: var(--fc-text-primary);
}

.fieldchat-btn-icon:active {
  transform: scale(0.95);
  background: rgba(148, 163, 184, 0.35);
}

/* ═══════════════════════════════════════════════════════════════════════
   CLOSE BUTTON — always visible, red accent, larger on mobile
   ═══════════════════════════════════════════════════════════════════════ */

#fieldchat-close-btn {
  background: rgba(239, 68, 68, 0.18);
  border-color: rgba(239, 68, 68, 0.45);
  color: #fca5a5;
}

#fieldchat-close-btn:hover {
  background: rgba(239, 68, 68, 0.32);
  border-color: rgba(239, 68, 68, 0.65);
  color: #fecaca;
}

#fieldchat-close-btn:active {
  background: var(--fc-color-danger);
  border-color: var(--fc-color-danger);
  color: white;
}

#fieldchat-close-btn i {
  font-size: 1.1rem;
  font-weight: bold;
}

/* On mobile, give the close button a text label so it's unmistakeable */
@media (max-width: 767px) {
  #fieldchat-close-btn {
    /* Wider pill shape to accommodate the label */
    width: auto;
    padding: 0 0.85rem;
    gap: 0.35rem;
    border-radius: var(--fc-radius-full);
    font-size: 0.8rem;
    font-weight: 600;
    letter-spacing: 0.01em;
    /* Stronger background so it reads clearly against any chat content */
    background: rgba(239, 68, 68, 0.22);
  }

  /* Inject "Close" label via pseudo-element — no HTML change required */
  #fieldchat-close-btn::after {
    content: 'Close';
    font-size: 0.78rem;
    font-weight: 600;
    color: #fca5a5;
  }

  #fieldchat-close-btn:hover::after { color: #fecaca; }
  #fieldchat-close-btn:active::after { color: white; }
}

/* ═══════════════════════════════════════════════════════════════════════
   BODY - SCROLLABLE CHAT AREA
   ═══════════════════════════════════════════════════════════════════════ */

.fieldchat-body {
  flex: 1;
  min-height: 0;
  overflow: hidden;
  position: relative;
}

.fieldchat-thread {
  height: 100%;
  padding: 1rem;
  overflow-y: auto;
  overflow-x: hidden;
  
  scrollbar-width: thin;
  scrollbar-color: rgba(148, 163, 184, 0.4) transparent;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
}

.fieldchat-thread::-webkit-scrollbar {
  width: 6px;
}

.fieldchat-thread::-webkit-scrollbar-track {
  background: transparent;
}

.fieldchat-thread::-webkit-scrollbar-thumb {
  background: rgba(148, 163, 184, 0.4);
  border-radius: var(--fc-radius-full);
}

.fieldchat-thread::-webkit-scrollbar-thumb:hover {
  background: rgba(148, 163, 184, 0.6);
}

/* ═══════════════════════════════════════════════════════════════════════
   GREETING
   ═══════════════════════════════════════════════════════════════════════ */

.fieldchat-greeting {
  text-align: center;
  padding: 2rem 1.5rem;
  color: var(--fc-text-secondary);
  font-size: 0.95rem;
  line-height: 1.6;
}

.fieldchat-greeting strong {
  color: var(--fc-color-primary-light);
}

/* ═══════════════════════════════════════════════════════════════════════
   MESSAGES
   ═══════════════════════════════════════════════════════════════════════ */

.fieldchat-msg {
  display: flex;
  margin-bottom: 1rem;
  animation: fc-fadeIn 0.3s ease;
}

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

.fieldchat-msg.user {
  justify-content: flex-end;
}

.fieldchat-msg.bot {
  justify-content: flex-start;
}

.fieldchat-msg-content {
  max-width: 85%;
  display: flex;
  flex-direction: column;
}

.fieldchat-msg.user .fieldchat-msg-content {
  align-items: flex-end;
}

.fieldchat-msg.bot .fieldchat-msg-content {
  align-items: flex-start;
}

/* ═══════════════════════════════════════════════════════════════════════
   MESSAGE BUBBLES
   ═══════════════════════════════════════════════════════════════════════ */

.fieldchat-bubble {
  padding: 0.75rem 1rem;
  border-radius: var(--fc-radius-lg);
  font-size: 0.9rem;
  line-height: 1.55;
  word-wrap: break-word;
  overflow-wrap: break-word;
}

.fieldchat-msg.user .fieldchat-bubble {
  background: var(--fc-gradient-primary);
  color: var(--fc-text-inverse);
  border-bottom-right-radius: 4px;
  box-shadow: var(--fc-shadow-glow);
}

.fieldchat-msg.bot .fieldchat-bubble {
  background: rgba(30, 41, 59, 0.9);
  color: var(--fc-text-primary);
  border: 1px solid var(--fc-glass-border);
  border-bottom-left-radius: 4px;
}

/* Streaming indicator */
.fieldchat-bubble.streaming::after {
  content: '▋';
  animation: fc-blink 0.8s infinite;
  color: var(--fc-color-primary);
  margin-left: 2px;
}

@keyframes fc-blink {
  0%, 50% { opacity: 1; }
  51%, 100% { opacity: 0; }
}

/* ═══════════════════════════════════════════════════════════════════════
   MARKDOWN STYLES IN BUBBLES
   ═══════════════════════════════════════════════════════════════════════ */

.fieldchat-bubble h1,
.fieldchat-bubble h2,
.fieldchat-bubble h3,
.fieldchat-bubble h4,
.fieldchat-bubble h5,
.fieldchat-bubble h6 {
  margin-top: 0.75em;
  margin-bottom: 0.5em;
  font-family: 'Space Grotesk', system-ui, sans-serif;
  font-weight: 600;
  line-height: 1.3;
  color: var(--fc-text-primary);
}

.fieldchat-bubble h1:first-child,
.fieldchat-bubble h2:first-child,
.fieldchat-bubble h3:first-child,
.fieldchat-bubble h4:first-child,
.fieldchat-bubble h5:first-child,
.fieldchat-bubble h6:first-child {
  margin-top: 0;
}

.fieldchat-bubble h1 { font-size: 1.35em; }
.fieldchat-bubble h2 { font-size: 1.2em; }
.fieldchat-bubble h3 { font-size: 1.1em; }
.fieldchat-bubble h4,
.fieldchat-bubble h5,
.fieldchat-bubble h6 { font-size: 1em; }

.fieldchat-bubble p {
  margin-bottom: 0.7em;
  line-height: 1.6;
}

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

.fieldchat-bubble ul,
.fieldchat-bubble ol {
  margin: 0.5em 0;
  padding-left: 1.4em;
}

.fieldchat-bubble li {
  margin-bottom: 0.3em;
  line-height: 1.5;
}

.fieldchat-bubble li:last-child {
  margin-bottom: 0;
}

.fieldchat-bubble code {
  background: rgba(0, 0, 0, 0.35);
  padding: 0.15em 0.4em;
  border-radius: 4px;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.88em;
  color: var(--fc-color-chlorophyll);
}

.fieldchat-bubble pre {
  background: rgba(0, 0, 0, 0.45);
  border: 1px solid rgba(148, 163, 184, 0.25);
  border-radius: var(--fc-radius-sm);
  padding: 0.7em 0.9em;
  margin: 0.7em 0;
  overflow-x: auto;
  font-size: 0.85em;
}

.fieldchat-bubble pre code {
  background: none;
  padding: 0;
  color: var(--fc-text-primary);
}

.fieldchat-bubble blockquote {
  border-left: 3px solid var(--fc-color-primary);
  margin: 0.7em 0;
  padding: 0.4em 0 0.4em 0.9em;
  background: rgba(16, 185, 129, 0.08);
  border-radius: 0 var(--fc-radius-sm) var(--fc-radius-sm) 0;
  font-style: italic;
  color: var(--fc-text-secondary);
}

.fieldchat-bubble a {
  color: var(--fc-color-primary-light);
  text-decoration: underline;
  text-underline-offset: 2px;
  transition: color var(--fc-transition-fast);
}

.fieldchat-bubble a:hover {
  color: var(--fc-color-chlorophyll);
}

.fieldchat-bubble strong,
.fieldchat-bubble b {
  font-weight: 600;
  color: var(--fc-text-primary);
}

.fieldchat-bubble em,
.fieldchat-bubble i {
  font-style: italic;
}

.fieldchat-bubble hr {
  border: none;
  border-top: 1px solid rgba(148, 163, 184, 0.25);
  margin: 0.9em 0;
}

.fieldchat-bubble table {
  width: 100%;
  border-collapse: collapse;
  margin: 0.7em 0;
  font-size: 0.88em;
}

.fieldchat-bubble th,
.fieldchat-bubble td {
  border: 1px solid rgba(148, 163, 184, 0.25);
  padding: 0.45em 0.65em;
  text-align: left;
}

.fieldchat-bubble th {
  background: rgba(16, 185, 129, 0.12);
  font-weight: 600;
}

.fieldchat-bubble tr:nth-child(even) {
  background: rgba(0, 0, 0, 0.08);
}

/* ═══════════════════════════════════════════════════════════════════════
   NAVIGATION BUTTONS
   ═══════════════════════════════════════════════════════════════════════ */

.fieldchat-nav-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid rgba(148, 163, 184, 0.2);
}

.fieldchat-nav-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 0.875rem;
  min-height: var(--fc-touch-target);
  background: rgba(16, 185, 129, 0.12);
  border: 1px solid rgba(16, 185, 129, 0.35);
  border-radius: var(--fc-radius-full);
  color: var(--fc-color-primary-light);
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--fc-transition-fast);
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
}

.fieldchat-nav-btn:hover {
  background: var(--fc-color-primary);
  border-color: var(--fc-color-primary);
  color: var(--fc-text-inverse);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.35);
}

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

.fieldchat-nav-btn i {
  font-size: 0.75rem;
}

/* Button variants */
.fieldchat-nav-btn.btn-products {
  background: rgba(99, 102, 241, 0.12);
  border-color: rgba(99, 102, 241, 0.35);
  color: #a5b4fc;
}

.fieldchat-nav-btn.btn-products:hover {
  background: var(--fc-color-accent);
  border-color: var(--fc-color-accent);
  color: var(--fc-text-inverse);
}

.fieldchat-nav-btn.btn-research {
  background: rgba(245, 158, 11, 0.12);
  border-color: rgba(245, 158, 11, 0.35);
  color: #fcd34d;
}

.fieldchat-nav-btn.btn-research:hover {
  background: #f59e0b;
  border-color: #f59e0b;
  color: #1f2937;
}

.fieldchat-nav-btn.btn-playground {
  background: rgba(236, 72, 153, 0.12);
  border-color: rgba(236, 72, 153, 0.35);
  color: #f9a8d4;
}

.fieldchat-nav-btn.btn-playground:hover {
  background: #ec4899;
  border-color: #ec4899;
  color: var(--fc-text-inverse);
}

.fieldchat-nav-btn.btn-safety {
  background: rgba(239, 68, 68, 0.12);
  border-color: rgba(239, 68, 68, 0.35);
  color: #fca5a5;
}

.fieldchat-nav-btn.btn-safety:hover {
  background: #ef4444;
  border-color: #ef4444;
  color: var(--fc-text-inverse);
}

.fieldchat-nav-btn.btn-solutions {
  background: rgba(34, 211, 238, 0.12);
  border-color: rgba(34, 211, 238, 0.35);
  color: #67e8f9;
}

.fieldchat-nav-btn.btn-solutions:hover {
  background: #22d3ee;
  border-color: #22d3ee;
  color: #1f2937;
}

.fieldchat-nav-btn.btn-contact {
  background: rgba(168, 85, 247, 0.12);
  border-color: rgba(168, 85, 247, 0.35);
  color: #d8b4fe;
}

.fieldchat-nav-btn.btn-contact:hover {
  background: #a855f7;
  border-color: #a855f7;
  color: var(--fc-text-inverse);
}

.fieldchat-nav-placeholder:empty {
  display: none;
}

/* ═══════════════════════════════════════════════════════════════════════
   MESSAGE META (TIMESTAMP + AUDIO)
   ═══════════════════════════════════════════════════════════════════════ */

.fieldchat-meta {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.35rem;
  padding: 0 0.25rem;
}

.fieldchat-timestamp {
  font-size: 0.7rem;
  color: var(--fc-text-muted);
  font-family: 'IBM Plex Mono', monospace;
}

.fieldchat-audio-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  background: rgba(16, 185, 129, 0.15);
  border: 1px solid rgba(16, 185, 129, 0.35);
  border-radius: var(--fc-radius-full);
  color: var(--fc-color-primary-light);
  font-size: 0.72rem;
  cursor: pointer;
  transition: all var(--fc-transition-fast);
  -webkit-tap-highlight-color: transparent;
}

.fieldchat-audio-btn:hover {
  background: var(--fc-color-primary);
  border-color: var(--fc-color-primary);
  color: var(--fc-text-inverse);
  transform: scale(1.08);
}

.fieldchat-audio-btn.loading {
  opacity: 0.6;
  pointer-events: none;
}

.fieldchat-audio-btn.loading::before {
  content: '';
  width: 12px;
  height: 12px;
  border: 2px solid rgba(16, 185, 129, 0.3);
  border-top-color: var(--fc-color-primary);
  border-radius: 50%;
  animation: fc-spin 0.7s linear infinite;
}

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

/* ═══════════════════════════════════════════════════════════════════════
   TYPING INDICATOR
   ═══════════════════════════════════════════════════════════════════════ */

.fieldchat-typing {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 0.75rem 1rem;
  background: rgba(30, 41, 59, 0.9);
  border: 1px solid var(--fc-glass-border);
  border-radius: var(--fc-radius-lg);
  border-bottom-left-radius: 4px;
}

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

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

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

/* ═══════════════════════════════════════════════════════════════════════
   COMPOSER (INPUT AREA) - MOBILE FIRST
   ═══════════════════════════════════════════════════════════════════════ */

.fieldchat-composer {
  padding: 0.75rem;
  background: rgba(15, 23, 42, 0.9);
  border-top: 1px solid var(--fc-glass-border);
  flex-shrink: 0;
  /* Safe area for iPhone notch/home indicator */
  padding-bottom: max(0.75rem, env(safe-area-inset-bottom));
}

.fieldchat-composer-form {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.fieldchat-input-wrapper {
  flex: 1;
  display: flex;
  align-items: center;
  background: rgba(30, 41, 59, 0.8);
  border: 1px solid var(--fc-glass-border);
  border-radius: var(--fc-radius-full);
  padding: 0.5rem 0.625rem 0.5rem 1rem;
  min-height: var(--fc-touch-target);
  transition: border-color var(--fc-transition-fast), box-shadow var(--fc-transition-fast);
}

.fieldchat-input-wrapper:focus-within {
  border-color: var(--fc-color-primary);
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.25);
}

.fieldchat-composer-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--fc-text-primary);
  font-family: inherit;
  font-size: 1rem;
  padding: 0.25rem 0;
  min-width: 0;
}

.fieldchat-composer-input::placeholder {
  color: var(--fc-text-muted);
}

.fieldchat-input-actions {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.fieldchat-input-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  min-width: 36px;
  padding: 0;
  background: transparent;
  border: none;
  border-radius: var(--fc-radius-full);
  color: var(--fc-text-muted);
  font-size: 1rem;
  cursor: pointer;
  transition: all var(--fc-transition-fast);
  -webkit-tap-highlight-color: transparent;
}

.fieldchat-input-btn:hover {
  background: rgba(148, 163, 184, 0.15);
  color: var(--fc-text-primary);
}

.fieldchat-input-btn.recording {
  background: rgba(239, 68, 68, 0.2);
  color: #ef4444;
  animation: fc-pulse 1.5s infinite;
}

@keyframes fc-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

/* ═══════════════════════════════════════════════════════════════════════
   SEND BUTTON - HIGHLY VISIBLE
   ═══════════════════════════════════════════════════════════════════════ */

.fieldchat-send-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  /* Large touch target */
  width: var(--fc-touch-target-lg);
  height: var(--fc-touch-target-lg);
  min-width: var(--fc-touch-target-lg);
  min-height: var(--fc-touch-target-lg);
  padding: 0;
  background: var(--fc-gradient-primary);
  border: none;
  border-radius: var(--fc-radius-full);
  color: var(--fc-text-inverse);
  font-size: 1.1rem;
  cursor: pointer;
  box-shadow: var(--fc-shadow-glow-strong);
  transition: all var(--fc-transition-fast);
  -webkit-tap-highlight-color: transparent;
  /* Ensure it's always visible */
  flex-shrink: 0;
}

.fieldchat-send-btn:hover {
  transform: scale(1.08);
  box-shadow: 0 8px 28px rgba(16, 185, 129, 0.6);
}

.fieldchat-send-btn:active {
  transform: scale(0.95);
  box-shadow: var(--fc-shadow-glow);
}

.fieldchat-send-btn:disabled {
  opacity: 0.4;
  pointer-events: none;
  box-shadow: none;
}

/* Send button icon */
.fieldchat-send-btn i {
  /* Slight offset to center the paper plane visually */
  margin-left: 2px;
}

/* ═══════════════════════════════════════════════════════════════════════
   RESPONSIVE ADJUSTMENTS
   ═══════════════════════════════════════════════════════════════════════ */

/* Small phones */
@media (max-width: 374px) {
  .fieldchat-header {
    padding: 0.625rem 0.75rem;
  }
  
  .fieldchat-title {
    font-size: 0.9rem;
  }
  
  .fieldchat-avatar {
    width: 28px;
    height: 28px;
  }
  
  .fieldchat-thread {
    padding: 0.75rem;
  }
  
  .fieldchat-composer {
    padding: 0.625rem;
  }
  
  .fieldchat-bubble {
    padding: 0.625rem 0.875rem;
    font-size: 0.88rem;
  }
  
  .fieldchat-send-btn {
    width: var(--fc-touch-target);
    height: var(--fc-touch-target);
    min-width: var(--fc-touch-target);
    min-height: var(--fc-touch-target);
  }
}

/* Standard phones */
@media (max-width: 575.98px) {
  .fieldchat-msg-content {
    max-width: 88%;
  }
  
  .fieldchat-nav-buttons {
    flex-direction: column;
  }
  
  .fieldchat-nav-btn {
    width: 100%;
    justify-content: center;
  }
}

/* Tablet and up - can use slightly smaller buttons */
@media (min-width: 768px) {
  .fieldchat-btn-icon {
    width: 38px;
    height: 38px;
    min-width: 38px;
    min-height: 38px;
  }
  
  .fieldchat-send-btn {
    width: 44px;
    height: 44px;
    min-width: 44px;
    min-height: 44px;
  }
  
  .fieldchat-composer {
    padding: 0.875rem 1rem;
  }
}

/* ═══════════════════════════════════════════════════════════════════════
   PRINT - HIDE WIDGET
   ═══════════════════════════════════════════════════════════════════════ */

@media print {
  #fieldchat-root,
  .fieldchat-backdrop,
  .fieldchat-container {
    display: none !important;
  }
}

/* ═══════════════════════════════════════════════════════════════════════
   ACCESSIBILITY - Reduced Motion
   ═══════════════════════════════════════════════════════════════════════ */

@media (prefers-reduced-motion: reduce) {
  .fieldchat-container,
  .fieldchat-backdrop,
  .fieldchat-msg,
  .fieldchat-btn-icon,
  .fieldchat-send-btn,
  .fieldchat-nav-btn {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
  }
}