/* ── Gym Chatbot Widget ─────────────────────────────────────────────────── */
:root {
  --cb-primary: #e8500a;
  --cb-primary-dark: #c04008;
  --cb-primary-light: #ff6b2b;
  --cb-bg: #1a1a2e;
  --cb-surface: #16213e;
  --cb-surface2: #0f3460;
  --cb-text: #e0e0e0;
  --cb-text-muted: #a0a0b0;
  --cb-radius: 16px;
  --cb-shadow: 0 8px 32px rgba(0,0,0,.45);
  --cb-font: 'Segoe UI', system-ui, sans-serif;
}

/* Toggle button */
#cb-toggle {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--cb-primary), var(--cb-primary-light));
  border: none;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(232,80,10,.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  transition: transform .2s, box-shadow .2s;
}
#cb-toggle:hover { transform: scale(1.1); box-shadow: 0 6px 28px rgba(232,80,10,.7); }
#cb-toggle svg { width: 28px; height: 28px; fill: #fff; }
#cb-badge {
  position: absolute;
  top: -4px; right: -4px;
  background: #ff3d3d;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  border-radius: 10px;
  padding: 2px 6px;
  display: none;
}

/* Widget window */
#cb-widget {
  position: fixed;
  bottom: 96px;
  right: 24px;
  width: 380px;
  max-height: 600px;
  display: flex;
  flex-direction: column;
  background: var(--cb-bg);
  border-radius: var(--cb-radius);
  box-shadow: var(--cb-shadow);
  z-index: 9998;
  font-family: var(--cb-font);
  font-size: 14px;
  color: var(--cb-text);
  overflow: hidden;
  border: 1px solid rgba(255,255,255,.08);
  transition: opacity .25s, transform .25s;
  opacity: 0;
  transform: translateY(20px) scale(.97);
  pointer-events: none;
}
#cb-widget.cb-open { opacity: 1; transform: translateY(0) scale(1); pointer-events: all; }

/* Header */
#cb-header {
  background: linear-gradient(135deg, var(--cb-primary-dark), var(--cb-primary));
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}
#cb-avatar {
  width: 40px; height: 40px;
  background: rgba(255,255,255,.2);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
}
#cb-avatar svg { width: 22px; height: 22px; fill: #fff; }
#cb-header-info { flex: 1; }
#cb-header-info h4 { margin: 0; font-size: 15px; font-weight: 700; color: #fff; }
#cb-header-info span { font-size: 11px; color: rgba(255,255,255,.75); }
#cb-close-btn {
  background: none; border: none; color: rgba(255,255,255,.8);
  cursor: pointer; padding: 4px; line-height: 0; border-radius: 6px;
  transition: background .15s;
}
#cb-close-btn:hover { background: rgba(255,255,255,.15); }

/* Messages */
#cb-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scrollbar-width: thin;
  scrollbar-color: var(--cb-surface2) transparent;
}
#cb-messages::-webkit-scrollbar { width: 4px; }
#cb-messages::-webkit-scrollbar-thumb { background: var(--cb-surface2); border-radius: 2px; }

.cb-msg {
  display: flex;
  gap: 8px;
  animation: cbFadeIn .2s ease;
}
@keyframes cbFadeIn { from { opacity: 0; transform: translateY(6px); } }

