/* ============================================
   S3 Systems — Chat Widget Styles
   ============================================ */

/* --- Floating Button --- */
.chat-toggle {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  width: 56px;
  height: 56px;
  border: 1px solid var(--accent-dim);
  background: rgba(10, 14, 23, 0.95);
  backdrop-filter: blur(12px);
  color: var(--accent);
  cursor: pointer;
  z-index: 999;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.4), 0 0 20px rgba(0, 180, 255, 0.08);
}
.chat-toggle:hover {
  border-color: var(--accent-glow);
  box-shadow: 0 4px 30px rgba(0, 0, 0, 0.5), 0 0 30px rgba(0, 180, 255, 0.15);
  transform: translateY(-2px);
}
.chat-toggle svg {
  width: 24px;
  height: 24px;
  transition: transform 0.3s;
}
.chat-toggle.active svg {
  transform: rotate(90deg);
}

/* Pulse ring on idle */
.chat-toggle::before {
  content: '';
  position: absolute;
  inset: -4px;
  border: 1px solid var(--accent-dim);
  opacity: 0;
  animation: chat-pulse 3s ease-in-out infinite;
}
@keyframes chat-pulse {
  0%, 100% { opacity: 0; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(1.08); }
}
.chat-toggle.active::before {
  display: none;
}

/* --- Chat Panel --- */
.chat-panel {
  position: fixed;
  bottom: 6rem;
  right: 2rem;
  width: 380px;
  max-height: 520px;
  background: rgba(10, 14, 23, 0.97);
  backdrop-filter: blur(20px);
  border: 1px solid var(--border);
  z-index: 998;
  display: flex;
  flex-direction: column;
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.5), 0 0 30px rgba(0, 180, 255, 0.05);
  opacity: 0;
  transform: translateY(12px) scale(0.97);
  pointer-events: none;
  transition: all 0.25s ease-out;
}
.chat-panel.open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

/* Header */
.chat-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.chat-header-dot {
  width: 8px;
  height: 8px;
  background: #00ff88;
  border-radius: 50%;
  box-shadow: 0 0 8px rgba(0, 255, 136, 0.4);
  animation: dot-blink 2s ease-in-out infinite;
}
@keyframes dot-blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}
.chat-header-info h4 {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text);
  line-height: 1;
  margin-bottom: 0.2rem;
}
.chat-header-info span {
  font-size: 0.65rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
}

/* Messages */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  min-height: 280px;
  max-height: 340px;
}
.chat-messages::-webkit-scrollbar {
  width: 4px;
}
.chat-messages::-webkit-scrollbar-track {
  background: transparent;
}
.chat-messages::-webkit-scrollbar-thumb {
  background: var(--border);
}

.chat-msg {
  max-width: 85%;
  padding: 0.75rem 1rem;
  font-size: 0.85rem;
  line-height: 1.6;
  animation: msg-in 0.25s ease-out;
}
@keyframes msg-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.chat-msg.bot {
  align-self: flex-start;
  background: rgba(0, 180, 255, 0.06);
  border: 1px solid var(--border);
  color: var(--text);
}
.chat-msg.user {
  align-self: flex-end;
  background: rgba(0, 180, 255, 0.12);
  border: 1px solid var(--accent-dim);
  color: var(--text);
}

/* Typing indicator */
.chat-typing {
  display: flex;
  gap: 4px;
  padding: 0.75rem 1rem;
  align-self: flex-start;
}
.chat-typing span {
  width: 6px;
  height: 6px;
  background: var(--accent);
  border-radius: 50%;
  opacity: 0.4;
  animation: typing 1.2s ease-in-out infinite;
}
.chat-typing span:nth-child(2) { animation-delay: 0.15s; }
.chat-typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes typing {
  0%, 60%, 100% { opacity: 0.4; transform: translateY(0); }
  30% { opacity: 1; transform: translateY(-4px); }
}

/* Input */
.chat-input {
  display: flex;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}
.chat-input input {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text);
  padding: 0.85rem 1rem;
  font-family: inherit;
  font-size: 0.85rem;
  outline: none;
}
.chat-input input::placeholder {
  color: var(--text-dim);
}
.chat-input button {
  background: none;
  border: none;
  border-left: 1px solid var(--border);
  color: var(--accent);
  padding: 0 1rem;
  cursor: pointer;
  transition: all 0.2s;
}
.chat-input button:hover {
  background: rgba(0, 180, 255, 0.06);
}

/* --- Responsive --- */
@media (max-width: 480px) {
  .chat-panel {
    right: 0.75rem;
    left: 0.75rem;
    bottom: 5rem;
    width: auto;
    max-height: 70vh;
  }
  .chat-toggle {
    bottom: 1.25rem;
    right: 1.25rem;
    width: 48px;
    height: 48px;
  }
}
