/* ─────────────────────────────────────────────────────────────────────────
   Football Intelligence — Floating SportGPT Chat Widget
   Faza 5.11-revamp, replaces dedicated #chat page route.

   - Fab button: fixed bottom-right (z-index above content).
   - Panel: slide-up from fab origin, 400×550px desktop, full-screen <600px.
   - Reuses design tokens (--accent, --surface-1/2/3, --border, --divider).
   - prefers-reduced-motion: wszystkie transitions/animations opt-out.
   ───────────────────────────────────────────────────────────────────────── */


.chat-widget {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 1000;
  pointer-events: none;
}
.chat-widget > * { pointer-events: auto; }


/* === Fab button ======================================================== */

/* F5.16-tweak: asymmetric pill tab — drop generic circle. Top-right + bot-left
   corners are pill-rounded, top-left + bot-right are sharply rounded — creates
   subtle "tab pulling out from the right edge" feel zamiast floating circle. */
.chat-widget__fab {
  position: relative;
  height: 44px;
  padding: 0 16px 0 14px;
  background: var(--surface-1);
  color: var(--text-primary);
  border: 1px solid var(--accent);
  border-radius: 22px 6px 22px 6px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: var(--weight-semibold);
  letter-spacing: 0.02em;
  box-shadow: 0 10px 28px -8px rgba(0, 0, 0, 0.55),
              0 0 0 4px rgba(0, 229, 160, 0.08);
  transition: transform var(--duration-fast) var(--easing-out),
              box-shadow var(--duration-fast) var(--easing-out),
              background-color var(--duration-fast) var(--easing-out);
}
.chat-widget__fab:hover {
  background: var(--surface-2);
  transform: translateY(-1px);
  box-shadow: 0 14px 32px -8px rgba(0, 0, 0, 0.65),
              0 0 0 5px rgba(0, 229, 160, 0.14);
}
.chat-widget__fab:active { transform: translateY(0); }

