/* ============================================================
   GDRM — Chatbot UI styles
   Extends style.css (all CSS variables available)
   ============================================================ */

/* ── Body override for chat layout ── */
body.chatbot-page {
  overflow: hidden;
  height: 100dvh;
}

/* ============================================================
   LAYOUT
   ============================================================ */
.chat-layout {
  display: flex;
  height: 100dvh;
  width: 100%;
  background: var(--bg);
  position: relative;
}

/* ============================================================
   SIDEBAR
   ============================================================ */
.chat-sidebar {
  width: 260px;
  flex-shrink: 0;
  background: var(--bg-raised);
  border-right: 0.5px solid var(--border);
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow-y: auto;
  transition: transform 0.32s cubic-bezier(0.25,1,0.5,1);
  z-index: 200;
}

.chat-sidebar__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 20px 16px;
  border-bottom: 0.5px solid var(--border);
  flex-shrink: 0;
}

.chat-logo { display: flex; align-items: center; }

.sidebar-close {
  display: none;
  background: none;
  border: none;
  color: var(--text-3);
  cursor: pointer;
  padding: 4px;
  border-radius: 6px;
  transition: color var(--t);
  -webkit-tap-highlight-color: transparent;
}
.sidebar-close:hover { color: var(--text-1); }

.chat-sidebar__section {
  padding: 20px 16px 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.chat-sidebar__label {
  font-size: 10px;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--text-3);
  font-weight: 600;
  padding: 0 6px;
  margin-bottom: 6px;
}

.chat-sidebar__link {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 10px;
  border-radius: var(--r-sm);
  font-size: 13.5px;
  color: var(--text-3);
  text-decoration: none;
  transition: background var(--t), color var(--t);
  -webkit-tap-highlight-color: transparent;
}
.chat-sidebar__link svg { flex-shrink: 0; opacity: 0.6; }
.chat-sidebar__link:hover { background: rgba(255,255,255,0.04); color: var(--text-1); }
.chat-sidebar__link--active {
  background: rgba(201,168,76,0.1);
  color: var(--gold);
  border: 0.5px solid rgba(201,168,76,0.2);
}
.chat-sidebar__link--active svg { opacity: 1; }

.chat-sidebar__footer {
  margin-top: auto;
  padding: 20px 16px;
  border-top: 0.5px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.chat-sidebar__phone {
  font-size: 13px;
  color: var(--gold);
  font-weight: 500;
  text-decoration: none;
}
.chat-sidebar__phone:hover { color: var(--gold-hi); }
.chat-sidebar__legal {
  font-size: 10.5px;
  color: var(--text-3);
  line-height: 1.6;
}

/* Overlay */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  z-index: 190;
  backdrop-filter: blur(2px);
}

/* ============================================================
   MAIN CHAT AREA
   ============================================================ */
.chat-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
  position: relative;
}

/* ============================================================
   CHAT HEADER
   ============================================================ */
.chat-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 20px;
  background: rgba(10,10,15,0.85);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border-bottom: 0.5px solid var(--border);
  flex-shrink: 0;
  position: relative;
  z-index: 10;
}

.chat-header__menu {
  background: none;
  border: none;
  color: var(--text-3);
  cursor: pointer;
  padding: 4px;
  border-radius: 8px;
  display: none;
  transition: color var(--t);
  -webkit-tap-highlight-color: transparent;
  flex-shrink: 0;
}
.chat-header__menu:hover { color: var(--text-1); }

.chat-header__title {
  display: flex;
  align-items: center;
  gap: 11px;
  flex: 1;
  min-width: 0;
}

.chat-header__bot-avatar {
  width: 38px; height: 38px;
  border-radius: 50%;
  background: linear-gradient(135deg, rgba(201,168,76,0.15), rgba(201,168,76,0.05));
  border: 0.5px solid rgba(201,168,76,0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 2px 10px rgba(201,168,76,0.15);
}

.chat-header__info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.chat-header__name {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-1);
  letter-spacing: -0.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chat-header__status {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  color: var(--text-3);
}
.status-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: #34c759;
  box-shadow: 0 0 5px rgba(52,199,89,0.6);
  animation: pulse-dot 2.4s ease-in-out infinite;
}
@keyframes pulse-dot {
  0%,100% { opacity: 1; }
  50% { opacity: 0.45; }
}