.cb-msg.cb-user { flex-direction: row-reverse; }
.cb-msg-avatar {
  width: 30px; height: 30px;
  border-radius: 50%;
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700;
}
.cb-msg.cb-bot .cb-msg-avatar { background: var(--cb-primary); color: #fff; }
.cb-msg.cb-user .cb-msg-avatar { background: var(--cb-surface2); color: var(--cb-text); }

.cb-msg-bubble {
  max-width: 80%;
  padding: 10px 14px;
  border-radius: 18px;
  line-height: 1.5;
  word-break: break-word;
}
.cb-msg.cb-bot .cb-msg-bubble {
  background: var(--cb-surface);
  border-bottom-left-radius: 4px;
  color: var(--cb-text);
}
.cb-msg.cb-user .cb-msg-bubble {
  background: linear-gradient(135deg, var(--cb-primary-dark), var(--cb-primary));
  border-bottom-right-radius: 4px;
  color: #fff;
}
.cb-msg-bubble strong { color: var(--cb-primary-light); }
.cb-msg.cb-user .cb-msg-bubble strong { color: #fff; }
.cb-msg-bubble ul, .cb-msg-bubble ol { margin: 4px 0 4px 16px; }
.cb-msg-bubble a { color: var(--cb-primary-light); }

.cb-msg-time { font-size: 10px; color: var(--cb-text-muted); margin-top: 4px; text-align: right; }
.cb-msg.cb-bot .cb-msg-time { text-align: left; }

/* Typing indicator */
#cb-typing {
  display: none;
  align-items: center;
  gap: 8px;
  padding: 0 16px 8px;
}
#cb-typing.cb-show { display: flex; }
.cb-dots { display: flex; gap: 4px; }
.cb-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--cb-primary);
  animation: cbBounce 1.2s infinite ease-in-out;
}
.cb-dot:nth-child(2) { animation-delay: .2s; }
.cb-dot:nth-child(3) { animation-delay: .4s; }
@keyframes cbBounce { 0%,80%,100% { transform: scale(0.6); opacity:.5; } 40% { transform: scale(1); opacity:1; } }

/* Quick replies */
#cb-quick-replies {
  padding: 0 12px 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.cb-qr {
  background: var(--cb-surface);
  border: 1px solid var(--cb-primary);
  color: var(--cb-primary-light);
  border-radius: 20px;
  padding: 5px 12px;
  font-size: 12px;
  cursor: pointer;
  transition: background .15s, color .15s;
  white-space: nowrap;
}
.cb-qr:hover { background: var(--cb-primary); color: #fff; }

/* Input area */
#cb-input-area {
  padding: 10px 12px;
  border-top: 1px solid rgba(255,255,255,.07);
  display: flex;
  gap: 8px;
  align-items: flex-end;
  flex-shrink: 0;
  background: var(--cb-surface);
}
#cb-input {
  flex: 1;
  background: var(--cb-bg);
  border: 1px solid rgba(255,255,255,.1);
  border-radius: 22px;
  padding: 9px 14px;
  color: var(--cb-text);
  font-family: var(--cb-font);
  font-size: 13px;
  resize: none;
  max-height: 100px;
  outline: none;
  line-height: 1.4;
  transition: border-color .2s;
}
#cb-input:focus { border-color: var(--cb-primary); }
#cb-input::placeholder { color: var(--cb-text-muted); }
#cb-send {
  width: 38px; height: 38px;
  border-radius: 50%;
  background: var(--cb-primary);
  border: none;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  transition: background .15s, transform .15s;
}
#cb-send:hover { background: var(--cb-primary-light); transform: scale(1.05); }
#cb-send svg { width: 18px; height: 18px; fill: #fff; }
#cb-send:disabled { opacity: .5; cursor: not-allowed; transform: none; }

/* Mobile */
@media (max-width: 480px) {
  #cb-widget { width: calc(100vw - 16px); right: 8px; bottom: 80px; max-height: 70vh; }
  #cb-toggle { right: 16px; bottom: 16px; }
}

/* The site's mobile bottom tab bar (60px) is shown below 992px — keep the launcher clear of it. */
@media (max-width: 991.98px) {
  #cb-toggle { bottom: 76px; width: 52px; height: 52px; }
  #cb-widget { bottom: 138px; max-height: calc(100vh - 160px); }
}
@media (max-width: 480px) {
  #cb-toggle { right: 16px; bottom: 76px; }
  #cb-widget { bottom: 138px; max-height: calc(100vh - 160px); }
}
