/* ========================================================================
   AXIAL CHATBOT — Thomas
   ======================================================================== */

.chat-launcher {
  position: fixed;
  bottom: 28px;
  right: 28px;
  width: 66px;
  height: 66px;
  z-index: 1000;
  background: linear-gradient(135deg, var(--cyan) 0%, var(--cyan-hi) 100%);
  border: 1px solid var(--cyan-hi);
  clip-path: polygon(14px 0, 100% 0, calc(100% - 14px) 100%, 0 100%);
  box-shadow: 0 0 30px var(--cyan-glow), 0 10px 30px rgba(0, 0, 0, 0.5);
  display: grid;
  place-items: center;
  color: var(--bg-black);
  transition: transform .25s ease, box-shadow .25s ease;
  animation: pulseLauncher 3s ease-in-out infinite;
}
.chat-launcher:hover {
  transform: translateY(-3px) scale(1.04);
  box-shadow: 0 0 45px var(--cyan-hi), 0 12px 36px rgba(0, 0, 0, 0.6);
}
.chat-launcher svg { width: 30px; height: 30px; }
.chat-launcher.hidden { opacity: 0; pointer-events: none; transform: scale(0.8); }
@keyframes pulseLauncher {
  0%, 100% { box-shadow: 0 0 30px var(--cyan-glow), 0 10px 30px rgba(0, 0, 0, 0.5); }
  50%      { box-shadow: 0 0 50px var(--cyan-hi), 0 10px 30px rgba(0, 0, 0, 0.5); }
}

.chat-panel {
  position: fixed;
  bottom: 28px;
  right: 28px;
  width: 400px;
  max-width: calc(100vw - 32px);
  height: 620px;
  max-height: calc(100vh - 56px);
  z-index: 1001;
  background:
    linear-gradient(135deg, rgba(13, 19, 28, 0.98) 0%, rgba(4, 7, 12, 0.98) 100%);
  border: 1px solid var(--cyan);
  clip-path: polygon(
    0 18px, 18px 0,
    calc(100% - 36px) 0, 100% 36px,
    100% calc(100% - 18px), calc(100% - 18px) 100%,
    36px 100%, 0 calc(100% - 36px)
  );
  box-shadow: 0 0 50px var(--cyan-glow), 0 30px 80px rgba(0, 0, 0, 0.7);
  display: flex;
  flex-direction: column;
  opacity: 0;
  pointer-events: none;
  transform: translateY(20px) scale(0.96);
  transform-origin: bottom right;
  transition: opacity .3s ease, transform .3s ease;
  overflow: hidden;
}
.chat-panel.open {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0) scale(1);
}

.chat-panel::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 50% 0%, var(--cyan-glow-soft) 0%, transparent 40%);
  pointer-events: none;
}

.chat-header {
  padding: 1.25rem 1.5rem 1.15rem;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 1rem;
  position: relative;
  z-index: 1;
  background: rgba(4, 7, 12, 0.5);
}
.chat-avatar {
  width: 46px;
  height: 46px;
  background: url('../img/axial-logo.jpg') center/cover;
  border: 1px solid var(--cyan);
  box-shadow: 0 0 14px var(--cyan-glow);
  clip-path: polygon(6px 0, 100% 0, calc(100% - 6px) 100%, 0 100%);
  flex: 0 0 46px;
}
.chat-who .name {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--text-bright);
  letter-spacing: 0.08em;
}
.chat-who .status {
  font-family: var(--font-body);
  font-size: 0.78rem;
  color: var(--text-dim);
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-top: 2px;
}
.chat-who .status::before {
  content: '';
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #2fff88;
  box-shadow: 0 0 8px #2fff88;
  animation: blinkDot 2s ease-in-out infinite;
}
@keyframes blinkDot {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.4; }
}
.chat-close {
  margin-left: auto;
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  color: var(--text-dim);
  transition: color .2s ease, border-color .2s ease;
}
.chat-close:hover { color: var(--cyan); border-color: var(--cyan); }

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
  scrollbar-width: thin;
  scrollbar-color: var(--cyan-dim) transparent;
  position: relative;
  z-index: 1;
}
.chat-messages::-webkit-scrollbar { width: 6px; }
.chat-messages::-webkit-scrollbar-thumb {
  background: var(--cyan-dim);
  border-radius: 3px;
}

