/* ============================================================
   BlueCortex — Chatbot Stylesheet v1.0
   Cohesive with Claymorphism Design System Tokens
   ============================================================ */

/* Chat Floating Action Button */
.chat-fab {
  position: fixed;
  bottom: 1.75rem;
  right: 1.75rem;
  z-index: 1000;
  width: 3.5rem;
  height: 3.5rem;
  border-radius: 50%;
  background: var(--gradient-primary);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 24px rgba(0, 74, 198, 0.35);
  cursor: pointer;
  border: none;
  outline: none;
  transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275), box-shadow 0.3s ease;
}

.chat-fab:hover {
  transform: scale(1.1) translateY(-2px);
  box-shadow: 0 12px 32px rgba(0, 74, 198, 0.45);
}

.chat-fab:active {
  transform: scale(0.95);
}

/* Pulse ring animation */
.chat-fab::before {
  content: '';
  position: absolute;
  border: 3px solid var(--color-primary);
  border-radius: 50%;
  width: 100%;
  height: 100%;
  top: 0;
  left: 0;
  box-sizing: border-box;
  animation: chatPulse 2.2s cubic-bezier(0.24, 0, 0.38, 1) infinite;
  pointer-events: none;
}

@keyframes chatPulse {
  0%   { transform: scale(1); opacity: 0.75; }
  75%  { transform: scale(1.6); opacity: 0; }
  100% { transform: scale(1.6); opacity: 0; }
}

/* Chat Container Panel */
.chat-panel {
  position: fixed;
  bottom: 5.75rem;
  right: 1.75rem;
  z-index: 1001;
  width: 380px;
  height: 520px;
  max-height: calc(100vh - 8rem);
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(16px) saturate(120%);
  -webkit-backdrop-filter: blur(16px) saturate(120%);
  border: 1px solid rgba(0, 74, 198, 0.12);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-hover);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  transform: scale(0.9) translateY(20px);
  transform-origin: bottom right;
  pointer-events: none;
  transition: opacity 0.3s cubic-bezier(0.25, 0.8, 0.25, 1), transform 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}

.chat-panel.open {
  opacity: 1;
  transform: scale(1) translateY(0);
  pointer-events: auto;
}

