/**
 * AISA COMPANION - CHAT STREAM & BUBBLE AESTHETICS (MULTIMODAL READY)
 * Miyazaki Haruto Entertainment Co., Ltd. - Project MHEnt. Universe
 */

/* ==========================================================================
   STREAM HEADER
   ========================================================================== */
.chat-stream-header {
  padding: 12px 24px;
  background: rgba(10, 15, 24, 0.6);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  z-index: 10;
}

.stream-scope-badge {
  font-size: 0.82rem;
  font-weight: 800;
  letter-spacing: 0.3px;
  color: #38bdf8;
  display: flex;
  align-items: center;
  gap: 8px;
}

.stream-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-stream-tool {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
  border-radius: var(--radius-full);
  padding: 4px 12px;
  font-size: 0.74rem;
  font-weight: 700;
  cursor: pointer;
  transition: var(--transition-smooth);
  display: flex;
  align-items: center;
  gap: 5px;
}
.btn-stream-tool:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-high);
  border-color: var(--border-medium);
}

/* ==========================================================================
   MESSAGES LIST WRAP (CENTERED CONTAINER WITH BREATHING ROOM)
   ========================================================================== */
.chat-messages-wrap {
  flex: 1;
  min-height: 0; /* CRUCIAL: Allow flex child to shrink and scroll */
  overflow-y: auto;
  padding: 20px 20px 14px 20px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  scroll-behavior: smooth;
}

/* Inner Centering Wrapper */
.messages-inner-container {
  max-width: 780px;
  width: 100%;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

/* Message Rows */
.message-row {
  display: flex;
  gap: 12px;
  max-width: 90%;
  animation: messageSlideIn 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

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

.user-row {
  align-self: flex-end;
  flex-direction: row-reverse;
  max-width: 82%;
}

.assistant-row {
  align-self: flex-start;
}

/* Avatars */
.assistant-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  flex-shrink: 0;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
  position: relative;
}

.avt-harmony {
  background: linear-gradient(135deg, rgba(236, 72, 153, 0.35), rgba(244, 114, 182, 0.15));
  border: 1.5px solid var(--harmony-border);
  box-shadow: 0 0 16px var(--harmony-glow);
}

.avt-echo {
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.35), rgba(168, 85, 247, 0.15));
  border: 1.5px solid var(--echo-border);
  box-shadow: 0 0 16px var(--echo-glow);
}

.dual-typing {
  background: linear-gradient(135deg, rgba(236, 72, 153, 0.25), rgba(139, 92, 246, 0.25));
  border: 1.5px solid var(--border-medium);
}

/* Message Bubbles */
.message-bubble {
  border-radius: var(--radius-xl);
  padding: 14px 18px;
  font-size: 0.93rem;
  line-height: 1.6;
  word-break: break-word;
  overflow-wrap: break-word;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.25);
  position: relative;
  transition: var(--transition-smooth);
}

.bubble-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 6px;
  font-size: 0.74rem;
}

.sender-name {
  font-weight: 800;
  letter-spacing: 0.3px;
}
.name-harmony { color: var(--harmony-soft); }
.name-echo { color: var(--echo-soft); }

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

.bubble-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 4px;
  opacity: 0.4;
  transition: var(--transition-smooth);
}
.message-bubble:hover .bubble-actions {
  opacity: 1;
}

.btn-bubble-action {
  background: rgba(255, 255, 255, 0.08);
  border: none;
  color: var(--text-medium);
  border-radius: var(--radius-sm);
  padding: 3px 6px;
  font-size: 0.7rem;
  cursor: pointer;
  transition: var(--transition-smooth);
}
.btn-bubble-action:hover {
  background: rgba(255, 255, 255, 0.2);
  color: #ffffff;
}

/* User Bubble (Crisp Sapphire) */
.user-bubble {
  background: linear-gradient(135deg, #0284c7 0%, #0369a1 100%);
  color: #ffffff;
  border: 1px solid rgba(56, 189, 248, 0.35);
  border-bottom-right-radius: 6px;
  box-shadow: 0 4px 20px rgba(2, 132, 199, 0.25);
}
.user-bubble .sender-name {
  color: #e0f2fe;
}
.user-bubble .message-time {
  color: rgba(255, 255, 255, 0.65);
}

/* Harmony Bubble (Warm Rose Sanctuary) */
.harmony-bubble {
  background: linear-gradient(135deg, rgba(236, 72, 153, 0.1) 0%, rgba(18, 25, 39, 0.95) 100%);
  border: 1px solid var(--harmony-border);
  color: #fdf2f8;
  border-bottom-left-radius: 6px;
}

/* Echo Bubble (Cyber Violet Sanctuary) */
.echo-bubble {
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.1) 0%, rgba(18, 25, 39, 0.95) 100%);
  border: 1px solid var(--echo-border);
  color: #f5f3ff;
  border-bottom-left-radius: 6px;
}

/* Image Attachment inside Bubble */
.bubble-attached-img-wrap {
  margin-bottom: 8px;
  border-radius: 12px;
  overflow: hidden;
  max-width: 320px;
  max-height: 240px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
}

.bubble-attached-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  cursor: pointer;
  transition: transform 0.25s ease;
}
.bubble-attached-img:hover {
  transform: scale(1.03);
}

/* ==========================================================================
   MARKDOWN & RICH FORMATTING INSIDE BUBBLES
   ========================================================================== */
.bubble-text {
  font-size: 0.93rem;
}

.bubble-text strong {
  font-weight: 800;
  color: inherit;
}
.bubble-text em {
  font-style: italic;
  color: inherit;
}
.bubble-text del {
  opacity: 0.7;
}