.msg {
  max-width: 85%;
  padding: 0.85rem 1.1rem;
  font-size: 0.95rem;
  line-height: 1.5;
  position: relative;
  white-space: pre-wrap;
  word-wrap: break-word;
}
.msg.bot {
  align-self: flex-start;
  background: rgba(0, 229, 255, 0.08);
  border: 1px solid rgba(0, 229, 255, 0.3);
  color: var(--text);
  clip-path: polygon(
    0 10px, 10px 0,
    100% 0, 100% calc(100% - 10px),
    calc(100% - 10px) 100%, 0 100%
  );
}
.msg.user {
  align-self: flex-end;
  background: linear-gradient(135deg, var(--cyan) 0%, var(--cyan-hi) 100%);
  color: var(--bg-black);
  font-weight: 500;
  clip-path: polygon(
    0 0, 100% 0, 100% 10px,
    calc(100% - 10px) 100%,
    10px 100%, 0 calc(100% - 10px)
  );
  box-shadow: 0 0 18px var(--cyan-glow-soft);
}
.msg.error {
  align-self: flex-start;
  background: rgba(255, 80, 80, 0.1);
  border: 1px solid rgba(255, 80, 80, 0.4);
  color: #ff8f8f;
}

.msg.bot .cursor {
  display: inline-block;
  width: 8px;
  height: 14px;
  background: var(--cyan);
  vertical-align: text-bottom;
  margin-left: 2px;
  animation: blinkCursor 1s steps(2) infinite;
  box-shadow: 0 0 6px var(--cyan-glow);
}
@keyframes blinkCursor {
  50% { opacity: 0; }
}

.typing {
  display: inline-flex;
  gap: 4px;
  padding: 4px 0;
}
.typing span {
  width: 6px;
  height: 6px;
  background: var(--cyan);
  border-radius: 50%;
  box-shadow: 0 0 6px var(--cyan-glow);
  animation: typeBounce 1.2s ease-in-out infinite;
}
.typing span:nth-child(2) { animation-delay: 0.15s; }
.typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes typeBounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30%           { transform: translateY(-6px); opacity: 1; }
}

.chat-form {
  padding: 1rem 1.25rem 1.25rem;
  border-top: 1px solid var(--line);
  background: rgba(4, 7, 12, 0.6);
  position: relative;
  z-index: 1;
}
.chat-input-wrap {
  display: flex;
  gap: 0.6rem;
  align-items: flex-end;
}
.chat-input {
  flex: 1;
  background: rgba(4, 7, 12, 0.8);
  border: 1px solid var(--line);
  color: var(--text-bright);
  font-family: var(--font-body);
  font-size: 0.95rem;
  padding: 0.8rem 1rem;
  resize: none;
  min-height: 46px;
  max-height: 120px;
  transition: border-color .2s ease, box-shadow .2s ease;
}
.chat-input:focus {
  outline: none;
  border-color: var(--cyan);
  box-shadow: 0 0 0 2px var(--cyan-glow-soft);
}
.chat-send {
  width: 46px;
  height: 46px;
  background: linear-gradient(135deg, var(--cyan), var(--cyan-hi));
  color: var(--bg-black);
  display: grid;
  place-items: center;
  clip-path: polygon(10px 0, 100% 0, calc(100% - 10px) 100%, 0 100%);
  box-shadow: 0 0 16px var(--cyan-glow);
  transition: transform .2s ease, box-shadow .2s ease;
  flex: 0 0 46px;
}
.chat-send:hover {
  transform: translateY(-2px);
  box-shadow: 0 0 24px var(--cyan-hi);
}
.chat-send:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}
.chat-send svg { width: 20px; height: 20px; }

.chat-footer-note {
  font-size: 0.7rem;
  color: var(--text-dim);
  margin-top: 0.6rem;
  text-align: center;
  letter-spacing: 0.08em;
  font-family: var(--font-display);
  text-transform: uppercase;
}

@media (max-width: 520px) {
  .chat-panel {
    right: 12px;
    left: 12px;
    bottom: 12px;
    width: auto;
    max-width: none;
    height: calc(100vh - 24px);
  }
  .chat-launcher { right: 18px; bottom: 18px; }
}