.chat-header__phone {
  font-size: 13px;
  color: var(--text-3);
  text-decoration: none;
  white-space: nowrap;
  transition: color var(--t);
  flex-shrink: 0;
}
.chat-header__phone:hover { color: var(--text-1); }

/* ============================================================
   MESSAGES
   ============================================================ */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 24px 20px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  scroll-behavior: smooth;
}
/* Custom scrollbar */
.chat-messages::-webkit-scrollbar { width: 4px; }
.chat-messages::-webkit-scrollbar-track { background: transparent; }
.chat-messages::-webkit-scrollbar-thumb { background: var(--border-hi); border-radius: 4px; }

/* Message row */
.chat-msg {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  max-width: 720px;
  animation: msgIn 0.3s cubic-bezier(0.25,1,0.5,1) both;
}
@keyframes msgIn {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}
.chat-msg--bot { align-self: flex-start; }
.chat-msg--user { align-self: flex-end; flex-direction: row-reverse; }

.chat-msg__avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, rgba(201,168,76,0.12), rgba(201,168,76,0.04));
  border: 0.5px solid rgba(201,168,76,0.25);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-bottom: 2px;
}

/* Bubble */
.chat-msg__bubble {
  background:
    linear-gradient(175deg, rgba(255,255,255,0.04) 0%, rgba(255,255,255,0.01) 100%),
    var(--bg-card);
  border: 0.5px solid var(--border-hi);
  border-radius: 18px 18px 18px 4px;
  padding: 13px 16px;
  max-width: 580px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.3), 0 1px 0 rgba(255,255,255,0.06) inset;
  position: relative;
}
.chat-msg__bubble--wide { max-width: 620px; }

.chat-msg--user .chat-msg__bubble {
  background: linear-gradient(135deg, rgba(201,168,76,0.18) 0%, rgba(201,168,76,0.08) 100%);
  border-color: rgba(201,168,76,0.35);
  border-radius: 18px 18px 4px 18px;
}

.chat-msg__text {
  font-size: 14.5px;
  color: var(--text-2);
  line-height: 1.65;
}
.chat-msg__text strong { color: var(--text-1); font-weight: 500; }

.chat-msg__meta {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 10px;
}
.chat-badge {
  background: rgba(201,168,76,0.1);
  border: 0.5px solid rgba(201,168,76,0.25);
  border-radius: var(--r-pill);
  padding: 3px 10px;
  font-size: 12px;
  color: var(--gold);
  font-weight: 500;
}

/* User answer bubble */
.chat-msg--user .chat-msg__text {
  color: var(--text-1);
  font-size: 14px;
}

/* Question bubble with options */
.chat-bubble-question {
  background:
    linear-gradient(175deg, rgba(255,255,255,0.04) 0%, rgba(255,255,255,0.01) 100%),
    var(--bg-card);
  border: 0.5px solid var(--border-hi);
  border-radius: 18px 18px 18px 4px;
  padding: 16px 18px;
  max-width: 580px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.3), 0 1px 0 rgba(255,255,255,0.06) inset;
  position: relative;
  overflow: hidden;
}
.chat-bubble-question::before {
  content: '';
  position: absolute;
  top: 0; left: 10%; right: 10%;
  height: 0.5px;
  background: linear-gradient(90deg, transparent, rgba(201,168,76,0.4), transparent);
}

.chat-q-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  gap: 10px;
}
.chat-q-counter {
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--gold);
  font-weight: 600;
}
.chat-q-progress {
  flex: 1;
  height: 2px;
  background: rgba(255,255,255,0.06);
  border-radius: 2px;
  overflow: hidden;
  max-width: 160px;
}
.chat-q-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--gold-lo), var(--gold), var(--gold-hi));
  box-shadow: 0 0 6px rgba(201,168,76,0.4);
  border-radius: 2px;
  transition: width 0.4s var(--ease-out);
}