/* Chat Header */
.chat-header {
  background: var(--gradient-primary);
  padding: 1rem 1.25rem;
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.chat-header-profile {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.chat-mascot {
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
  border: 1.5px solid rgba(255, 255, 255, 0.8);
  object-fit: cover;
}

.chat-header-info {
  display: flex;
  flex-direction: column;
}

.chat-title {
  font-family: var(--font-display);
  font-weight: var(--fw-bold);
  font-size: 0.95rem;
  line-height: 1.2;
}

.chat-status {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.75rem;
  opacity: 0.9;
}

.chat-status-dot {
  width: 6px;
  height: 6px;
  background: #10b981;
  border-radius: 50%;
  display: inline-block;
  box-shadow: 0 0 8px #10b981;
  animation: statusPulse 1.8s infinite;
}

@keyframes statusPulse {
  0% { opacity: 0.5; }
  50% { opacity: 1; }
  100% { opacity: 0.5; }
}

.chat-close-btn {
  background: rgba(255, 255, 255, 0.15);
  border: none;
  color: #ffffff;
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.2s ease, transform 0.2s ease;
}

.chat-close-btn:hover {
  background: rgba(255, 255, 255, 0.3);
  transform: rotate(90deg);
}

/* Chat Messages Area */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.875rem;
  scroll-behavior: smooth;
  background: rgba(249, 249, 255, 0.6);
}

/* Custom Scrollbar for Messages */
.chat-messages::-webkit-scrollbar {
  width: 6px;
}
.chat-messages::-webkit-scrollbar-track {
  background: transparent;
}
.chat-messages::-webkit-scrollbar-thumb {
  background: rgba(0, 74, 198, 0.15);
  border-radius: 3px;
}
.chat-messages::-webkit-scrollbar-thumb:hover {
  background: rgba(0, 74, 198, 0.3);
}

/* Chat Bubbles */
.chat-bubble {
  max-width: 82%;
  padding: 0.75rem 1rem;
  font-size: 0.9rem;
  line-height: 1.45;
  font-family: var(--font-body);
  word-wrap: break-word;
  animation: bubbleFadeIn 0.3s ease forwards;
}

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

.chat-bubble.bot {
  align-self: flex-start;
  background: #ffffff;
  color: var(--color-on-surface);
  border-top-left-radius: var(--radius-md);
  border-top-right-radius: var(--radius-md);
  border-bottom-right-radius: var(--radius-md);
  border-bottom-left-radius: 0.2rem;
  box-shadow: 0 2px 8px rgba(0, 74, 198, 0.05);
  border: 1px solid rgba(0, 74, 198, 0.05);
}

.chat-bubble.user {
  align-self: flex-end;
  background: var(--gradient-primary);
  color: #ffffff;
  border-top-left-radius: var(--radius-md);
  border-top-right-radius: var(--radius-md);
  border-bottom-left-radius: var(--radius-md);
  border-bottom-right-radius: 0.2rem;
  box-shadow: 0 4px 12px rgba(0, 74, 198, 0.15);
}

.chat-bubble p {
  margin: 0 0 0.5rem 0;
}
.chat-bubble p:last-child {
  margin-bottom: 0;
}
.chat-bubble ul, .chat-bubble ol {
  margin: 0.5rem 0;
  padding-left: 1.25rem;
}
.chat-bubble li {
  margin-bottom: 0.25rem;
}
.chat-bubble li:last-child {
  margin-bottom: 0;
}

/* Chat Footer / Input Area */
.chat-footer {
  background: #ffffff;
  padding: 0.75rem 1rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  border-top: 1px solid rgba(0, 74, 198, 0.08);
}

.chat-input-wrapper {
  flex: 1;
  background: var(--color-surface-container-low);
  border-radius: var(--radius-full);
  padding: 0.5rem 1.25rem;
  display: flex;
  align-items: center;
  border: 1px solid rgba(0, 74, 198, 0.05);
  transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.chat-input-wrapper:focus-within {
  border-color: rgba(0, 74, 198, 0.3);
  box-shadow: 0 0 0 3px rgba(0, 74, 198, 0.1);
  background: #ffffff;
}

.chat-input {
  width: 100%;
  border: none;
  background: transparent;
  outline: none;
  font-family: var(--font-body);
  font-size: 0.9rem;
  color: var(--color-on-surface);
  padding: 0.25rem 0;
  resize: none;
  max-height: 80px;
}

.chat-input::placeholder {
  color: var(--color-on-surface-variant);
  opacity: 0.6;
}

.chat-send-btn {
  background: var(--gradient-primary);
  color: #ffffff;
  border: none;
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 4px 10px rgba(0, 74, 198, 0.2);
  transition: transform 0.2s ease, background 0.2s ease, opacity 0.2s ease;
  flex-shrink: 0;
}

.chat-send-btn:hover {
  transform: scale(1.08);
  background: var(--color-primary-container);
}

.chat-send-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

/* Typing Indicator Animation */
.typing-indicator {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px 4px;
}

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

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

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

/* Responsive Mobile Layout */
@media (max-width: 576px) {
  .chat-panel {
    bottom: 0;
    right: 0;
    width: 100%;
    height: 100%;
    max-height: 100%;
    border-radius: 0;
    border: none;
    transform: translateY(100%);
    transform-origin: bottom center;
  }
  
  .chat-panel.open {
    transform: translateY(0);
  }
  
  .chat-close-btn {
    width: 2.5rem;
    height: 2.5rem;
  }

  .chat-header {
    padding: 1.25rem 1rem;
  }
}
