/* ============================================================
   AI Chatbot Widget — Romulo's AI Twin
   Dark mode. Nexus tokens. Floating bottom-right.
   ============================================================ */

/* Floating trigger pill */
.tzai-chat-fab {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9998;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 20px 14px 16px;
  background: linear-gradient(135deg, #d4ff3b 0%, #b8e600 100%);
  color: #0a0a0a;
  border: none;
  border-radius: 999px;
  font-family: 'Inter', sans-serif;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 8px 32px rgba(212, 255, 59, 0.35), 0 2px 8px rgba(0, 0, 0, 0.4);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  animation: tzai-fab-pulse 3s ease-in-out infinite;
}

.tzai-chat-fab:hover {
  transform: translateY(-2px) scale(1.04);
  box-shadow: 0 12px 40px rgba(212, 255, 59, 0.5), 0 3px 12px rgba(0, 0, 0, 0.5);
}

.tzai-chat-fab.is-open {
  animation: none;
  transform: scale(0.9);
  opacity: 0;
  pointer-events: none;
}

.tzai-chat-fab__icon {
  width: 22px;
  height: 22px;
  flex-shrink: 0;
}

@keyframes tzai-fab-pulse {
  0%, 100% { box-shadow: 0 8px 32px rgba(212, 255, 59, 0.35), 0 2px 8px rgba(0, 0, 0, 0.4); }
  50% { box-shadow: 0 8px 32px rgba(212, 255, 59, 0.55), 0 2px 8px rgba(0, 0, 0, 0.4), 0 0 0 8px rgba(212, 255, 59, 0.08); }
}

/* Chat panel */
.tzai-chat-panel {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9998;
  width: 380px;
  max-width: calc(100vw - 32px);
  height: 600px;
  max-height: calc(100vh - 48px);
  background:
    radial-gradient(circle at 20% 0%, rgba(212, 255, 59, 0.06), transparent 50%),
    #0a0a0a;
  border: 1px solid rgba(212, 255, 59, 0.2);
  border-radius: 20px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.65);
  display: flex;
  flex-direction: column;
  opacity: 0;
  visibility: hidden;
  transform: translateY(20px) scale(0.98);
  transition: opacity 0.28s ease, transform 0.28s cubic-bezier(0.16, 1, 0.3, 1), visibility 0.28s ease;
  overflow: hidden;
}

.tzai-chat-panel.is-open {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
}

/* Header */
.tzai-chat-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 18px 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(212, 255, 59, 0.03);
}

.tzai-chat-header__avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, #d4ff3b 0%, #b8e600 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #0a0a0a;
  font-family: 'Montserrat', sans-serif;
  font-weight: 900;
  font-size: 14px;
  letter-spacing: -0.02em;
  flex-shrink: 0;
}

.tzai-chat-header__meta {
  flex: 1;
  min-width: 0;
}

.tzai-chat-header__name {
  font-family: 'Inter', sans-serif;
  font-size: 14px;
  font-weight: 700;
  color: #fff;
  line-height: 1.2;
}

.tzai-chat-header__status {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 10px;
  color: rgba(255, 255, 255, 0.5);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 2px;
}

.tzai-chat-header__status::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #d4ff3b;
  box-shadow: 0 0 8px #d4ff3b;
  animation: tzai-status-pulse 2s ease-in-out infinite;
}

@keyframes tzai-status-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.tzai-chat-header__close {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: rgba(255, 255, 255, 0.7);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  line-height: 1;
  padding: 0;
  transition: all 0.18s ease;
}

.tzai-chat-header__close:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  transform: rotate(90deg);
}

/* Message list */
.tzai-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.15) transparent;
}

.tzai-chat-messages::-webkit-scrollbar { width: 6px; }
.tzai-chat-messages::-webkit-scrollbar-track { background: transparent; }
.tzai-chat-messages::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.15); border-radius: 3px; }

.tzai-msg {
  max-width: 88%;
  padding: 12px 14px;
  border-radius: 14px;
  font-family: 'Inter', sans-serif;
  font-size: 14px;
  line-height: 1.5;
  animation: tzai-msg-in 0.28s ease;
}