.chat-q-text {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-1);
  line-height: 1.4;
  letter-spacing: -0.02em;
  margin-bottom: 14px;
}

/* Options as inline button rows */
.chat-options {
  display: flex;
  flex-direction: column;
  gap: 7px;
}
.chat-option-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: rgba(255,255,255,0.025);
  border: 0.5px solid var(--border);
  border-radius: var(--r-md);
  cursor: pointer;
  font-family: var(--f-sans);
  font-size: 13.5px;
  color: var(--text-2);
  text-align: left;
  transition: background var(--t), border-color var(--t), color var(--t), transform 0.15s;
  -webkit-tap-highlight-color: transparent;
  width: 100%;
}
.chat-option-btn:hover {
  background: rgba(255,255,255,0.05);
  border-color: var(--border-hi);
  color: var(--text-1);
}
.chat-option-btn:active { transform: scale(0.99); }
.chat-option-btn.selected {
  background: rgba(201,168,76,0.1);
  border-color: rgba(201,168,76,0.4);
  color: var(--text-1);
  pointer-events: none;
}
.chat-option-btn.disabled {
  opacity: 0.4;
  pointer-events: none;
}
.chat-option-radio {
  width: 16px; height: 16px;
  border-radius: 50%;
  border: 1.5px solid var(--border-hi);
  flex-shrink: 0;
  transition: background var(--t), border-color var(--t);
  display: flex;
  align-items: center;
  justify-content: center;
}
.chat-option-btn.selected .chat-option-radio {
  background: var(--gold);
  border-color: var(--gold);
}
.chat-option-btn.selected .chat-option-radio::after {
  content: '';
  width: 6px; height: 6px;
  border-radius: 50%;
  background: rgba(0,0,0,0.7);
}

/* Quick replies (start button) */
.chat-quick-replies {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}
.chat-qr-btn {
  padding: 9px 20px;
  border-radius: var(--r-pill);
  font-family: var(--f-sans);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  border: 0.5px solid var(--border-hi);
  background: rgba(255,255,255,0.04);
  color: var(--text-2);
  transition: all var(--t) var(--ease-out);
  -webkit-tap-highlight-color: transparent;
}
.chat-qr-btn:hover {
  background: rgba(255,255,255,0.08);
  color: var(--text-1);
}
.chat-qr-btn--primary {
  background: linear-gradient(135deg, rgba(201,168,76,0.2), rgba(201,168,76,0.08));
  border-color: rgba(201,168,76,0.4);
  color: var(--gold);
}
.chat-qr-btn--primary:hover {
  background: linear-gradient(135deg, rgba(201,168,76,0.3), rgba(201,168,76,0.12));
  color: var(--gold-hi);
}

/* Advantages grid in bubble */
.chat-adv-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.chat-adv-item {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(255,255,255,0.025);
  border: 0.5px solid var(--border);
  border-radius: var(--r-sm);
  padding: 8px 12px;
  font-size: 12.5px;
  color: var(--text-3);
  line-height: 1.4;
}
.chat-adv-icon { font-size: 14px; flex-shrink: 0; }

/* ============================================================
   TYPING INDICATOR
   ============================================================ */
.chat-typing {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  padding: 4px 20px 8px;
  animation: msgIn 0.25s ease both;
}
.typing-dots {
  display: flex;
  align-items: center;
  gap: 4px;
  background: var(--bg-card);
  border: 0.5px solid var(--border-hi);
  border-radius: 18px 18px 18px 4px;
  padding: 11px 16px;
}
.typing-dots span {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--text-3);
  animation: typingBounce 1.4s ease-in-out infinite;
}
.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes typingBounce {
  0%,60%,100% { transform: translateY(0); opacity: 0.5; }
  30% { transform: translateY(-5px); opacity: 1; }
}

