@import url("/site-tokens.css");

.chat-page {
  --chat-accent: #3d9b66;
  --chat-accent-soft: rgba(61, 155, 102, 0.14);
  --chat-accent-glow: rgba(61, 155, 102, 0.35);
  --chat-panel: #111110;
  --chat-panel-2: #161615;
  --chat-ink: var(--text);
  --chat-muted: var(--muted);
  --chat-line: var(--border);
  --chat-radius: 12px;
  --chat-bubble: #1a1a18;
  --chat-bubble-border: #2a2a28;
  font-family: "Manrope", var(--font-sans);
  background:
    radial-gradient(ellipse 90% 60% at 50% -20%, rgba(61, 155, 102, 0.08), transparent 55%),
    var(--bg);
  color: var(--chat-ink);
  min-height: 100dvh;
}

.chat-page .shell-header {
  background: var(--bg);
  border-bottom-color: var(--chat-line);
}

.chat-wrap {
  max-width: 32rem;
  margin: 0 auto;
  padding: clamp(1.25rem, 4vw, 2rem) var(--gutter) 3rem;
}

.chat-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.chat-top__title {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.chat-top__sub {
  margin: 0.25rem 0 0;
  font-size: 0.8125rem;
  color: var(--chat-muted);
}

.chat-live {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.3rem 0.65rem;
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--chat-accent);
  background: var(--chat-accent-soft);
  border: 1px solid rgba(61, 155, 102, 0.35);
  border-radius: 999px;
}

.chat-live::before {
  content: "";
  width: 0.4rem;
  height: 0.4rem;
  border-radius: 50%;
  background: var(--chat-accent);
  box-shadow: 0 0 0 3px var(--chat-accent-soft);
  animation: chat-pulse 2s ease-in-out infinite;
}

@keyframes chat-pulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.45;
  }
}

