/* static/css/chat.css */

/* Chat Panel Container */
.chat-panel {
  position: fixed;
  right: 1rem;
  bottom: 5rem;      /* Above the mic button */
  width: min(90vw, 420px);  /* Responsive width, max 420px */
  max-height: 60vh;
  overflow-y: auto;
  padding: 1rem;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-radius: 12px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  display: none;  /* Hidden by default */
  flex-direction: column;
  gap: 0.75rem;
  z-index: 10020;
  transition: all 0.3s ease;
}

/* Show panel when it has content */
.chat-panel:not(:empty) {
  display: flex;
}

/* Chat Bubbles */
.chat-panel .bubble {
  padding: 0.75rem 1rem;
  border-radius: 18px;
  max-width: 85%;
  word-wrap: break-word;
  word-break: break-word;
  white-space: pre-wrap;
  animation: fadeIn 0.3s ease;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

/* User Messages (right-aligned) */
.chat-panel .bubble.user {
  background: #1976d2;
  color: white;
  align-self: flex-end;
  margin-left: auto;
  border-bottom-right-radius: 4px;
}

/* Assistant Messages (left-aligned) */
.chat-panel .bubble.assistant {
  background: #f0f0f0;
  color: #333;
  align-self: flex-start;
  margin-right: auto;
  border-bottom-left-radius: 4px;
}

/* Scrollbar Styling */
.chat-panel::-webkit-scrollbar {
  width: 6px;
}

.chat-panel::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.05);
  border-radius: 3px;
}

.chat-panel::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.2);
  border-radius: 3px;
}

.chat-panel::-webkit-scrollbar-thumb:hover {
  background: rgba(0, 0, 0, 0.3);
}

/* Fade-in Animation */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Mic Button */
.mic-btn {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: #1976d2;
  color: white;
  border: none;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  cursor: pointer;
  z-index: 10025;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
}

.mic-btn:hover {
  background: #1565c0;
  transform: scale(1.1);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2);
}

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

.mic-btn.active {
  background: #d32f2f;
  animation: pulse 1.5s infinite;
}

.mic-btn svg {
  width: 24px;
  height: 24px;
  fill: currentColor;
}

/* Pulse Animation for Active Recording */
@keyframes pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(211, 47, 47, 0.7);
  }
  70% {
    box-shadow: 0 0 0 20px rgba(211, 47, 47, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(211, 47, 47, 0);
  }
}

/* Mobile Responsive Adjustments */
@media (max-width: 768px) {
  .chat-panel {
    right: 0.5rem;
    bottom: 4.5rem;
    width: calc(100vw - 1rem);
    max-width: none;
    font-size: 14px;
  }
  
  .chat-panel .bubble {
    max-width: 90%;
  }
  
  .mic-btn {
    right: 0.5rem;
    bottom: 0.5rem;
  }
}

/* Dark Mode Support (if needed) */
@media (prefers-color-scheme: dark) {
  .chat-panel {
    background: rgba(30, 30, 30, 0.95);
    color: #f0f0f0;
  }
  
  .chat-panel .bubble.assistant {
    background: #424242;
    color: #f0f0f0;
  }
}

/* Add these styles to the end of chat.css */

/* Disabled state when assistant is speaking */
.mic-btn.disabled {
  background: #9e9e9e;
  cursor: not-allowed;
  opacity: 0.6;
}

.mic-btn.disabled:hover {
  background: #9e9e9e;
  transform: none;
}

/* Visual feedback for when assistant is speaking */
.chat-panel .bubble.assistant.speaking {
  animation: pulse-soft 2s infinite;
}

@keyframes pulse-soft {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.7;
  }
}

/* Add a small status indicator */
.mic-status {
  position: absolute;
  bottom: -20px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 11px;
  color: #666;
  white-space: nowrap;
  pointer-events: none;
}

/* Update the mic button to show state */
.mic-btn::after {
  content: '';
  position: absolute;
  bottom: -22px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 11px;
  color: #666;
  white-space: nowrap;
}

.mic-btn.active::after {
  content: 'Listening...';
  color: #d32f2f;
}

.mic-btn.disabled::after {
  content: 'Assistant speaking';
  color: #9e9e9e;
}