/* ============================================================
   INPUT AREA (Lead form)
   ============================================================ */
.chat-input-area {
  border-top: 0.5px solid var(--border);
  background: var(--bg);
  flex-shrink: 0;
  max-height: 70vh;
  overflow-y: auto;
}
.chat-input-wrap { padding: 20px; }

.chat-lead-form {
  max-width: 560px;
  margin: 0 auto;
}
.chat-lead-header {
  text-align: center;
  margin-bottom: 20px;
}

/* ============================================================
   DISCLAIMER BAR
   ============================================================ */
.chat-disclaimer {
  flex-shrink: 0;
  padding: 10px 20px;
  border-top: 0.5px solid var(--border);
  background: var(--bg);
}
.chat-disclaimer p {
  font-size: 10.5px;
  color: var(--text-3);
  text-align: center;
  line-height: 1.6;
}
.chat-disclaimer a { color: var(--text-3); text-decoration: underline; text-decoration-color: transparent; }
.chat-disclaimer a:hover { color: var(--gold); text-decoration-color: var(--gold); }

/* ============================================================
   PROGRESS PILL (shown in messages area at top of quiz)
   ============================================================ */
.chat-progress-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: rgba(255,255,255,0.04);
  border: 0.5px solid var(--border-hi);
  border-radius: var(--r-pill);
  padding: 5px 14px;
  font-size: 11px;
  color: var(--gold);
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  align-self: center;
  margin: 8px auto;
}
.chat-progress-dot {
  width: 5px; height: 5px;
  border-radius: 50%;
  background: var(--gold);
  animation: blink 2s ease-in-out infinite;
}

/* ============================================================
   SCROLL TO BOTTOM BUTTON
   ============================================================ */
.scroll-to-bottom {
  position: absolute;
  bottom: 80px;
  right: 20px;
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--bg-card2);
  border: 0.5px solid var(--border-hi);
  color: var(--text-2);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(0,0,0,0.4);
  transition: opacity var(--t), transform var(--t);
  z-index: 5;
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
}
.scroll-to-bottom.visible {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

/* ============================================================
   MOBILE (≤ 768px) — Sidebar becomes drawer
   ============================================================ */
@media (max-width: 768px) {
  body.chatbot-page { overflow: hidden; }

  .chat-sidebar {
    position: fixed;
    left: 0; top: 0; bottom: 0;
    transform: translateX(-100%);
    box-shadow: 8px 0 40px rgba(0,0,0,0.5);
  }
  .chat-sidebar.open {
    transform: translateX(0);
  }
  .sidebar-close { display: flex; }
  .sidebar-overlay.open { display: block; }
  .chat-header__menu { display: flex; }

  .chat-messages { padding: 16px 14px 8px; }
  .chat-typing { padding: 4px 14px 6px; }

  .chat-msg__bubble,
  .chat-bubble-question { max-width: calc(100vw - 80px); }

  .chat-adv-grid { grid-template-columns: 1fr 1fr; }

  .chat-header__phone { display: none; }

  .chat-input-wrap { padding: 14px; }
  .form-row { grid-template-columns: 1fr; }

  .chat-disclaimer { display: none; }
}

@media (max-width: 480px) {
  .chat-adv-grid { grid-template-columns: 1fr; }
  .chat-msg { gap: 7px; }
  .chat-msg__avatar { width: 28px; height: 28px; }
  .chat-q-text { font-size: 14px; }
  .chat-option-btn { font-size: 13px; padding: 9px 12px; }
  .chat-msg__text { font-size: 14px; }
}

/* ============================================================
   TABLET (769px – 1024px)
   ============================================================ */
@media (min-width: 769px) and (max-width: 1024px) {
  .chat-sidebar { width: 220px; }
}

/* ============================================================
   Large screens
   ============================================================ */
@media (min-width: 1280px) {
  .chat-messages { padding: 28px 32px 12px; }
  .chat-typing { padding: 4px 32px 8px; }
  .chat-input-wrap { padding: 20px 32px; }
}
