/* PandaBet Live Chat Widget */
.chat-widget {
  position: fixed;
  bottom: max(20px, env(safe-area-inset-bottom, 0px));
  right: max(20px, env(safe-area-inset-right, 0px));
  z-index: 10000;
  font-family: var(--font, "Plus Jakarta Sans", system-ui, sans-serif);
  pointer-events: none;
}

/* Backdrop when open */
body.chat-open::before {
  content: "";
  position: fixed;
  inset: 0;
  background: rgba(4, 6, 10, 0.55);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 9999;
  animation: chatBackdropIn 0.28s ease;
  pointer-events: none;
}

@keyframes chatBackdropIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.chat-widget__fab {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.2);
  background: linear-gradient(145deg, var(--yellow-bright, #d4ff33), var(--yellow, #c6f015));
  color: #111;
  cursor: pointer;
  box-shadow:
    0 10px 36px rgba(0, 0, 0, 0.45),
    0 0 0 1px rgba(198, 240, 21, 0.35),
    inset 0 1px 0 rgba(255, 255, 255, 0.35);
  display: grid;
  place-items: center;
  transition: transform 0.22s cubic-bezier(0.34, 1.4, 0.64, 1), box-shadow 0.22s, opacity 0.2s;
  position: relative;
  overflow: visible;
  padding: 0;
  pointer-events: auto;
}

.chat-widget__fab-icon {
  display: block;
  flex-shrink: 0;
}

.chat-widget__fab-brand,
.chat-widget__fab-logo,
.chat-widget__logo-frame,
.chat-widget__logo { display: none !important; }

.chat-widget__fab:hover {
  transform: scale(1.08) translateY(-2px);
  box-shadow:
    0 16px 44px rgba(198, 240, 21, 0.28),
    0 0 0 1px rgba(198, 240, 21, 0.55),
    inset 0 1px 0 rgba(255, 255, 255, 0.4);
}

.chat-widget__fab.is-open,
.chat-widget__fab.is-open:hover {
  transform: scale(0);
  opacity: 0;
  pointer-events: none;
}

.chat-widget__badge {
  position: absolute;
  top: -3px;
  right: -3px;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  border-radius: 11px;
  background: linear-gradient(135deg, #ff6b76, #ff4d5a);
  color: #fff;
  font-size: 11px;
  font-weight: 800;
  display: grid;
  place-items: center;
  border: 2px solid var(--bg, #06080d);
  pointer-events: none;
  box-shadow: 0 4px 12px rgba(255, 77, 90, 0.45);
}

/* ── Panel ── */
.chat-widget__panel {
  position: fixed;
  bottom: max(24px, env(safe-area-inset-bottom, 0px));
  right: max(24px, env(safe-area-inset-right, 0px));
  width: min(400px, calc(100vw - 32px));
  height: min(620px, calc(100dvh - 48px));
  max-height: calc(100dvh - 48px);
  background: var(--bg-card, #111520);
  border: 1px solid var(--border-strong, rgba(255, 255, 255, 0.12));
  border-radius: var(--radius-xl, 20px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow:
    0 0 0 1px rgba(198, 240, 21, 0.06),
    0 32px 96px rgba(0, 0, 0, 0.65),
    0 8px 24px rgba(0, 0, 0, 0.35);
  animation: chatPanelIn 0.32s cubic-bezier(0.22, 1, 0.36, 1);
  pointer-events: auto;
  z-index: 10001;
}

.chat-widget__panel::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 80% 40% at 50% -10%, rgba(198, 240, 21, 0.08), transparent 60%),
    radial-gradient(ellipse 60% 30% at 100% 100%, rgba(198, 240, 21, 0.04), transparent 50%);
  pointer-events: none;
  z-index: 0;
}

.chat-widget__panel > * {
  position: relative;
  z-index: 1;
}

.chat-widget__panel[hidden] {
  display: none !important;
  visibility: hidden !important;
  pointer-events: none !important;
}

@keyframes chatPanelIn {
  from {
    opacity: 0;
    transform: translateY(20px) scale(0.96);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

/* ── Header ── */
.chat-widget__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 18px;
  background: linear-gradient(180deg, rgba(14, 17, 26, 0.98) 0%, rgba(10, 12, 18, 0.95) 100%);
  border-bottom: 1px solid var(--border, rgba(255, 255, 255, 0.07));
  flex-shrink: 0;
}

.chat-widget__head::after {
  content: "";
  position: absolute;
  left: 18px;
  right: 18px;
  bottom: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(198, 240, 21, 0.35), transparent);
  pointer-events: none;
}

.chat-widget__head-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.chat-widget__avatar {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  background: linear-gradient(145deg, rgba(198, 240, 21, 0.22), rgba(198, 240, 21, 0.06));
  border: 1px solid rgba(198, 240, 21, 0.28);
  display: grid;
  place-items: center;
  flex-shrink: 0;
  box-shadow: 0 4px 16px rgba(198, 240, 21, 0.12);
}

.chat-widget__avatar svg {
  color: var(--yellow, #c6f015);
}

.chat-widget__head-logo { display: none !important; }

.chat-widget__head-text {
  min-width: 0;
}

.chat-widget__head-text strong {
  display: block;
  font-family: var(--font-display, "Barlow Semi Condensed", sans-serif);
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--text, #f4f6fa);
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-widget__status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 4px;
  padding: 3px 10px 3px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-muted, #939bab);
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.chat-widget__status.is-online {
  background: rgba(34, 197, 94, 0.1);
  color: #86efac;
  border-color: rgba(34, 197, 94, 0.22);
}

.chat-widget__status.is-offline {
  background: rgba(148, 163, 184, 0.1);
  color: #94a3b8;
  border-color: rgba(148, 163, 184, 0.18);
}

.chat-widget__status.is-online::before,
.chat-widget__status.is-offline::before {
  content: "";
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}

.chat-widget__status.is-online::before {
  background: #22c55e;
  box-shadow: 0 0 8px rgba(34, 197, 94, 0.7);
  animation: chatPulse 2s ease infinite;
}

.chat-widget__status.is-offline::before {
  background: #64748b;
}

@keyframes chatPulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.7; transform: scale(0.85); }
}

.chat-widget__close {
  width: 38px;
  height: 38px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-muted, #939bab);
  cursor: pointer;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.chat-widget__close:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text, #f4f6fa);
  border-color: rgba(255, 255, 255, 0.14);
}

.chat-widget__close svg {
  display: block;
}

/* ── Start view ── */
.chat-widget__start-view,
.chat-widget__chat-view {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: linear-gradient(180deg, rgba(8, 10, 16, 0.4) 0%, transparent 120px);
}

.chat-widget__start-view[hidden],
.chat-widget__chat-view[hidden] {
  display: none !important;
}

.chat-widget__hero {
  padding: 20px 18px 0;
  text-align: center;
}

.chat-widget__hero-icon {
  width: 52px;
  height: 52px;
  margin: 0 auto 12px;
  border-radius: 16px;
  background: var(--yellow-muted, rgba(198, 240, 21, 0.1));
  border: 1px solid rgba(198, 240, 21, 0.2);
  display: grid;
  place-items: center;
  color: var(--yellow, #c6f015);
}

.chat-widget__hero h3 {
  font-family: var(--font-display, "Barlow Semi Condensed", sans-serif);
  font-size: 18px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--text, #f4f6fa);
  margin: 0 0 6px;
}

.chat-widget__intro {
  font-size: 14px;
  color: var(--text-muted, #939bab);
  line-height: 1.55;
  margin: 0;
  max-width: 320px;
  margin-inline: auto;
}

.chat-widget__pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  padding: 14px 18px 0;
}

.chat-widget__pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted, #939bab);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.07);
}

.chat-widget__pill svg {
  color: var(--yellow, #c6f015);
  flex-shrink: 0;
}

.chat-widget__offline {
  margin: 14px 18px 0;
  padding: 12px 14px;
  border-radius: 12px;
  background: rgba(255, 77, 90, 0.08);
  border: 1px solid rgba(255, 77, 90, 0.22);
  color: #fecaca;
  font-size: 13px;
  line-height: 1.5;
}

.chat-widget__offline[hidden] {
  display: none !important;
}

.chat-widget__form {
  flex: 1;
  overflow-y: auto;
  padding: 16px 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.chat-widget__field {
  display: flex;
  flex-direction: column;
  gap: 7px;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-dim, #5e6573);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.chat-widget__field[hidden] {
  display: none !important;
}

.chat-widget__field input,
.chat-widget__field textarea {
  font-size: 15px;
  font-weight: 400;
  text-transform: none;
  letter-spacing: normal;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--border-strong, rgba(255, 255, 255, 0.12));
  background: rgba(0, 0, 0, 0.28);
  color: var(--text, #f4f6fa);
  resize: vertical;
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
}

.chat-widget__field input::placeholder,
.chat-widget__field textarea::placeholder {
  color: var(--text-dim, #5e6573);
}

.chat-widget__field input:focus,
.chat-widget__field textarea:focus {
  outline: none;
  border-color: var(--border-yellow, rgba(198, 240, 21, 0.35));
  background: rgba(0, 0, 0, 0.38);
  box-shadow: 0 0 0 3px rgba(198, 240, 21, 0.1);
}

.chat-widget__submit {
  margin-top: 4px;
  padding: 14px 18px;
  border: none;
  border-radius: 14px;
  background: linear-gradient(145deg, var(--yellow-bright, #d4ff33), var(--yellow, #c6f015));
  color: #111;
  font-weight: 800;
  font-size: 14px;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  cursor: pointer;
  transition: transform 0.15s, filter 0.15s, box-shadow 0.15s;
  box-shadow: 0 6px 20px rgba(198, 240, 21, 0.25);
}

.chat-widget__submit:hover {
  filter: brightness(1.05);
  transform: translateY(-1px);
  box-shadow: 0 8px 28px rgba(198, 240, 21, 0.32);
}

.chat-widget__submit:active {
  transform: translateY(0);
}

/* ── Success ── */
.chat-widget__success-view {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 36px 28px;
  text-align: center;
  gap: 14px;
}

.chat-widget__success-view[hidden] {
  display: none !important;
}

.chat-widget__success-view strong {
  font-family: var(--font-display, "Barlow Semi Condensed", sans-serif);
  font-size: 20px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--text, #f4f6fa);
}

.chat-widget__success-view p {
  color: var(--text-muted, #939bab);
  font-size: 14px;
  line-height: 1.55;
  max-width: 280px;
}

.chat-widget__success-icon {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: rgba(34, 197, 94, 0.12);
  border: 2px solid rgba(34, 197, 94, 0.3);
  color: #22c55e;
  font-size: 30px;
  display: grid;
  place-items: center;
  font-weight: 700;
  box-shadow: 0 8px 32px rgba(34, 197, 94, 0.15);
}

/* ── Offline mode ── */
.chat-widget__fab--offline {
  background: linear-gradient(145deg, #2a3140, #1e2430);
  color: var(--yellow, #c6f015);
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.4);
}

.chat-widget--offline .chat-widget__submit:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.chat-widget__field input:disabled,
.chat-widget__field textarea:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

/* ── Queue ── */
.chat-widget__queue {
  margin: 12px 14px 0;
  padding: 16px;
  text-align: center;
  border-radius: 14px;
  background: rgba(198, 240, 21, 0.06);
  border: 1px solid rgba(198, 240, 21, 0.14);
  color: var(--text-muted, #939bab);
}

.chat-widget__queue[hidden] {
  display: none !important;
}

.chat-widget__queue-icon {
  width: 40px;
  height: 40px;
  margin: 0 auto 10px;
  border-radius: 12px;
  background: rgba(198, 240, 21, 0.1);
  display: grid;
  place-items: center;
  color: var(--yellow, #c6f015);
  animation: chatQueueSpin 2s linear infinite;
}

@keyframes chatQueueSpin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.chat-widget__queue p {
  font-size: 13px;
  line-height: 1.5;
  margin: 0;
  color: var(--text, #f4f6fa);
}

/* ── Messages ── */
.chat-widget__messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 0;
  scroll-behavior: smooth;
}

.chat-widget__messages::-webkit-scrollbar {
  width: 5px;
}

.chat-widget__messages::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.12);
  border-radius: 999px;
}

.chat-msg {
  max-width: 82%;
  animation: chatMsgIn 0.22s ease;
}

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

.chat-msg p {
  margin: 0;
  padding: 11px 14px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.5;
  word-break: break-word;
}

.chat-msg time {
  display: block;
  font-size: 10px;
  color: var(--text-dim, #5e6573);
  margin-top: 4px;
  padding: 0 4px;
}

.chat-msg--mine {
  align-self: flex-end;
}

.chat-msg--mine p {
  background: linear-gradient(145deg, var(--yellow-bright, #d4ff33), var(--yellow, #c6f015));
  color: #111;
  border-bottom-right-radius: 5px;
  box-shadow: 0 4px 16px rgba(198, 240, 21, 0.2);
}

.chat-msg--mine time {
  text-align: right;
}

.chat-msg--theirs {
  align-self: flex-start;
}

.chat-msg--theirs p {
  background: rgba(255, 255, 255, 0.07);
  color: var(--text, #f4f6fa);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-bottom-left-radius: 5px;
}

.chat-msg--theirs time {
  text-align: left;
}

.chat-msg--system {
  align-self: center;
  max-width: 92%;
  text-align: center;
}

.chat-msg--system span {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--text-muted, #939bab);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.06);
  padding: 6px 14px;
  border-radius: 999px;
}

.chat-msg--system time {
  text-align: center;
  margin-top: 6px;
}

/* Legacy class aliases */
.chat-msg--client { align-self: flex-end; }
.chat-msg--client p {
  background: linear-gradient(145deg, var(--yellow-bright, #d4ff33), var(--yellow, #c6f015));
  color: #111;
  border-bottom-right-radius: 5px;
}
.chat-msg--admin { align-self: flex-start; }
.chat-msg--admin p {
  background: rgba(255, 255, 255, 0.07);
  color: var(--text, #f4f6fa);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-bottom-left-radius: 5px;
}

/* ── Typing ── */
.chat-widget__typing {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 18px 10px;
  font-size: 12px;
  color: var(--text-muted, #939bab);
}

.chat-widget__typing[hidden] {
  display: none !important;
}

.chat-widget__typing-dots {
  display: inline-flex;
  gap: 4px;
  padding: 8px 12px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.07);
}

.chat-widget__typing-dots span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--yellow, #c6f015);
  animation: chatTypingDot 1.2s ease infinite;
}

.chat-widget__typing-dots span:nth-child(2) { animation-delay: 0.15s; }
.chat-widget__typing-dots span:nth-child(3) { animation-delay: 0.3s; }

@keyframes chatTypingDot {
  0%, 60%, 100% { opacity: 0.35; transform: translateY(0); }
  30% { opacity: 1; transform: translateY(-3px); }
}

/* ── Reply bar ── */
.chat-widget__reply {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px max(16px, env(safe-area-inset-bottom, 0px));
  border-top: 1px solid var(--border, rgba(255, 255, 255, 0.07));
  background: linear-gradient(180deg, rgba(10, 12, 18, 0.95) 0%, rgba(8, 10, 16, 0.98) 100%);
  flex-shrink: 0;
}

.chat-widget__reply input {
  flex: 1;
  min-width: 0;
  padding: 12px 18px;
  border-radius: 999px;
  border: 1px solid var(--border-strong, rgba(255, 255, 255, 0.12));
  background: rgba(0, 0, 0, 0.32);
  color: var(--text, #f4f6fa);
  font-size: 15px;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.chat-widget__reply input::placeholder {
  color: var(--text-dim, #5e6573);
}

.chat-widget__reply input:focus {
  outline: none;
  border-color: var(--border-yellow, rgba(198, 240, 21, 0.35));
  box-shadow: 0 0 0 3px rgba(198, 240, 21, 0.08);
}

.chat-widget__reply input:disabled,
.chat-widget__reply button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.chat-widget__reply button {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(145deg, var(--yellow-bright, #d4ff33), var(--yellow, #c6f015));
  color: #111;
  cursor: pointer;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  transition: transform 0.15s, box-shadow 0.15s;
  box-shadow: 0 4px 16px rgba(198, 240, 21, 0.25);
}

.chat-widget__reply button:hover:not(:disabled) {
  transform: scale(1.06);
  box-shadow: 0 6px 22px rgba(198, 240, 21, 0.35);
}

.chat-widget__reply button:active:not(:disabled) {
  transform: scale(0.96);
}

/* ── Mobile ── */
@media (max-width: 640px) {
  body.chat-open::before {
    background: rgba(4, 6, 10, 0.75);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
  }

  .chat-widget {
    bottom: max(16px, env(safe-area-inset-bottom, 0px));
    right: max(16px, env(safe-area-inset-right, 0px));
  }

  .chat-widget__fab {
    width: 58px;
    height: 58px;
  }

  .chat-widget__fab-icon {
    width: 26px;
    height: 26px;
  }

  .chat-widget__panel:not([hidden]) {
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100% !important;
    height: 100% !important;
    max-height: none;
    border-radius: 0;
    border: none;
    animation: chatSlideUpMobile 0.34s cubic-bezier(0.22, 1, 0.36, 1);
    box-shadow: none;
  }

  .chat-widget__head {
    padding: max(14px, env(safe-area-inset-top, 0px)) 16px 14px;
  }

  .chat-widget__head-text strong {
    font-size: 15px;
  }

  .chat-widget__avatar {
    width: 40px;
    height: 40px;
    border-radius: 12px;
  }

  .chat-widget__close {
    width: 42px;
    height: 42px;
    border-radius: 14px;
  }

  .chat-widget__hero {
    padding-top: 16px;
  }

  .chat-widget__form {
    padding: 14px 16px 20px;
  }

  .chat-widget__messages {
    padding: 14px 12px;
  }

  .chat-msg {
    max-width: 88%;
  }

  .chat-msg p {
    font-size: 15px;
    padding: 12px 15px;
  }

  .chat-widget__reply {
    padding: 12px 14px max(14px, env(safe-area-inset-bottom, 0px));
  }

  .chat-widget__reply button {
    width: 46px;
    height: 46px;
  }
}

@keyframes chatSlideUpMobile {
  from { opacity: 0; transform: translateY(100%); }
  to { opacity: 1; transform: none; }
}

body.chat-open {
  overflow: hidden;
  touch-action: none;
}

body.mobile-nav-open .chat-widget__fab {
  opacity: 0;
  pointer-events: none;
  transform: scale(0.8);
}
