/* ─────────────────────────────────────────────────────────────────────────
   Football Intelligence — SportGPT Chat page
   Faza 5.10-polish, redesign v2.

   Visual reference: 21st.dev `AnimatedAIChat` (Karol 2026-05-15) — ported
   z React+framer-motion do vanilla JS+CSS. Key elements:
   - 3 gradient blobs background (accent-only, NOT violet/fuchsia z 21st.dev
     bo Karol "single accent" hard rule)
   - Animated entrance (fade-in + slide-up keyframes)
   - Card backdrop-blur z subtle border
   - Auto-resize textarea (JS-side adjustHeight)
   - Typing dots (3 bouncing) — istniejące

   Reuses design tokens. Single accent (#00e5a0). prefers-reduced-motion
   respektuje wszystkie animacje.
   ───────────────────────────────────────────────────────────────────────── */


/* === Page shell z gradient blobs ======================================= */

.chat-page {
  max-width: 820px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  position: relative;
  isolation: isolate;
  animation: chat-entrance 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes chat-entrance {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* 3 absolute-positioned gradient blobs — accent green only z low opacity
   (single accent rule). animate-pulse-slow keyframe (24s cycle) — subtle,
   no distraction. */
.chat-page::before,
.chat-page::after {
  content: '';
  position: absolute;
  pointer-events: none;
  z-index: -1;
  border-radius: 50%;
  filter: blur(96px);
  opacity: 0.08;
  mix-blend-mode: normal;
}
.chat-page::before {
  top: -10%;
  left: -10%;
  width: 320px;
  height: 320px;
  background: var(--accent);
  animation: chat-blob-pulse 18s ease-in-out infinite;
}
.chat-page::after {
  bottom: 5%;
  right: -10%;
  width: 280px;
  height: 280px;
  background: var(--accent-strong);
  animation: chat-blob-pulse 22s ease-in-out infinite reverse;
  animation-delay: 6s;
}
@keyframes chat-blob-pulse {
  0%, 100% { opacity: 0.06; transform: scale(1); }
  50%      { opacity: 0.10; transform: scale(1.15); }
}
@media (prefers-reduced-motion: reduce) {
  .chat-page { animation: none; }
  .chat-page::before, .chat-page::after { animation: none; }
}


/* === Header ============================================================ */

.chat-page__header {
  padding: var(--space-2) 0 0;
}
.chat-page__header h1 {
  margin: 0 0 4px;
  /* Subtle gradient text per 21st.dev reference — accent fade to text-primary */
  background: linear-gradient(135deg, var(--text-primary) 0%, rgba(255, 255, 255, 0.55) 100%);
  -webkit-background-clip: text;
          background-clip: text;
  -webkit-text-fill-color: transparent;
}
.chat-page__header p { margin: 0; }


/* === Main thread container ============================================== */

.chat-page__main {
  background: rgba(11, 17, 24, 0.4);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: var(--radius-md);
  min-height: 320px;
  max-height: 60vh;
  overflow-y: auto;
  padding: var(--space-2);
  box-shadow: 0 20px 50px -20px rgba(0, 0, 0, 0.5);
}


/* === Thread ============================================================ */

.chat-thread {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.chat-msg {
  max-width: 80%;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  display: flex;
  flex-direction: column;
  gap: 4px;
  word-wrap: break-word;
  animation: chat-msg-in 0.3s ease-out;
}
@keyframes chat-msg-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
@media (prefers-reduced-motion: reduce) {
  .chat-msg { animation: none; }
}

.chat-msg__head {
  font-size: 0.62rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  font-weight: var(--weight-bold);
}
.chat-msg__body {
  white-space: pre-line;
  line-height: 1.55;
  font-size: 0.95rem;
}

.chat-msg--user {
  align-self: flex-end;
  background: var(--accent-soft);
  border: 1px solid rgba(0, 229, 160, 0.2);
}
.chat-msg--user .chat-msg__head { color: var(--accent); }

.chat-msg--ai {
  align-self: flex-start;
  background: rgba(255, 255, 255, 0.025);
  border: 1px solid rgba(255, 255, 255, 0.05);
}

/* F5.11: DEMO simulator integration — structured_bet button banner pod AI
   message. Karol QA "Place this match in DEMO". */
.chat-msg__demo-banner {
  margin-top: 10px;
  padding: 10px 14px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-sm);
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.chat-msg__demo-summary {
  font-size: 0.85rem;
  color: var(--text-primary);
  font-weight: var(--weight-medium);
}
.chat-msg__demo-summary strong { color: var(--accent); }
.chat-msg__demo-cta {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
  align-self: flex-start;
}

/* Typing dots */
.chat-msg--typing .chat-msg__typing {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 0;
}
.chat-msg__typing span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-tertiary);
  animation: chat-typing 1.2s infinite ease-in-out;
}
.chat-msg__typing span:nth-child(2) { animation-delay: 0.15s; }
.chat-msg__typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes chat-typing {
  0%, 60%, 100% { opacity: 0.3; transform: translateY(0); }
  30%           { opacity: 1;   transform: translateY(-4px); }
}
@media (prefers-reduced-motion: reduce) {
  .chat-msg__typing span { animation: none; opacity: 0.6; }
}


/* === Empty state z suggestion chips ==================================== */

.chat-empty {
  text-align: center;
  padding: var(--space-3) var(--space-2);
}
.chat-empty p { margin: 0 0 10px; }
.chat-empty__hints {
  list-style: none;
  padding: 0;
  margin: var(--space-2) auto 0;
  max-width: 520px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  text-align: left;
}
.chat-empty__hints li {
  padding: 12px 16px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 0.9rem;
  cursor: pointer;
  transition: background-color var(--duration-fast) var(--easing-out),
              border-color var(--duration-fast) var(--easing-out),
              transform var(--duration-fast) var(--easing-out);
  font-style: normal;
}
.chat-empty__hints li:hover {
  background: rgba(0, 229, 160, 0.05);
  border-color: rgba(0, 229, 160, 0.2);
  transform: translateY(-1px);
}
@media (prefers-reduced-motion: reduce) {
  .chat-empty__hints li { transition: background-color var(--duration-fast); }
  .chat-empty__hints li:hover { transform: none; }
}


/* === Error banner ====================================================== */

.chat-error {
  margin: 0;
  padding: 10px 14px;
  background: rgba(239, 68, 68, 0.08);
  border: 1px solid rgba(239, 68, 68, 0.3);
  border-radius: var(--radius-sm);
  color: #ef4444;
}


/* === Input bar (sticky bottom feel) ==================================== */

.chat-inputbar {
  background: rgba(255, 255, 255, 0.02);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: border-color var(--duration-fast) var(--easing-out);
}
.chat-inputbar:focus-within {
  border-color: rgba(0, 229, 160, 0.3);
  box-shadow: 0 0 0 2px rgba(0, 229, 160, 0.08);
}
.chat-inputbar__input {
  width: 100%;
  background: transparent;
  border: none;
  color: var(--text-primary);
  font: inherit;
  font-size: 0.95rem;
  resize: none;
  min-height: 44px;
  max-height: 200px;
  outline: none;
  line-height: 1.5;
  font-family: inherit;
  overflow-y: auto;
}
.chat-inputbar__input::placeholder {
  color: rgba(255, 255, 255, 0.25);
}
.chat-inputbar__input:disabled {
  color: var(--text-tertiary);
  cursor: not-allowed;
}
.chat-inputbar__row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-top: 8px;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
}
.chat-inputbar__meta {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.78rem;
}
.chat-inputbar__plan {
  font-weight: var(--weight-bold);
  letter-spacing: 0.04em;
  color: var(--accent);
}
.chat-inputbar__send {
  /* Use existing btn--primary z subtle scale on press */
  transition: transform var(--duration-fast) var(--easing-out);
}
.chat-inputbar__send:active {
  transform: scale(0.97);
}
@media (prefers-reduced-motion: reduce) {
  .chat-inputbar__send { transition: none; }
  .chat-inputbar__send:active { transform: none; }
}


/* === Legal footer ====================================================== */

.chat-page__legal {
  text-align: center;
  padding: var(--space-2) 0;
  border-top: 1px solid var(--divider);
  line-height: 1.6;
}


/* === Mobile ============================================================ */

@media (max-width: 600px) {
  .chat-page__main { max-height: 50vh; padding: var(--space-1); }
  .chat-msg { max-width: 92%; padding: 10px 14px; }
  .chat-empty__hints li { font-size: 0.85rem; }
  .chat-page::before, .chat-page::after { display: none; }
}
