﻿:root {
  --chat-font: "Space Grotesk", "Segoe UI", sans-serif;
  --chat-title-font: "Space Grotesk", "Segoe UI", sans-serif;

  --chat-primary: #2ea8ff;
  --chat-accent: #0b5cff;
  --chat-text: #eaf2ff;
  --chat-muted: #9bb0d0;

  --chat-border: #162338;
  --chat-border-2: #1c2a44;

  --chat-bg: #0b1220;
  --chat-surface: #0f1728;
  --chat-soft: #0a121f;

  --chat-radius: 18px;
  --chat-radius-sm: 14px;

  --chat-shadow: 0 16px 40px -20px rgba(6, 10, 18, 0.8);
  --chat-shadow-soft: 0 8px 24px -16px rgba(6, 10, 18, 0.7);
}

* { box-sizing: border-box; }

.chat-fab {
  position: fixed;
  right: 18px;
  bottom: 18px;
  width: 56px;
  height: 56px;
  border: 0;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--chat-primary), var(--chat-accent));
  box-shadow: var(--chat-shadow);
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: transform 160ms ease, box-shadow 160ms ease, filter 160ms ease;
  z-index: 9999;
}

.chat-fab:hover {
  transform: translateY(-1px);
  box-shadow: 0 18px 44px -22px rgba(6, 10, 18, 0.9);
}

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

.chat-fab svg { filter: drop-shadow(0 6px 10px rgba(0, 0, 0, 0.25)); }

@keyframes fabPulse {
  0%, 100% { filter: saturate(1); transform: translateY(0); }
  50% { filter: saturate(1.15); transform: translateY(-1px); }
}

.chat-panel {
  position: fixed;
  right: 18px;
  bottom: 86px;
  width: min(380px, calc(100vw - 36px));
  height: 560px;
  max-height: calc(100vh - 120px);
  border: 1px solid var(--chat-border);
  border-radius: var(--chat-radius);
  background: var(--chat-bg);
  box-shadow: var(--chat-shadow);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(14px) scale(0.98);
  transition:
    opacity 220ms ease,
    transform 260ms cubic-bezier(.2,.8,.2,1),
    visibility 0s linear 260ms;
  z-index: 9999;
  will-change: transform, opacity;
}

.chat-panel.open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translateY(0) scale(1);
  transition:
    opacity 220ms ease,
    transform 260ms cubic-bezier(.2,.8,.2,1),
    visibility 0s linear 0s;
  animation: panelPop 260ms cubic-bezier(.2,.8,.2,1) both;
}

@keyframes panelPop {
  0% { transform: translateY(16px) scale(0.975); opacity: 0; }
  100% { transform: translateY(0) scale(1); opacity: 1; }
}

.chat-panel.open ~ .chat-fab { animation: none; }

.chat-header {
  padding: 14px 14px 12px 14px;
  border-bottom: 1px solid var(--chat-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: linear-gradient(135deg, rgba(46, 168, 255, 0.12), rgba(11, 92, 255, 0.16));
}

.chat-title {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}

.chat-title strong {
  font-family: var(--chat-title-font);
  font-size: 15px;
  letter-spacing: 0.2px;
  color: var(--chat-text);
}

.chat-title span {
  font-size: 12px;
  color: var(--chat-muted);
  margin-top: 2px;
  font-family: var(--chat-font);
}

.chat-close {
  border: 1px solid var(--chat-border-2);
  background: rgba(255, 255, 255, 0.04);
  color: var(--chat-text);
  border-radius: 12px;
  padding: 8px 10px;
  cursor: pointer;
  transition: transform 120ms ease, box-shadow 120ms ease, border-color 120ms ease;
}

.chat-close:hover {
  border-color: var(--chat-accent);
  box-shadow: 0 0 0 4px rgba(46, 168, 255, 0.12);
}

.chat-close:active { transform: scale(0.98); }

.chat-messages {
  padding: 14px;
  flex: 1;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--chat-soft);
}

.chat-gate {
  position: absolute;
  inset: 56px 0 0 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(6, 10, 18, 0.82);
  z-index: 5;
}

.chat-gate.hidden { display: none; }

.chat-gate-card {
  width: min(320px, 90%);
  background: var(--chat-surface);
  border: 1px solid var(--chat-border);
  border-radius: 16px;
  box-shadow: var(--chat-shadow-soft);
  padding: 14px;
  font-family: var(--chat-font);
  color: var(--chat-text);
}

.chat-gate-card strong {
  display: block;
  font-size: 14px;
  margin-bottom: 6px;
  color: var(--chat-text);
}

.chat-gate-card p {
  font-size: 12px;
  color: var(--chat-muted);
  margin: 0 0 10px 0;
}

