/* chat.css — Chat messages + bottom input bar */

/* ══════════════════════════════════════════
   Chat Container
   ══════════════════════════════════════════ */

.chat-container {
  position: relative;
  z-index: 10;
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  pointer-events: none;
}

@media (max-width: 899px) {
  .chat-container {
    height: 100%;
    padding-bottom: var(--input-bar-height);
  }
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-6) var(--space-6) calc(var(--input-bar-height) + var(--space-8));
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  scroll-behavior: smooth;
  max-width: 860px;
  width: 100%;
  margin: 0 auto;
}

/* ══════════════════════════════════════════
   Message Bubbles
   ══════════════════════════════════════════ */

.message {
  display: flex;
  gap: var(--space-3);
  max-width: 92%;
  animation: fadeInUp 0.3s ease;
}

/* User messages — right aligned */
.message.user {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.message.user .message-bubble {
  background: linear-gradient(135deg, rgba(74, 158, 255, 0.08), rgba(74, 158, 255, 0.03));
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgba(74, 158, 255, 0.18);
  border-radius: var(--radius-xl) var(--radius-xl) var(--radius-sm) var(--radius-xl);
}

/* Assistant messages — left aligned */
.message.assistant {
  align-self: flex-start;
}

.message.assistant .message-bubble {
  background: linear-gradient(135deg, rgba(124, 58, 237, 0.07), rgba(74, 158, 255, 0.03));
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgba(124, 58, 237, 0.18);
  border-radius: var(--radius-xl) var(--radius-xl) var(--radius-xl) var(--radius-sm);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
}

/* System messages — centered */
.message.system {
  align-self: center;
  max-width: 85%;
}

.message.system .message-bubble {
  background: rgba(124, 58, 237, 0.08);
  border: 1px solid rgba(124, 58, 237, 0.15);
  border-radius: var(--radius-xl);
  text-align: center;
  color: var(--text-secondary);
  font-size: var(--font-size-sm);
}

/* Bubble content */
.message-bubble {
  padding: var(--space-3) var(--space-5);
  line-height: 1.6;
  word-break: break-word;
}

.message-bubble p {
  margin-bottom: var(--space-2);
}

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

.message-bubble strong {
  color: var(--text-primary);
  font-weight: 600;
}

.message-bubble code {
  font-family: var(--font-mono);
  font-size: var(--font-size-sm);
  background: rgba(255, 255, 255, 0.08);
  padding: 0.15em 0.4em;
  border-radius: var(--radius-sm);
}

.message-bubble pre {
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-3);
  overflow-x: auto;
  margin: var(--space-2) 0;
}

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

/* Avatar */
.message-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--font-size-sm);
  flex-shrink: 0;
  margin-top: var(--space-1);
}

.message.user .message-avatar {
  background: linear-gradient(135deg, var(--accent-blue), var(--accent-purple));
}

.message.assistant .message-avatar {
  background: linear-gradient(135deg, var(--accent-purple), var(--accent-blue));
  box-shadow: 0 0 12px var(--accent-blue-glow);
}

/* ══════════════════════════════════════════
   Typing Indicator
   ══════════════════════════════════════════ */

.typing-indicator {
  display: flex;
  gap: 4px;
  padding: var(--space-3) var(--space-5);
}

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

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

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

@keyframes typingBounce {

  0%,
  60%,
  100% {
    transform: translateY(0);
    opacity: 0.4;
  }

  30% {
    transform: translateY(-6px);
    opacity: 1;
  }
}

/* ══════════════════════════════════════════
   Bottom Input Bar
   ══════════════════════════════════════════ */

.input-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 100;
  background: rgba(10, 14, 39, 0.85);
  backdrop-filter: var(--glass-blur);
  border-top: 1px solid var(--border);
  padding: var(--space-3) var(--space-6) var(--space-4);
}

.input-bar-inner {
  max-width: 800px;
  margin: 0 auto;
}

/* Status line — positioned to the left of the input bar */
.status-line {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-bottom: 0;
  white-space: nowrap;
  flex-shrink: 0;
}

.status-dot-pulse {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-muted);
  transition: background var(--transition-base);
  flex-shrink: 0;
}

.status-dot-pulse.listening {
  background: var(--accent-blue);
  animation: dotPulse 1.5s ease-in-out infinite;
}

.status-dot-pulse.thinking {
  background: var(--accent-purple);
  animation: dotPulse 1s ease-in-out infinite;
}

.status-dot-pulse.speaking {
  background: var(--accent-gold);
  animation: dotPulse 1.2s ease-in-out infinite;
}

.status-text {
  font-size: var(--font-size-xs);
  color: var(--text-muted);
  letter-spacing: 0.03em;
  transition: color var(--transition-base);
}

.status-line.active .status-text {
  color: var(--text-secondary);
}

/* Input area */
.input-area {
  display: flex;
  gap: var(--space-3);
  align-items: center;
  width: 100%;
  flex-wrap: nowrap;
}