.chat-widget__fab-logo {
  width: 22px;
  height: 22px;
  display: block;
  flex-shrink: 0;
}
.chat-widget__fab-label {
  font-feature-settings: 'ss01' on;
  white-space: nowrap;
}
.chat-widget__fab-badge {
  position: absolute;
  top: -6px;
  right: -6px;
  background: #ef4444;
  color: #fff;
  font-size: 0.65rem;
  font-weight: var(--weight-extrabold);
  padding: 2px 6px;
  border-radius: var(--radius-pill);
  border: 2px solid var(--bg, #060a0f);
  line-height: 1;
}
@media (prefers-reduced-motion: reduce) {
  .chat-widget__fab { transition: none; }
  .chat-widget__fab:hover { transform: none; }
}


/* === Slide-up panel ==================================================== */

.chat-widget__panel {
  position: absolute;
  bottom: 60px;
  right: 0;
  width: 400px;
  height: 550px;
  max-height: calc(100vh - 120px);
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: 0 24px 60px -10px rgba(0, 0, 0, 0.7), 0 8px 20px rgba(0, 0, 0, 0.4);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: chat-widget-slide 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  transform-origin: bottom right;
}
@keyframes chat-widget-slide {
  from { opacity: 0; transform: translateY(12px) scale(0.96); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
@media (prefers-reduced-motion: reduce) {
  .chat-widget__panel { animation: none; }
}


/* === Panel header ====================================================== */

.chat-widget__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border-bottom: 1px solid var(--divider);
  background: var(--surface-2);
  flex-shrink: 0;
}
.chat-widget__head-title {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: var(--weight-semibold);
  color: var(--text-primary);
}
.chat-widget__head-icon {
  width: 22px;
  height: 22px;
  display: inline-block;
  vertical-align: middle;
}
.chat-widget__head-meta {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.chat-widget__plan-pill {
  display: inline-block;
  font-size: 0.55rem;
  font-weight: var(--weight-extrabold);
  letter-spacing: 0.08em;
  padding: 2px 7px;
  border-radius: var(--radius-pill);
  background: var(--surface-3);
  color: var(--text-tertiary);
}
.chat-widget__plan-pill--pro,
.chat-widget__plan-pill--elite,
.chat-widget__plan-pill--unlimited {
  background: var(--accent-soft);
  color: var(--accent);
}
.chat-widget__head-btn {
  background: transparent;
  border: none;
  color: var(--text-tertiary);
  cursor: pointer;
  font-size: 1.1rem;
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background-color var(--duration-fast) var(--easing-out),
              color var(--duration-fast) var(--easing-out);
}
.chat-widget__head-btn:hover {
  background: var(--surface-3);
  color: var(--text-primary);
}


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

.chat-widget__thread {
  flex: 1;
  overflow-y: auto;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scrollbar-width: thin;
}
.chat-widget__thread::-webkit-scrollbar { width: 6px; }
.chat-widget__thread::-webkit-scrollbar-thumb {
  background: var(--surface-3);
  border-radius: 3px;
}

.chat-widget__msg {
  max-width: 90%;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  display: flex;
  flex-direction: column;
  gap: 4px;
  word-wrap: break-word;
  animation: chat-widget-msg-in 0.25s ease-out;
}
@keyframes chat-widget-msg-in {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}
@media (prefers-reduced-motion: reduce) {
  .chat-widget__msg { animation: none; }
}
.chat-widget__msg-head {
  font-size: 0.58rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-weight: var(--weight-bold);
}
.chat-widget__msg-body {
  white-space: pre-line;
  line-height: 1.5;
  font-size: 0.88rem;
  color: var(--text-primary);
}
/* F5.16-tweak v3: SportGPT bold highlight (parsed z **double asterisks**).
   Accent color + subtle underline dla stake/odds/picks visibility. */
.chat-widget__hl {
  color: var(--accent);
  font-weight: var(--weight-bold);
  border-bottom: 1px dotted rgba(0, 229, 160, 0.35);
  padding-bottom: 1px;
}
.chat-widget__msg--user {
  align-self: flex-end;
  background: var(--accent-soft);
  border: 1px solid rgba(0, 229, 160, 0.2);
}
.chat-widget__msg--user .chat-widget__msg-head { color: var(--accent); }
.chat-widget__msg--ai {
  align-self: flex-start;
  background: var(--surface-2);
  border: 1px solid var(--border);
}


/* === DEMO banner inline w AI message =================================== */

.chat-widget__demo-banner {
  margin-top: 8px;
  padding: 8px 10px;
  background: var(--surface-3);
  border-left: 2px solid var(--accent);
  border-radius: var(--radius-sm);
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.chat-widget__demo-summary {
  font-size: 0.78rem;
  color: var(--text-primary);
}
.chat-widget__demo-summary strong { color: var(--accent); }
.chat-widget__demo-cta {
  font-size: 0.78rem;
  padding: 4px 10px;
  align-self: flex-start;
}


/* === Typing dots ======================================================= */

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


/* === Empty state ======================================================= */

.chat-widget__empty {
  padding: 8px 4px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.chat-widget__empty p { margin: 0; line-height: 1.5; font-size: 0.88rem; }
.chat-widget__suggestions {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.chat-widget__suggestions li {
  padding: 10px 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  color: var(--text-secondary);
  cursor: pointer;
  transition: background-color var(--duration-fast) var(--easing-out),
              border-color var(--duration-fast) var(--easing-out);
}
.chat-widget__suggestions li:hover {
  background: rgba(0, 229, 160, 0.05);
  border-color: rgba(0, 229, 160, 0.2);
}


/* === Input bar ========================================================= */

.chat-widget__inputbar {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid var(--divider);
  background: var(--surface-2);
}
.chat-widget__input {
  flex: 1;
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  padding: 8px 10px;
  resize: none;
  min-height: 36px;
  max-height: 120px;
  font: inherit;
  font-size: 0.88rem;
  line-height: 1.4;
  outline: none;
  font-family: inherit;
  overflow-y: auto;
}
.chat-widget__input:focus {
  border-color: rgba(0, 229, 160, 0.4);
}
.chat-widget__send {
  font-size: 0.82rem;
  padding: 6px 14px;
  white-space: nowrap;
}
.chat-widget__hint {
  margin: 0;
  padding: 6px 12px;
  text-align: center;
  background: var(--surface-2);
  border-top: 1px solid var(--divider);
}


/* === Mobile ≤767px — FAB above dock + floating panel (not full-bleed) ===

   F5.17.c-fix: FAB raised above dock. Panel is a clearly-floating card with
   visible margins on ALL sides — not full-screen. Owner: "shouldn't cover the
   whole screen". 70vh cap + side/top gap so the page shows behind it. */

@media (max-width: 767px) {
  .chat-widget {
    bottom: calc(72px + env(safe-area-inset-bottom));
    right: 14px;
  }
  .chat-widget__fab {
    /* P1.16 audit fix: raised from 40 → 44px so the FAB hits WCAG 2.5.5
       (minimum 44×44 touch target). */
    height: 44px;
    padding: 0 14px 0 12px;
    font-size: 0.78rem;
  }
  /* Floating panel: fixed, inset 14px on left/right, top gap ~80px (clears
     sticky header), height capped at 70vh so the page is always visible
     behind the panel. Not full-bleed on any side. */
  .chat-widget__panel {
    position: fixed;
    bottom: calc(72px + env(safe-area-inset-bottom) + 8px);
    right: 14px;
    left: 14px;
    width: auto;
    height: 70vh;
    max-height: min(70vh, calc(100vh - 160px));
  }
}