.chat-gate-label {
  font-size: 12px;
  color: var(--chat-muted);
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

.chat-gate-label input {
  margin-top: 2px;
  width: 18px;
  height: 18px;
  border-radius: 5px;
  border: 1.5px solid rgba(46, 168, 255, 0.7);
  background: rgba(6, 10, 18, 0.9);
  display: grid;
  place-items: center;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  transition: border-color 140ms ease, box-shadow 140ms ease, background 140ms ease;
}

.chat-gate-label input:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(46, 168, 255, 0.25);
}

.chat-gate-label input:checked {
  border-color: transparent;
  background: linear-gradient(135deg, var(--chat-primary), var(--chat-accent));
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0%200%2012%209'%3E%3Cpath d='M1%205l3%203%207-7' fill='none' stroke='%23ffffff' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: center;
  background-size: 12px 9px;
}

.chat-gate-label a {
  color: var(--chat-primary);
  text-decoration: none;
}

.chat-gate-label a:hover { text-decoration: underline; }

.chat-gate-confirm {
  margin-top: 10px;
  width: 100%;
  height: 38px;
  border: 0;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--chat-primary), var(--chat-accent));
  color: #03101f;
  font-weight: 600;
  cursor: pointer;
  box-shadow: var(--chat-shadow-soft);
}

.chat-gate-confirm:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  filter: grayscale(0.15);
}

.chat-gate-status {
  margin-top: 8px;
  font-size: 12px;
  color: var(--chat-muted);
  min-height: 16px;
}

.msg {
  max-width: 82%;
  padding: 10px 12px;
  border-radius: 16px;
  border: 1px solid var(--chat-border);
  background: var(--chat-surface);
  white-space: pre-wrap;
  word-wrap: break-word;
  font-size: 13px;
  line-height: 1.35;
  font-family: var(--chat-font);
  color: var(--chat-text);
  box-shadow: 0 6px 14px rgba(2, 6, 12, 0.35);
}

.msg.bot {
  align-self: flex-start;
  border-radius: 16px 16px 16px 6px;
}

.msg.user {
  align-self: flex-end;
  border-radius: 16px 16px 6px 16px;
  border-color: rgba(46, 168, 255, 0.35);
  background: linear-gradient(135deg, rgba(46, 168, 255, 0.16), rgba(11, 92, 255, 0.18));
}

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

.msg { animation: msgIn 160ms ease both; }

.typing {
  display: inline-flex;
  gap: 6px;
  align-items: center;
  padding: 10px 12px;
  border-radius: 16px 16px 16px 6px;
  border: 1px solid var(--chat-border);
  background: var(--chat-surface);
  width: fit-content;
  box-shadow: 0 6px 14px rgba(2, 6, 12, 0.35);
}

.dot {
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: rgba(46, 168, 255, 0.75);
  animation: bounce 1s infinite ease-in-out;
}

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

@keyframes bounce {
  0%, 80%, 100% { transform: translateY(0); opacity: 0.55; }
  40% { transform: translateY(-4px); opacity: 1; }
}

.chat-input:disabled {
  background: #0b1220;
  color: rgba(155, 176, 208, 0.6);
  cursor: not-allowed;
}

.chat-composer {
  border-top: 1px solid var(--chat-border);
  padding: 10px;
  display: flex;
  gap: 10px;
  background: var(--chat-bg);
}

.chat-input {
  flex: 1;
  resize: none;
  border-radius: var(--chat-radius-sm);
  border: 1.5px solid var(--chat-border-2);
  background: #0a121f;
  color: var(--chat-text);
  padding: 10px 12px;
  outline: none;
  height: 42px;
  max-height: 120px;
  font-size: 13px;
  font-family: var(--chat-font);
  transition:
    border 150ms cubic-bezier(0.4,0,0.2,1),
    box-shadow 150ms cubic-bezier(0.4,0,0.2,1);
}

.chat-input::placeholder { color: rgba(155, 176, 208, 0.6); }

.chat-input:focus {
  border: 1.5px solid rgba(46, 168, 255, 0.7);
  box-shadow: 0 0 0 4px rgba(46, 168, 255, 0.14);
}

.chat-send {
  width: 44px;
  height: 42px;
  border-radius: var(--chat-radius-sm);
  border: 0;
  cursor: pointer;
  background: linear-gradient(135deg, var(--chat-primary), var(--chat-accent));
  display: grid;
  place-items: center;
  box-shadow: var(--chat-shadow-soft);
  transition: transform 120ms ease, opacity 120ms ease, filter 120ms ease;
}

.chat-send:hover { opacity: 0.96; }
.chat-send:active { transform: scale(0.99); }

.chat-send:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  filter: grayscale(0.15);
}

@media (prefers-reduced-motion: reduce) {
  .chat-panel,
  .chat-panel.open,
  .msg,
  .dot,
  .chat-fab {
    animation: none !important;
    transition: none !important;
  }
}
