/* ═══════════════════════════════════════════════════════════
   ParlayBuilder – Chatbot Styles
   Matches "Customize Your Build" modal styling conventions.
   ═══════════════════════════════════════════════════════════ */

/* ── FAB Button ─────────────────────────────────────────── */
.pb-chat-fab {
  position: fixed;
  bottom: calc(var(--pb-bottom-nav-height, 64px) + env(safe-area-inset-bottom, 0px) + 16px);
  right: 20px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: none;
  background: var(--theme-gradient-primary, linear-gradient(135deg, #00F5D4, #00D3BD, #00AD84));
  color: #000;
  font-size: 24px;
  cursor: pointer;
  z-index: 1300;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 16px rgba(0, 211, 189, 0.35);
  transition: transform 0.2s, box-shadow 0.2s;
}
.pb-chat-fab:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 24px rgba(0, 211, 189, 0.45);
}
.pb-chat-fab:active { transform: scale(0.96); }

/* Hide on cover page */
body.cover-active .pb-chat-fab,
body.cover-active .pb-chat-panel { display: none !important; }

/* Chatbot is in development — hide the FAB + any open panel everywhere
   until the feature is ready to ship. The DOM still mounts (tracking /
   keyboard shortcuts that key off the elements keep working) but the
   user never sees an entry point. Drop these rules to re-enable. */
.pb-chat-fab,
.pb-chat-panel { display: none !important; }

/* Body scroll lock when chat is open (mobile) */
html.pb-chat-lock,
body.pb-chat-lock {
  overflow: hidden !important;
  overscroll-behavior: none;
}

/* ── Chat Panel (desktop) ──────────────────────────────── */
.pb-chat-panel {
  position: fixed;
  bottom: 80px;
  right: 20px;
  width: 520px;
  max-height: 820px;
  background: var(--theme-bg-base, #0a1628);
  border: 1px solid rgba(var(--theme-accent-rgb, 0, 211, 189), 0.22);
  border-radius: 20px;
  z-index: 1300;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(10px);
  opacity: 0;
  transform: translateY(16px) scale(0.96);
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
}
.pb-chat-panel.open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

/* ── Panel Header ───────────────────────────────────────── */
.pb-chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 16px 14px;
  border-bottom: 1px solid rgba(var(--theme-accent-rgb, 0, 211, 189), 0.12);
  flex-shrink: 0;
}
.pb-chat-header-left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.pb-chat-header-title {
  font-weight: 700;
  font-size: 20px;
  color: var(--theme-text-primary, #e8ffe9);
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}
.pb-chat-header-title::before { display: none; }
.pb-chat-header-stats {
  font-size: 10px;
  color: rgba(255,255,255,0.3);
  white-space: nowrap;
}
.pb-chat-close {
  width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(255,255,255,0.12);
  border: none;
  border-radius: 10px;
  color: #d6fffa;
  font-size: 16px;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.15s;
}
.pb-chat-close:hover { background: rgba(255,255,255,0.2); }

/* ── Messages Area ──────────────────────────────────────── */
.pb-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 12px;
  min-height: 0;
}
.pb-chat-messages::-webkit-scrollbar { width: 4px; }
.pb-chat-messages::-webkit-scrollbar-track { background: transparent; }
.pb-chat-messages::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.12);
  border-radius: 2px;
}

