/* Project Chimera — Chat Widget + Topology Styles */

/* ── Topology Canvas ── */
.topology-section {
  margin: 2rem auto 0;
  max-width: 900px;
  height: 280px;
  position: relative;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(0, 212, 170, 0.08);
  border-radius: 6px;
  overflow: hidden;
}
#topology-canvas {
  display: block;
  width: 100%;
  height: 100%;
}

/* ── Chat Toggle Button ── */
.chat-toggle {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: 2px solid rgba(0, 212, 170, 0.4);
  background: rgba(0, 212, 170, 0.15);
  color: #00d4aa;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  transition: all 0.3s ease;
  box-shadow: 0 0 20px rgba(0, 212, 170, 0.15);
}
.chat-toggle:hover {
  background: rgba(0, 212, 170, 0.25);
  border-color: #00d4aa;
  box-shadow: 0 0 30px rgba(0, 212, 170, 0.25);
  transform: scale(1.05);
}
.chat-toggle:focus-visible {
  outline: 2px solid #00d4aa;
  outline-offset: 3px;
}

/* ── Chat Panel ── */
.chat-panel {
  position: fixed;
  bottom: 90px;
  right: 24px;
  width: 380px;
  max-height: 540px;
  background: rgba(10, 10, 18, 0.95);
  border: 1px solid rgba(0, 212, 170, 0.15);
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  z-index: 999;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.5), 0 0 60px rgba(0, 212, 170, 0.05);
  transform: translateY(20px);
  opacity: 0;
  pointer-events: none;
  transition: all 0.35s cubic-bezier(0.22, 1, 0.36, 1);
}
.chat-open.chat-panel {
  transform: translateY(0);
  opacity: 1;
  pointer-events: all;
}

/* Header */
.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid rgba(0, 212, 170, 0.1);
}
.chat-header-title {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.8rem;
  font-weight: 600;
  color: #00d4aa;
  letter-spacing: 0.5px;
}
.chat-close {
  background: none;
  border: none;
  color: rgba(200, 200, 220, 0.5);
  cursor: pointer;
  font-size: 1.1rem;
  padding: 4px;
  line-height: 1;
  transition: color 0.2s;
}
.chat-close:hover { color: #e8e8f5; }
.chat-close:focus-visible {
  outline: 2px solid #00d4aa;
  outline-offset: 2px;
  border-radius: 3px;
}

/* Messages */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 14px 16px;
  min-height: 200px;
  max-height: 350px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.chat-messages::-webkit-scrollbar {
  width: 4px;
}
.chat-messages::-webkit-scrollbar-track {
  background: transparent;
}
.chat-messages::-webkit-scrollbar-thumb {
  background: rgba(0, 212, 170, 0.2);
  border-radius: 3px;
}

.chat-msg {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  max-width: 90%;
}
.chat-msg-user {
  align-self: flex-end;
  flex-direction: row-reverse;
}
.chat-msg-assistant {
  align-self: flex-start;
}

.chat-avatar {
  width: 30px;
  min-width: 30px;
  height: 30px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.7rem;
  font-weight: 700;
  margin-top: 2px;
}
.chat-msg-user .chat-avatar {
  background: rgba(0, 212, 170, 0.2);
  color: #00d4aa;
  border: 1px solid rgba(0, 212, 170, 0.25);
}
.chat-msg-assistant .chat-avatar {
  background: rgba(245, 158, 11, 0.15);
  color: #f59e0b;
  border: 1px solid rgba(245, 158, 11, 0.2);
}

.chat-bubble {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 0.85rem;
  line-height: 1.5;
  color: #c8c8dc;
  word-break: break-word;
}
.chat-msg-user .chat-bubble {
  background: rgba(0, 212, 170, 0.08);
  border-color: rgba(0, 212, 170, 0.12);
  color: #e0f5ef;
}

/* Typing dots */
.chat-dot {
  animation: chatDot 1.4s infinite;
  font-size: 1.4rem;
  line-height: 0.5;
  opacity: 0.4;
}
.chat-dot:nth-child(2) { animation-delay: 0.2s; }
.chat-dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes chatDot {
  0%, 80%, 100% { opacity: 0.3; }
  40% { opacity: 1; }
}

/* Input */
.chat-input-area {
  display: flex;
  gap: 8px;
  padding: 12px 16px 14px;
  border-top: 1px solid rgba(0, 212, 170, 0.1);
  align-items: flex-end;
}
.chat-input {
  flex: 1;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  padding: 10px 14px;
  color: #e8e8f5;
  font-family: 'Inter', sans-serif;
  font-size: 0.85rem;
  line-height: 1.4;
  resize: none;
  min-height: 40px;
  max-height: 100px;
}
.chat-input:focus {
  border-color: rgba(0, 212, 170, 0.3);
  outline: none;
  box-shadow: 0 0 0 2px rgba(0, 212, 170, 0.06);
}
.chat-input::placeholder {
  color: rgba(200, 200, 220, 0.3);
}

.chat-send {
  background: rgba(0, 212, 170, 0.15);
  border: 1px solid rgba(0, 212, 170, 0.2);
  border-radius: 8px;
  color: #00d4aa;
  cursor: pointer;
  padding: 10px 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  transition: all 0.2s;
}
.chat-send:hover {
  background: rgba(0, 212, 170, 0.25);
  border-color: #00d4aa;
}
.chat-send:focus-visible {
  outline: 2px solid #00d4aa;
  outline-offset: 2px;
}

/* ── Move service section below topology ── */
#services-section {
  margin-top: 1rem;
}

/* ── Responsive ── */
@media (max-width: 640px) {
  .chat-panel {
    right: 12px;
    left: 12px;
    width: auto;
    bottom: 84px;
  }
  .chat-toggle {
    bottom: 16px;
    right: 16px;
    width: 50px;
    height: 50px;
  }
  .topology-section {
    height: 200px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .chat-panel { transition: none; }
  .chat-toggle { transition: none; }
  .chat-dot { animation: none; }
  .chat-dot { opacity: 0.5; }
}