.text-input {
  flex: 1 1 auto;
  min-width: 0;
  /* Crucial for flex shrinking on mobile */
  height: 44px;
  padding: 0 var(--space-5);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: var(--font-size-base);
  outline: none;
  transition: all var(--transition-base);
}

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

.text-input:focus {
  border-color: var(--accent-blue);
  box-shadow: 0 0 0 3px rgba(74, 158, 255, 0.1);
}

/* Mic button */
.mic-btn {
  width: 44px;
  height: 44px;
  min-width: 44px;
  border-radius: 50%;
  border: 2px solid var(--border);
  background: var(--surface);
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  transition: all var(--transition-base);
  flex-shrink: 0;
}

.mic-btn:hover {
  border-color: var(--accent-blue);
  color: var(--accent-blue);
  background: rgba(74, 158, 255, 0.1);
}

.mic-btn.recording {
  border-color: var(--accent-blue);
  color: var(--accent-blue);
  background: rgba(74, 158, 255, 0.15);
  animation: micGlow 2s ease-in-out infinite;
}

.mic-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

/* Phone Call button */
.call-btn {
  width: 44px;
  height: 44px;
  min-width: 44px;
  border-radius: 50%;
  border: 2px solid var(--border);
  background: var(--surface);
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  transition: all var(--transition-base);
  flex-shrink: 0;
}

.call-btn:hover {
  border-color: var(--accent-blue);
  color: var(--accent-blue);
  background: rgba(74, 158, 255, 0.1);
}

.call-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  transition: transform 0.2s ease;
}

.call-btn.in-call {
  border-color: #ef4444;
  color: #ffffff;
  background: #dc2626;
  box-shadow: 0 0 16px rgba(239, 68, 68, 0.6);
  animation: pulse-flashing-call 1s ease-in-out infinite alternate;
}

.call-btn.in-call .call-icon {
  transform: rotate(135deg);
}

@keyframes pulse-flashing-call {
  0% {
    background-color: #dc2626;
    box-shadow: 0 0 10px rgba(239, 68, 68, 0.5);
    transform: scale(1);
  }

  100% {
    background-color: #ef4444;
    box-shadow: 0 0 24px rgba(239, 68, 68, 0.9);
    transform: scale(1.08);
  }
}

.mic-ring {
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  border: 2px solid transparent;
  pointer-events: none;
  transition: border-color var(--transition-base);
}

.mic-btn.recording .mic-ring {
  border-color: var(--accent-blue);
  animation: micGlow 2s ease-in-out infinite;
}

/* ══════════════════════════════════════════
   Floating Response Cards (Spatial Multi-Layer Glassmorphism)
   ══════════════════════════════════════════ */

.floating-response-card {
  position: absolute;
  width: 380px;
  max-width: 90vw;
  pointer-events: auto;
  border-radius: var(--radius-xl);
  background: rgba(8, 14, 38, 0.40);
  backdrop-filter: blur(10px) saturate(130%);
  -webkit-backdrop-filter: blur(10px) saturate(130%);
  border: 1px solid rgba(74, 158, 255, 0.24);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.35), 0 0 18px rgba(74, 158, 255, 0.08);
  display: flex;
  flex-direction: column;
  transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.22s ease, background 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
  user-select: none;
  animation: cardPopIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.floating-response-card:hover {
  background: rgba(10, 18, 48, 0.62);
  backdrop-filter: blur(14px) saturate(175%);
  -webkit-backdrop-filter: blur(14px) saturate(175%);
  border-color: rgba(74, 158, 255, 0.45);
  box-shadow: 0 18px 45px rgba(0, 0, 0, 0.50), 0 0 25px rgba(74, 158, 255, 0.20);
}

@keyframes cardPopIn {
  from {
    opacity: 0;
    transform: scale(0.9) translateY(10px);
  }

  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.floating-response-card.dragging {
  cursor: grabbing;
  background: rgba(14, 24, 60, 0.70);
  backdrop-filter: blur(16px) saturate(180%);
  -webkit-backdrop-filter: blur(16px) saturate(180%);
  border-color: rgba(74, 158, 255, 0.60);
  box-shadow: 0 24px 55px rgba(0, 0, 0, 0.65), 0 0 35px rgba(74, 158, 255, 0.35);
  transform: scale(1.02);
}

.floating-response-card.closing {
  opacity: 0;
  transform: scale(0.85);
  pointer-events: none;
}

.response-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-3) var(--space-4);
  background: rgba(255, 255, 255, 0.03);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  cursor: grab;
}

.card-title-group {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  overflow: hidden;
  flex: 1;
}

.card-source-badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  flex-shrink: 0;
  line-height: 1.2;
}

.card-source-icon {
  font-size: 10px;
}

.card-source-label {
  font-size: 9px;
}