/* ── Empty State Placeholder ───────────────────────────── */
.pb-chat-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  flex: 1;
  padding: 40px 24px;
  text-align: center;
  color: rgba(255,255,255,0.35);
}
.pb-chat-placeholder-icon {
  font-size: 36px;
  color: var(--theme-accent, #00D3BD);
  opacity: 0.6;
}
.pb-chat-placeholder-text {
  font-size: 17px;
  font-weight: 600;
  color: rgba(255,255,255,0.5);
  line-height: 1.5;
}

/* ── Message Bubbles ────────────────────────────────────── */
.pb-chat-msg {
  max-width: 88%;
  padding: 11px 15px;
  border-radius: 14px;
  font-size: 15.5px;
  line-height: 1.6;
  word-wrap: break-word;
  overflow-wrap: break-word;
}
.pb-chat-msg-user {
  align-self: flex-end;
  background: rgba(var(--theme-accent-rgb, 0, 211, 189), 0.75);
  color: var(--theme-text-on-accent, #0a1628);
  border-bottom-right-radius: 4px;
  font-weight: 500;
}
.pb-chat-msg-assistant {
  align-self: flex-start;
  background: rgba(255,255,255,0.06);
  color: var(--theme-text-secondary, #e8ffe9);
  border-bottom-left-radius: 4px;
}

/* Markdown */
.pb-chat-msg-assistant strong { color: var(--theme-accent, #00D3BD); font-weight: 600; }
.pb-chat-msg-assistant .pb-chat-h2,
.pb-chat-msg-assistant .pb-chat-h3 {
  display: block;
  color: var(--theme-accent, #00D3BD);
  margin-top: 6px;
}
.pb-chat-msg-assistant .pb-chat-h2 { font-size: 1.1em; }
.pb-chat-msg-assistant .pb-chat-h3 { font-size: 1em; }
.pb-chat-msg-assistant em { font-style: italic; }
.pb-chat-msg-assistant code {
  background: rgba(255,255,255,0.08);
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 13px;
}
.pb-chat-msg-assistant ul,
.pb-chat-msg-assistant ol { margin: 4px 0; padding-left: 18px; }
.pb-chat-msg-assistant li { margin: 2px 0; }

/* Inline team logos */
.pb-chat-logo {
  width: 1.2em;
  height: 1.2em;
  vertical-align: -0.15em;
  margin-right: 2px;
  object-fit: contain;
  display: inline;
}

/* Player name links */
.pb-chat-player-link {
  color: var(--theme-accent, #00D3BD);
  cursor: pointer;
  font-weight: 600;
}

/* Token usage (dev) */
.pb-chat-usage {
  align-self: flex-start;
  font-size: 10px;
  color: rgba(255,255,255,0.25);
  padding: 2px 0 0 4px;
}

/* ── Add-to-Parlay Buttons ──────────────────────────────── */
.pb-chat-parlay-legs {
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-self: flex-start;
  max-width: 92%;
}
.pb-chat-add-leg {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(var(--theme-accent-rgb, 0, 211, 189), 0.12);
  border: 1px solid rgba(var(--theme-accent-rgb, 0, 211, 189), 0.35);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 13px;
  color: var(--theme-text-secondary, #e8ffe9);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  text-align: left;
  line-height: 1.35;
}
.pb-chat-add-leg:hover {
  background: rgba(var(--theme-accent-rgb, 0, 211, 189), 0.22);
  border-color: rgba(var(--theme-accent-rgb, 0, 211, 189), 0.5);
}
.pb-chat-add-leg:disabled { cursor: default; opacity: 0.7; }
.pb-chat-add-leg.added {
  background: rgba(var(--theme-accent-rgb, 0, 211, 189), 0.06);
  border-color: rgba(var(--theme-accent-rgb, 0, 211, 189), 0.12);
  color: rgba(255,255,255,0.4);
}
.pb-chat-add-all {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--theme-accent, #00D3BD);
  border: none;
  border-radius: 8px;
  padding: 9px 14px;
  font-size: 13px;
  font-weight: 600;
  color: var(--theme-text-on-accent, #0a1628);
  cursor: pointer;
  transition: opacity 0.15s;
  text-align: left;
  line-height: 1.35;
}
.pb-chat-add-all:hover { opacity: 0.85; }
.pb-chat-add-all:disabled { cursor: default; opacity: 0.5; }
.pb-chat-add-all.added {
  background: rgba(var(--theme-accent-rgb, 0, 211, 189), 0.15);
  color: var(--theme-accent, #00D3BD);
}

/* ── Follow-up suggestion chips ──────────────────────── */
.pb-chat-followups {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-self: flex-start;
  max-width: 92%;
  padding-top: 4px;
}
.pb-chat-followup {
  background: rgba(var(--theme-accent-rgb, 0, 211, 189), 0.08);
  border: 1px solid rgba(var(--theme-accent-rgb, 0, 211, 189), 0.28);
  border-radius: 16px;
  padding: 6px 14px;
  font-size: 13px;
  color: var(--theme-accent, #00D3BD);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  white-space: nowrap;
}
.pb-chat-followup:hover {
  background: rgba(var(--theme-accent-rgb, 0, 211, 189), 0.18);
  border-color: rgba(var(--theme-accent-rgb, 0, 211, 189), 0.45);
}

/* Typing indicator */
.pb-chat-typing {
  align-self: flex-start;
  padding: 10px 14px;
  background: rgba(255,255,255,0.06);
  border-radius: 14px;
  border-bottom-left-radius: 4px;
  font-size: 14px;
  color: rgba(255,255,255,0.4);
}
.pb-chat-typing::after {
  content: "...";
  animation: pb-chat-dots 1.2s infinite;
}
@keyframes pb-chat-dots {
  0%, 20% { content: "."; }
  40% { content: ".."; }
  60%, 100% { content: "..."; }
}

/* ── Suggested Starters (carousel) ─────────────────────── */
.pb-chat-starters-wrap {
  position: relative;
  flex-shrink: 0;
  padding: 0;
}
.pb-chat-starters-track {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  padding: 0 16px 8px;
}
.pb-chat-starters-track::-webkit-scrollbar { display: none; }

.pb-chat-starters-col {
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex-shrink: 0;
}
.pb-chat-starter {
  background: rgba(var(--theme-accent-rgb, 0, 211, 189), 0.12);
  border: 1px solid rgba(var(--theme-accent-rgb, 0, 211, 189), 0.35);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 13.5px;
  color: var(--theme-text-secondary, #e8ffe9);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
  text-align: left;
}
.pb-chat-starter:hover {
  background: rgba(var(--theme-accent-rgb, 0, 211, 189), 0.22);
  color: #fff;
  border-color: rgba(var(--theme-accent-rgb, 0, 211, 189), 0.5);
}
.pb-chat-starters-arrow {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: none;
  background: rgba(255,255,255,0.12);
  color: #fff;
  font-size: 13px;
  cursor: pointer;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
}
.pb-chat-starters-arrow:hover { background: rgba(255,255,255,0.22); }
.pb-chat-starters-arrow.left { left: 2px; }
.pb-chat-starters-arrow.right { right: 2px; }

/* ── Input Area ─────────────────────────────────────────── */
.pb-chat-input-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid rgba(var(--theme-accent-rgb, 0, 211, 189), 0.12);
  flex-shrink: 0;
}
.pb-chat-input {
  flex: 1;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(var(--theme-accent-rgb, 0, 211, 189), 0.22);
  border-radius: 10px;
  padding: 11px 14px;
  font-size: 15.5px;
  color: #fff;
  max-height: 80px;
  overflow-y: auto;
  line-height: 1.4;
  font-family: inherit;
  outline: none;
  -webkit-user-select: text;
  user-select: text;
  word-wrap: break-word;
  overflow-wrap: break-word;
  white-space: pre-wrap;
}
.pb-chat-input:empty::before {
  content: "Ask about NBA stats, props, matchups\2026";
  color: rgba(255,255,255,0.3);
  pointer-events: none;
}
.pb-chat-input:focus { border-color: rgba(var(--theme-accent-rgb, 0, 211, 189), 0.6); }

.pb-chat-send {
  background: var(--theme-accent, #00D3BD);
  border: none;
  border-radius: 10px;
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--theme-text-on-accent, #0a1628);
  font-size: 15px;
  flex-shrink: 0;
  transition: opacity 0.15s;
}
.pb-chat-send:disabled { opacity: 0.4; cursor: default; }

/* ═══════════════════════════════════════════════════════════
   Mobile / Tablet – max-width 1000px
   Matches Customize Your Build modal mobile layout.
   ═══════════════════════════════════════════════════════════ */
@media (max-width: 1000px) {

  /* ── Backdrop (overlay) ──────────────────────────────── */
  .pb-chat-backdrop {
    display: none;
    position: fixed;
    top: 0;
    bottom: -400px;
    left: 0;
    right: 0;
    background: var(--theme-bg-primary, #0D1117);
    z-index: 1299;
  }
  .pb-chat-backdrop.open {
    display: block;
  }

  /* ── FAB ──────────────────────────────────────────────── */
  .pb-chat-fab {
    right: 16px;
    width: 70px;
    height: 70px;
    font-size: 30px;
  }

  /* ── Panel → card style, covers bottom nav ───────────── */
  .pb-chat-panel {
    position: fixed;
    top: calc(env(safe-area-inset-top, 0px) + 140px);
    bottom: -400px !important;
    left: 0;
    right: 0;
    width: 100%;
    max-width: 960px;
    max-height: none;
    margin: 0 auto;
    padding: 0;
    padding-bottom: 400px;
    border-radius: 24px 24px 0 0;
    border: none;
    border-top: 1px solid rgba(var(--theme-accent-rgb, 0, 211, 189), 0.22);
    box-shadow: 0 -8px 40px rgba(0, 0, 0, 0.4);
  }

  /* ── Header ──────────────────────────────────────────── */
  .pb-chat-header {
    padding: 22px 24px;
    padding-right: 86px; /* room for close btn */
    position: relative;
    gap: 14px;
  }
  .pb-chat-header-title {
    font-size: 46px;
    font-weight: 700;
  }
  .pb-chat-header-title::before {
    font-size: 40px;
  }
  .pb-chat-header-stats {
    font-size: 22px;
  }
  .pb-chat-close {
    position: absolute;
    top: 18px;
    right: 14px;
    width: 60px;
    height: 60px;
    border-radius: 14px;
    font-size: 36px;
  }

  /* ── Messages ────────────────────────────────────────── */
  .pb-chat-messages {
    padding: 20px 18px;
    gap: 18px;
  }
  .pb-chat-messages::-webkit-scrollbar { width: 6px; }

  .pb-chat-msg {
    max-width: 92%;
    font-size: 46px;
    padding: 20px 24px;
    line-height: 1.45;
    border-radius: 20px;
  }
  .pb-chat-msg-user { border-bottom-right-radius: 6px; }
  .pb-chat-msg-assistant { border-bottom-left-radius: 6px; }

  .pb-chat-msg-assistant code {
    font-size: 38px;
    padding: 2px 8px;
    border-radius: 6px;
  }
  .pb-chat-msg-assistant ul,
  .pb-chat-msg-assistant ol { padding-left: 32px; margin: 8px 0; }
  .pb-chat-msg-assistant li { margin: 4px 0; }

  /* ── Input ───────────────────────────────────────────── */
  .pb-chat-input-wrap {
    padding: 16px 18px calc(16px + env(safe-area-inset-bottom, 0px));
    gap: 12px;
  }
  .pb-chat-input {
    font-size: 46px;
    padding: 18px 20px;
    border-radius: 14px;
  }
  .pb-chat-send {
    width: 70px;
    height: 70px;
    font-size: 30px;
    border-radius: 14px;
  }

  /* ── Starters carousel ─────────────────────────────────── */
  .pb-chat-starters-track {
    padding: 0 18px 16px;
    gap: 12px;
  }
  .pb-chat-starters-col { gap: 12px; }
  .pb-chat-starter {
    font-size: 38px;
    padding: 16px 22px;
    border-radius: 14px;
    white-space: nowrap;
  }
  .pb-chat-starters-arrow {
    width: 52px;
    height: 52px;
    font-size: 24px;
  }
  .pb-chat-starters-arrow.left { left: 4px; }
  .pb-chat-starters-arrow.right { right: 4px; }

  /* ── Placeholder ───────────────────────────────────────── */
  .pb-chat-placeholder { padding: 60px 32px; }
  .pb-chat-placeholder-icon { font-size: 60px; }
  .pb-chat-placeholder-text { font-size: 38px; }

  /* ── Add-to-Parlay ───────────────────────────────────── */
  .pb-chat-parlay-legs { gap: 14px; }
  .pb-chat-add-leg {
    font-size: 38px;
    padding: 16px 20px;
    border-radius: 14px;
    gap: 12px;
  }
  .pb-chat-add-all {
    font-size: 38px;
    padding: 16px 20px;
    border-radius: 14px;
    gap: 12px;
  }

  /* ── Follow-up chips ────────────────────────────────── */
  .pb-chat-followups { gap: 12px; padding-top: 8px; }
  .pb-chat-followup {
    font-size: 38px;
    padding: 14px 22px;
    border-radius: 24px;
  }

  /* ── Typing ──────────────────────────────────────────── */
  .pb-chat-typing {
    font-size: 42px;
    padding: 20px 24px;
    border-radius: 20px;
    border-bottom-left-radius: 6px;
  }

  /* ── Usage tag ───────────────────────────────────────── */
  .pb-chat-usage {
    font-size: 22px;
    padding: 4px 0 0 6px;
  }
}
