/* -------------------------------------------------------------------
   Chat Container – now expands to fill its parent
   ------------------------------------------------------------------- */
.i3ai-chat-container {
  background: #ffffff;
  border-radius: 16px;
  border: 1px solid #e5e7eb;
  box-shadow: 0 4px 12px rgba(0,0,0,0.06);
  font-family: system-ui, -apple-system, sans-serif;
  overflow: hidden;
  transition: all 0.2s;

  /* --- NEW: Make the container fill its parent --- */
  display: flex;
  flex-direction: column;
  height: 100%;              /* Requires parent to have a defined height */
  min-height: 300px;         /* Fallback minimum */
}

/* -------------------------------------------------------------------
   Chat Output Area – grows to fill remaining space
   ------------------------------------------------------------------- */
.i3ai-chat-output {
  /* Removed fixed height, now uses flex to grow */
  flex: 1;                   /* Takes all available space */
  overflow-y: auto;
  padding: 20px 24px;
  background: #fafcff;
  display: flex;
  flex-direction: column;
  gap: 14px;
  scroll-behavior: smooth;
  min-height: 200px;         /* Keep a minimum */
}
.i3ai-chat-output::-webkit-scrollbar { width: 6px; }
.i3ai-chat-output::-webkit-scrollbar-track { background: #f1f1f1; border-radius: 10px; }
.i3ai-chat-output::-webkit-scrollbar-thumb { background: #c1c7cd; border-radius: 10px; }

/* -------------------------------------------------------------------
   Footer (input + button) – fixed height, stays at bottom
   ------------------------------------------------------------------- */
.i3ai-chat-footer {
  padding: 14px 24px;
  background: #f8fafc;
  border-top: 1px solid #e5e7eb;
  display: flex;
  gap: 12px;
  flex-shrink: 0;            /* Prevents footer from shrinking */
}
.i3ai-chat-input {
  flex: 1;
  padding: 12px 18px;
  border: 1px solid #d1d5db;
  border-radius: 40px;
  font-size: 14px;
  outline: none;
  transition: all 0.2s;
  background: #ffffff;
}
.i3ai-chat-input:focus {
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

/* Default button style */
.i3ai-chat-btn {
  background: #2563eb;
  color: #ffffff;
  border: none;
  padding: 12px 32px;
  border-radius: 40px;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
  min-width: 80px;               /* keep width stable during loading */
  display: flex;
  align-items: center;
  justify-content: center;
}
.i3ai-chat-btn:hover {
  background: #1d4ed8;
  transform: scale(1.02);
  box-shadow: 0 4px 10px rgba(37,99,235,0.3);
}

/* -------------------------------------------------------------------
   Loading state – red circle with spinner only (no text)
   ------------------------------------------------------------------- */
.i3ai-chat-btn-loading {
  background: #dc2626 !important;    /* red */
  padding: 12px !important;
  min-width: 48px !important;
  width: 48px !important;
  height: 48px !important;
  border-radius: 50% !important;     /* circular */
  color: transparent !important;     /* hide any text */
  font-size: 0 !important;
  cursor: not-allowed !important;
  transform: none !important;
  box-shadow: none !important;
  position: relative;
}

/* Spinner inside the loading button */
.i3ai-chat-btn-loading::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 24px;
  height: 24px;
  border: 3px solid rgba(255, 255, 255, 0.3);
  border-radius: 50%;
  border-top-color: #ffffff;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: translate(-50%, -50%) rotate(360deg); }
}

/* Disabled state (fallback) */
.i3ai-chat-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none !important;
  box-shadow: none !important;
}

/* -------------------------------------------------------------------
   Messages (user, bot, loading, error)
   ------------------------------------------------------------------- */
.i3ai-msg-user, .i3ai-msg-bot, .i3ai-msg-error {
  padding: 12px 18px;
  max-width: 75%;
  box-shadow: 0 2px 6px rgba(0,0,0,0.04);
  margin-bottom: 6px;
  word-wrap: break-word;
  line-height: 1.6;
}
.i3ai-msg-user {
  color: #1e293b;
}
.i3ai-msg-bot {
  color: #0f172a;
}
.i3ai-msg-loading {
  color: #6b7280;
  padding: 10px 0;
  font-size: 14px;
  background: transparent;
  box-shadow: none;
}
.i3ai-msg-error {
  color: #dc2626;
  background: #fee2e2;
  border-radius: 16px;
  max-width: 80%;
}

/* -------------------------------------------------------------------
   Direction-specific alignment & background
   (RTL: Arabic. LTR: English, German, French, and any future LTR
   language - added once via Text Messages, no new CSS block needed.)
   ------------------------------------------------------------------- */
/* RTL */
.i3ai-dir-rtl .i3ai-msg-user {
  background: #eef2ff;
  align-self: flex-end;
  border-radius: 16px 16px 4px 16px;
  text-align: right;
}
.i3ai-dir-rtl .i3ai-msg-bot {
  background: #f1f5f9;
  align-self: flex-start;
  border-radius: 16px 16px 16px 4px;
  text-align: right;
}
.i3ai-dir-rtl .i3ai-msg-loading {
  align-self: flex-start;
  text-align: right;
}
.i3ai-dir-rtl .i3ai-msg-error {
  align-self: flex-start;
  text-align: right;
}

/* LTR */
.i3ai-dir-ltr .i3ai-msg-user {
  background: #dbeafe;
  align-self: flex-start;
  border-radius: 16px 16px 16px 4px;
  text-align: left;
}
.i3ai-dir-ltr .i3ai-msg-bot {
  background: #f3f4f6;
  align-self: flex-end;
  border-radius: 16px 16px 4px 16px;
  text-align: left;
}
.i3ai-dir-ltr .i3ai-msg-loading {
  align-self: flex-end;
  text-align: left;
}
.i3ai-dir-ltr .i3ai-msg-error {
  align-self: flex-end;
  text-align: left;
}

/* -------------------------------------------------------------------
   Navigation suggestion (Phase 5) - confirmation prompt shown under a
   bot message that proposed opening a page. See docs/navigation.md.
   ------------------------------------------------------------------- */
.i3ai-nav-suggestion {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  padding: 10px 14px;
  margin-top: -6px;
  margin-bottom: 6px;
  max-width: 75%;
  background: #eef2ff;
  border: 1px solid #c7d2fe;
  border-radius: 12px;
  font-size: 13px;
  color: #3730a3;
}
.i3ai-nav-confirm-btn,
.i3ai-nav-dismiss-btn {
  border: none;
  border-radius: 20px;
  padding: 6px 14px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}
.i3ai-nav-confirm-btn {
  background: #4f46e5;
  color: #ffffff;
}
.i3ai-nav-confirm-btn:hover {
  background: #4338ca;
}
.i3ai-nav-dismiss-btn {
  background: transparent;
  color: #4f46e5;
}
.i3ai-nav-dismiss-btn:hover {
  background: rgba(79, 70, 229, 0.1);
}

/* -------------------------------------------------------------------
   Empty state
   ------------------------------------------------------------------- */
.i3ai-chat-empty {
  text-align: center;
  color: #94a3b8;
  font-size: 15px;
  margin-top: 80px;
  padding: 20px;
}
.i3ai-chat-emoji {
  font-size: 44px;
  display: block;
  margin-bottom: 12px;
}

/* -------------------------------------------------------------------
   Viewport Override (ACTIVE)
   This rule overrides the height:100% above and forces the container
   to fill the full browser viewport. To use parent-relative sizing
   instead, comment out or remove this block and keep height:100%.
   ------------------------------------------------------------------- */

.i3ai-chat-container {
  height: 100vh;            /* Full viewport height */
  max-height: 100vh;
}

/* -------------------------------------------------------------------
   "New conversation" — Embedded Display Mode
   In Floating mode the button lands in the panel header and is styled
   in i3ai_chat_floating.css. With no header there is no header, so
   i3ai_chat_script.js drops it next to the send button instead; this
   rule keeps it visibly secondary to that button.
   ------------------------------------------------------------------- */

.i3ai-chat-new-conv {
  flex-shrink: 0;
  background: transparent;
  border: 1px solid rgba(0, 0, 0, 0.15);
  color: inherit;
  opacity: 0.6;
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  padding: 6px 10px;
  margin-right: 6px;
  border-radius: 6px;
  transition: opacity 0.15s ease, background 0.15s ease;
}
.i3ai-chat-new-conv:hover,
.i3ai-chat-new-conv:focus-visible {
  opacity: 1;
  background: rgba(0, 0, 0, 0.06);
}