.card-source-badge.source-discord {
  background: rgba(88, 101, 242, 0.2);
  color: #8ea1e1;
  border-color: rgba(88, 101, 242, 0.4);
}

.card-source-badge.source-telegram {
  background: rgba(0, 136, 204, 0.2);
  color: #38bdf8;
  border-color: rgba(0, 136, 204, 0.4);
}

.card-source-badge.source-whatsapp {
  background: rgba(37, 211, 102, 0.2);
  color: #4ade80;
  border-color: rgba(37, 211, 102, 0.4);
}

.card-source-badge.source-voice {
  background: rgba(239, 68, 68, 0.2);
  color: #f87171;
  border-color: rgba(239, 68, 68, 0.4);
}

.card-source-badge.source-web {
  background: rgba(74, 158, 255, 0.2);
  color: var(--accent-blue);
  border-color: rgba(74, 158, 255, 0.4);
}

.card-source-badge.source-note {
  background: rgba(234, 179, 8, 0.2);
  color: #facc15;
  border-color: rgba(234, 179, 8, 0.4);
}

.card-source-badge.source-schedule {
  background: rgba(168, 85, 247, 0.2);
  color: #c084fc;
  border-color: rgba(168, 85, 247, 0.4);
}

.card-source-badge.source-system {
  background: rgba(148, 163, 184, 0.2);
  color: #cbd5e1;
  border-color: rgba(148, 163, 184, 0.4);
}

.card-header-title {
  font-size: var(--font-size-xs);
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card-header-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.card-action-btn {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-secondary);
  font-size: 11px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
}

.card-action-btn:hover {
  background: rgba(74, 158, 255, 0.2);
  border-color: rgba(74, 158, 255, 0.4);
  color: var(--text-primary);
}

.card-action-btn.btn-close:hover {
  background: rgba(239, 68, 68, 0.25);
  color: var(--accent-red);
}

.response-card-body {
  padding: var(--space-4);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  user-select: text;
}

.card-user-prompt {
  font-size: var(--font-size-xs);
  color: var(--text-secondary);
  background: rgba(74, 158, 255, 0.08);
  border: 1px solid rgba(74, 158, 255, 0.15);
  padding: 4px 8px;
  border-radius: var(--radius-md);
  line-height: 1.4;
}

.user-tag {
  font-weight: 700;
  font-size: 9px;
  letter-spacing: 0.05em;
  color: var(--accent-blue);
  background: rgba(74, 158, 255, 0.18);
  padding: 1px 4px;
  border-radius: var(--radius-sm);
  margin-right: 4px;
}

.card-response-content {
  font-size: var(--font-size-sm);
  color: var(--text-primary);
  line-height: 1.6;
  max-height: 280px;
  overflow-y: auto;
  word-break: break-word;
}

.card-response-content p {
  margin-bottom: var(--space-2);
}

.response-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: var(--font-size-xs);
  color: var(--text-muted);
  border-top: 1px solid rgba(255, 255, 255, 0.05);
  padding-top: var(--space-2);
}

.card-copy-btn {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--text-secondary);
  font-size: 10px;
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.card-copy-btn:hover {
  background: rgba(74, 158, 255, 0.15);
  border-color: rgba(74, 158, 255, 0.35);
  color: var(--accent-blue);
}

/* Minimized card pill */
.floating-response-card.minimized {
  width: 240px;
  border-radius: var(--radius-full);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4), 0 0 15px rgba(74, 158, 255, 0.15);
}

.floating-response-card.minimized .response-card-header {
  border-radius: var(--radius-full);
  border-bottom: none;
}

.floating-response-card.minimized .response-card-body {
  display: none;
}

/* ══════════════════════════════════════════
   Mobile & Small Screen Optimizations (< 680px)
   ══════════════════════════════════════════ */

@media (max-width: 680px) {
  .input-bar {
    padding: 8px 12px calc(8px + env(safe-area-inset-bottom, 8px));
  }

  .input-area {
    gap: 8px;
    width: 100%;
  }

  .status-text {
    display: none;
    /* Hide status text label on phones so Mic and Call buttons are fully visible */
  }

  .status-line {
    padding-right: 2px;
  }

  .text-input {
    min-width: 0;
    flex: 1 1 auto;
    height: 42px;
    padding: 0 12px;
    font-size: 14px;
  }

  .mic-btn,
  .call-btn {
    width: 42px;
    height: 42px;
    min-width: 42px;
    min-height: 42px;
    flex-shrink: 0;
  }

  .mic-icon,
  .call-icon {
    width: 19px;
    height: 19px;
  }

  .footer-text {
    display: none;
  }

  /* Response cards on phone screens */
  .floating-response-card {
    width: calc(100vw - 24px) !important;
    max-width: calc(100vw - 24px) !important;
    left: 12px !important;
  }

  .floating-response-card.minimized {
    width: 220px !important;
    left: 12px !important;
  }
}