.chat-mention {
  color: #38bdf8;
  font-weight: 800;
  background: rgba(56, 189, 248, 0.15);
  padding: 1px 6px;
  border-radius: 4px;
}

.chat-link {
  color: #38bdf8;
  font-weight: 700;
  text-decoration: underline;
  word-break: break-all;
}

.chat-inline-code {
  background: rgba(255, 255, 255, 0.12);
  border-radius: 4px;
  padding: 1px 6px;
  font-family: var(--font-mono);
  font-size: 0.88em;
  color: #f472b6;
}

/* Bullet Row */
.chat-bullet-row {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin: 4px 0;
}
.chat-bullet-row .bullet-mark {
  color: var(--harmony-soft);
  font-weight: bold;
}

/* ==========================================================================
   TYPING INDICATOR
   ========================================================================== */
.typing-row {
  align-items: center;
}

.typing-bubble {
  background: rgba(18, 25, 39, 0.85);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-full);
  padding: 8px 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.typing-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  animation: typingBounce 1.4s infinite ease-in-out;
}
.typing-dot.pink { background: #ec4899; }
.typing-dot.purple { background: #8b5cf6; animation-delay: 0.2s; }
.typing-dot.cyan { background: #06b6d4; animation-delay: 0.4s; }

@keyframes typingBounce {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
  40% { transform: scale(1.15); opacity: 1; }
}

.typing-label {
  font-size: 0.74rem;
  color: var(--text-muted);
  font-style: italic;
  margin-left: 4px;
}

/* ==========================================================================
   FLOATING INPUT ISLAND (GEMINI STYLE ATTACHMENT + TEXTAREA)
   ========================================================================== */
.chat-input-station {
  padding: 8px 20px 18px 20px;
  flex-shrink: 0; /* CRUCIAL: Never squish or push off-screen */
  z-index: 20;
}

.input-station-inner {
  max-width: 780px;
  width: 100%;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* Quick Prompts Bar */
.quick-prompts-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 2px;
}
.quick-prompts-bar::-webkit-scrollbar {
  display: none;
}

.quick-prompt-btn {
  background: rgba(18, 25, 39, 0.7);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-full);
  padding: 5px 12px;
  font-size: 0.74rem;
  font-weight: 600;
  color: var(--text-medium);
  white-space: nowrap;
  cursor: pointer;
  transition: var(--transition-smooth);
  backdrop-filter: blur(10px);
}
.quick-prompt-btn:hover {
  background: rgba(236, 72, 153, 0.18);
  border-color: rgba(236, 72, 153, 0.5);
  color: #ffffff;
  transform: translateY(-1px);
}

/* Image Attachment Preview Above Input (Gemini Style) */
.chat-attached-preview {
  display: flex;
  align-items: center;
  gap: 8px;
  animation: fadeIn 0.2s ease-out;
}

.attached-img-card {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  background: rgba(18, 25, 39, 0.9);
  border: 1px solid rgba(236, 72, 153, 0.4);
  border-radius: var(--radius-md);
  padding: 5px 10px 5px 6px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
}

.attached-img-thumb {
  width: 44px;
  height: 44px;
  border-radius: 8px;
  object-fit: cover;
  border: 1px solid rgba(255, 255, 255, 0.15);
}

.attached-img-info {
  display: flex;
  flex-direction: column;
}

.attached-img-name {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-high);
  max-width: 180px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.attached-img-size {
  font-size: 0.68rem;
  color: var(--text-muted);
}

.btn-remove-attachment {
  background: rgba(255, 255, 255, 0.08);
  border: none;
  color: var(--text-medium);
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 0.85rem;
  transition: var(--transition-smooth);
}
.btn-remove-attachment:hover {
  background: rgba(239, 68, 68, 0.3);
  color: #ef4444;
}

/* Input Box Wrapper */
.input-box-wrapper {
  display: flex;
  align-items: flex-end;
  background: var(--bg-glass-input);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 22px;
  padding: 6px 12px;
  gap: 8px;
  transition: var(--transition-smooth);
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.4);
}

.input-box-wrapper:focus-within {
  border-color: rgba(236, 72, 153, 0.6);
  box-shadow: 0 0 20px rgba(236, 72, 153, 0.25), 0 8px 30px rgba(0, 0, 0, 0.5);
}

.chat-input-textarea {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  font-family: inherit;
  font-size: 0.94rem;
  color: var(--text-high);
  resize: none;
  height: 40px;
  max-height: 140px;
  line-height: 1.45;
  padding: 8px 4px;
}

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

.input-tools {
  display: flex;
  align-items: center;
  gap: 4px;
  padding-bottom: 2px;
}

.btn-tool-icon {
  background: transparent;
  border: none;
  color: var(--text-muted);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 1.15rem;
  transition: var(--transition-smooth);
}
.btn-tool-icon:hover {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.09);
}
.btn-tool-icon.recording {
  color: #ef4444;
  background: rgba(239, 68, 68, 0.15);
  animation: pulseRed 1s infinite alternate;
}

@keyframes pulseRed {
  from { transform: scale(1); }
  to { transform: scale(1.1); box-shadow: 0 0 12px rgba(239, 68, 68, 0.4); }
}

.btn-send-message {
  background: linear-gradient(135deg, #ec4899 0%, #8b5cf6 100%);
  border: none;
  color: #ffffff;
  border-radius: var(--radius-full);
  padding: 0 16px;
  height: 36px;
  font-weight: 800;
  font-size: 0.85rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 5px;
  transition: var(--transition-smooth);
  box-shadow: 0 0 14px rgba(236, 72, 153, 0.35);
}
.btn-send-message:hover {
  filter: brightness(1.15);
  transform: translateY(-1px);
}