.chat-panel {
  display: flex;
  flex-direction: column;
  min-height: min(70dvh, 36rem);
  border: 1px solid var(--chat-line);
  border-radius: var(--chat-radius);
  background: linear-gradient(180deg, var(--chat-panel) 0%, #0e0e0d 100%);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.04) inset,
    0 24px 48px rgba(0, 0, 0, 0.35);
  overflow: hidden;
}

.chat-log-wrap {
  position: relative;
  flex: 1;
  min-height: 18rem;
  display: flex;
  flex-direction: column;
}

.chat-log {
  list-style: none;
  margin: 0;
  padding: 1rem 1rem 0.5rem;
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  scroll-behavior: smooth;
}

.chat-log::-webkit-scrollbar {
  width: 6px;
}

.chat-log::-webkit-scrollbar-thumb {
  background: #333330;
  border-radius: 99px;
}

.chat-empty {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0;
  padding: 2rem;
  text-align: center;
  font-size: 0.875rem;
  line-height: 1.5;
  color: var(--chat-muted);
  pointer-events: none;
}

.chat-empty.is-hidden {
  display: none;
}

.chat-announce {
  padding: 0 1rem 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.chat-announce[hidden] {
  display: none !important;
}

.chat-announce__card {
  padding: 0.65rem 0.75rem;
  border-radius: 10px;
  border: 1px solid rgba(196, 165, 116, 0.35);
  background: linear-gradient(135deg, #1f1a14 0%, #161412 100%);
}

.chat-announce__card[data-severity="warn"] {
  border-color: rgba(196, 154, 108, 0.45);
  background: linear-gradient(135deg, #221a12 0%, #161210 100%);
}

.chat-announce__card[data-severity="critical"],
.chat-announce__card[data-severity="error"] {
  border-color: rgba(196, 92, 92, 0.45);
  background: linear-gradient(135deg, #221414 0%, #161010 100%);
}

.chat-announce__tag {
  display: inline-block;
  margin-bottom: 0.35rem;
  font-size: 0.625rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--chat-accent);
}

.chat-announce__title {
  margin: 0 0 0.2rem;
  font-size: 0.8125rem;
  font-weight: 600;
}

.chat-announce__body {
  margin: 0;
  font-size: 0.8125rem;
  line-height: 1.45;
  color: #c8c4bc;
}

.chat-msg {
  display: flex;
  align-items: flex-end;
  gap: 0.5rem;
  margin: 0;
  max-width: min(85%, 20rem);
  animation: chat-in 0.22s ease-out;
}

.chat-msg--self {
  align-self: flex-end;
  flex-direction: row-reverse;
  margin-left: auto;
}

@keyframes chat-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.chat-msg__avatar {
  flex-shrink: 0;
  width: 2.1rem;
  height: 2.1rem;
  border-radius: 10px;
  display: grid;
  place-items: center;
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: #f2f0ec;
  background: var(--chat-avatar-bg, #3d5a4a);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.chat-msg__bubble {
  width: fit-content;
  max-width: 100%;
  padding: 0.5rem 0.7rem;
  border-radius: 12px 12px 12px 4px;
  background: var(--chat-bubble);
  border: 1px solid var(--chat-bubble-border);
}

.chat-msg--self .chat-msg__bubble {
  border-radius: 12px 12px 4px 12px;
  background: linear-gradient(135deg, #1e2a22 0%, #161f19 100%);
  border-color: rgba(61, 155, 102, 0.35);
}

.chat-msg__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.2rem;
}

.chat-msg__user {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--chat-ink);
}

.chat-msg__time {
  flex-shrink: 0;
  font-family: "JetBrains Mono", var(--font-mono);
  font-size: 0.625rem;
  color: var(--chat-muted);
}

.chat-msg__body {
  margin: 0;
  font-size: 0.875rem;
  line-height: 1.45;
  color: #d8d4cc;
  word-break: break-word;
}

.chat-msg--loader:not(.chat-msg--self) .chat-msg__bubble {
  border-color: rgba(130, 80, 220, 0.25);
  background: linear-gradient(135deg, #1a161f 0%, #141218 100%);
}

.chat-msg--loader .chat-msg__user {
  color: #c9b0e8;
}

.chat-msg--self .chat-msg__user {
  color: var(--chat-accent);
}

.chat-compose {
  display: flex;
  align-items: stretch;
  gap: 0.5rem;
  padding: 0.75rem;
  border-top: 1px solid var(--chat-line);
  background: var(--chat-panel-2);
}

.chat-compose__field {
  flex: 1;
  min-width: 0;
}

.chat-input {
  width: 100%;
  height: 100%;
  min-height: 2.65rem;
  padding: 0.6rem 0.85rem;
  border: 1px solid var(--chat-line);
  border-radius: 8px;
  background: #0c0c0b;
  color: var(--chat-ink);
  font: inherit;
  font-size: 0.875rem;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.chat-input::placeholder {
  color: var(--chat-muted);
}

.chat-input:focus {
  outline: none;
  border-color: var(--chat-accent);
  box-shadow: 0 0 0 3px var(--chat-accent-soft);
}

.chat-input:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.chat-send {
  flex-shrink: 0;
  min-width: 4.25rem;
  padding: 0 1.1rem;
  border: none;
  border-radius: 8px;
  background: linear-gradient(180deg, #47b374 0%, var(--chat-accent) 100%);
  color: var(--accent-text);
  font: inherit;
  font-size: 0.8125rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.12s, filter 0.12s, opacity 0.12s;
}

.chat-send:hover:not(:disabled) {
  filter: brightness(1.06);
}

.chat-send:active:not(:disabled) {
  transform: scale(0.98);
}

.chat-send:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.chat-foot {
  margin: 0;
  padding: 0.5rem 0.85rem 0.75rem;
  font-size: 0.75rem;
  line-height: 1.4;
  color: var(--chat-muted);
  min-height: 1.25rem;
}

.chat-foot.is-error {
  color: var(--danger);
}

@media (max-width: 480px) {
  .chat-wrap {
    max-width: none;
  }

  .chat-top__sub {
    display: none;
  }
}