@keyframes tzai-msg-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.tzai-msg--bot {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: rgba(255, 255, 255, 0.9);
  align-self: flex-start;
  border-bottom-left-radius: 4px;
}

.tzai-msg--user {
  background: linear-gradient(135deg, #d4ff3b 0%, #b8e600 100%);
  color: #0a0a0a;
  align-self: flex-end;
  border-bottom-right-radius: 4px;
  font-weight: 500;
}

.tzai-msg a {
  color: #d4ff3b;
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.tzai-msg--user a { color: #0a0a0a; }

.tzai-msg p { margin: 0 0 8px; }
.tzai-msg p:last-child { margin-bottom: 0; }

/* Typing indicator */
.tzai-typing {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 14px 16px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 14px;
  border-bottom-left-radius: 4px;
  align-self: flex-start;
  animation: tzai-msg-in 0.28s ease;
}

.tzai-typing span {
  width: 6px;
  height: 6px;
  background: rgba(255, 255, 255, 0.5);
  border-radius: 50%;
  animation: tzai-typing 1.2s ease-in-out infinite;
}

.tzai-typing span:nth-child(2) { animation-delay: 0.15s; }
.tzai-typing span:nth-child(3) { animation-delay: 0.3s; }

@keyframes tzai-typing {
  0%, 60%, 100% { transform: scale(0.8); opacity: 0.4; }
  30% { transform: scale(1.2); opacity: 1; }
}

/* Error message */
.tzai-error {
  color: #ffb4b4;
  background: rgba(255, 100, 100, 0.08);
  border: 1px solid rgba(255, 100, 100, 0.25);
  font-family: 'Inter', sans-serif;
  font-size: 13px;
  line-height: 1.5;
  padding: 10px 14px;
  border-radius: 12px;
  align-self: stretch;
}

/* Input area */
.tzai-chat-input {
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  padding: 14px 16px;
  display: flex;
  gap: 8px;
  align-items: flex-end;
  background: rgba(0, 0, 0, 0.3);
}

.tzai-chat-input textarea {
  flex: 1;
  min-height: 40px;
  max-height: 120px;
  padding: 10px 14px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 20px;
  color: #fff;
  font-family: 'Inter', sans-serif;
  font-size: 14px;
  line-height: 1.4;
  resize: none;
  outline: none;
  transition: border-color 0.18s ease;
}

.tzai-chat-input textarea::placeholder {
  color: rgba(255, 255, 255, 0.35);
}

.tzai-chat-input textarea:focus {
  border-color: rgba(212, 255, 59, 0.5);
  background: rgba(255, 255, 255, 0.07);
}

.tzai-chat-input button {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, #d4ff3b 0%, #b8e600 100%);
  color: #0a0a0a;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: transform 0.18s ease, opacity 0.18s ease;
}

.tzai-chat-input button:hover:not(:disabled) {
  transform: scale(1.08);
}

.tzai-chat-input button:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.tzai-chat-input button svg {
  width: 18px;
  height: 18px;
}

/* Footer disclaimer */
.tzai-chat-disclaimer {
  padding: 8px 16px 12px;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 10px;
  color: rgba(255, 255, 255, 0.35);
  text-align: center;
  letter-spacing: 0.02em;
  line-height: 1.4;
  background: rgba(0, 0, 0, 0.3);
}

/* Mobile */
@media (max-width: 480px) {
  .tzai-chat-fab {
    bottom: 16px;
    right: 16px;
    padding: 12px 16px 12px 12px;
    font-size: 13px;
  }
  .tzai-chat-panel {
    bottom: 0;
    right: 0;
    left: 0;
    width: 100%;
    max-width: 100%;
    height: 100vh;
    max-height: 100vh;
    border-radius: 20px 20px 0 0;
    border-bottom: none;
  }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  .tzai-chat-fab, .tzai-chat-panel, .tzai-msg, .tzai-typing span,
  .tzai-chat-header__status::before, .tzai-chat-input textarea,
  .tzai-chat-input button, .tzai-chat-header__close {
    animation: none;
    transition: none;
  }
}
