/* ════════════════════════════════════════════════════════════════
   CHATBOT — glass bubble Apple-style floating assistant
   ════════════════════════════════════════════════════════════════ */

/* ── Floating trigger button ─────────────────────────────────── */
#chat-trigger {
  position: fixed;
  bottom: calc(76px + env(safe-area-inset-bottom, 0px));
  right: 22px;
  z-index: 940;
  display: flex;
  align-items: center;
  gap: 10px;
  height: 50px;
  padding: 0 20px 0 16px;
  border-radius: 999px;
  border: none;
  cursor: pointer;
  font-family: inherit;

  background: rgba(255,255,255,0.12);
  backdrop-filter: blur(40px) saturate(180%) brightness(112%);
  -webkit-backdrop-filter: blur(40px) saturate(180%) brightness(112%);
  border: 1px solid rgba(255,255,255,0.28);
  box-shadow:
    inset 0 1.5px 0 rgba(255,255,255,0.45),
    inset 0 -1px 0 rgba(255,255,255,0.05),
    0 0 28px rgba(255,255,255,0.09),
    0 8px 32px rgba(0,0,0,0.38);

  transition:
    transform 0.35s cubic-bezier(0.22,1,0.36,1),
    background 0.3s ease,
    box-shadow 0.3s ease,
    opacity 0.3s ease;
}

#chat-trigger:hover {
  transform: scale(1.05) translateY(-2px);
  background: rgba(255,255,255,0.20);
  box-shadow:
    inset 0 1.5px 0 rgba(255,255,255,0.55),
    0 0 36px rgba(255,255,255,0.14),
    0 12px 40px rgba(0,0,0,0.44);
}

#chat-trigger.hidden {
  opacity: 0;
  pointer-events: none;
  transform: scale(0.85) translateY(8px);
}

/* Top highlight strip */
#chat-trigger::before {
  content: '';
  position: absolute;
  top: 0; left: 20%; width: 60%; height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.65) 50%, transparent);
  border-radius: 999px;
}

.chat-trigger-icon {
  width: 22px;
  height: 22px;
  flex-shrink: 0;
  color: rgba(255,255,255,0.88);
}

.chat-trigger-label {
  font-size: 13.5px;
  font-weight: 500;
  letter-spacing: -0.01em;
  color: rgba(255,255,255,0.92);
  white-space: nowrap;
}

/* Pulsing dot — online indicator */
.chat-trigger-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: rgba(120,220,120,0.85);
  flex-shrink: 0;
  box-shadow: 0 0 8px rgba(100,210,100,0.55);
  animation: chat-pulse 2.6s ease-in-out infinite;
}

@keyframes chat-pulse {
  0%, 100% { opacity: 1;    transform: scale(1); }
  50%       { opacity: 0.55; transform: scale(0.82); }
}

/* ── Chat panel ──────────────────────────────────────────────── */
#chat-panel {
  position: fixed;
  bottom: calc(138px + env(safe-area-inset-bottom, 0px));
  right: 22px;
  z-index: 945;
  width: 360px;
  max-height: 520px;
  border-radius: 26px;
  overflow: hidden;
  display: flex;
  flex-direction: column;

  background: rgba(14,14,14,0.72);
  backdrop-filter: blur(56px) saturate(180%) brightness(108%);
  -webkit-backdrop-filter: blur(56px) saturate(180%) brightness(108%);
  border: 1px solid rgba(255,255,255,0.16);
  box-shadow:
    0 32px 80px rgba(0,0,0,0.55),
    0 4px 16px rgba(0,0,0,0.35),
    inset 0 1px 0 rgba(255,255,255,0.55),
    inset 0 -1px 0 rgba(255,255,255,0.04);

  opacity: 0;
  transform: translateY(16px) scale(0.97);
  pointer-events: none;
  transition:
    opacity 0.40s cubic-bezier(0.22,1,0.36,1),
    transform 0.40s cubic-bezier(0.22,1,0.36,1);
}

#chat-panel.open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: all;
}

/* Top-edge highlight */
#chat-panel::before {
  content: '';
  position: absolute;
  top: 0; left: 15%; width: 70%; height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.52) 50%, transparent);
  border-radius: 999px;
  z-index: 1;
  pointer-events: none;
}

/* ── Panel header ────────────────────────────────────────────── */
.chat-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 18px 14px;
  border-bottom: 1px solid rgba(255,255,255,0.07);
  flex-shrink: 0;
  position: relative;
  z-index: 1;
}

.chat-header-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: rgba(255,255,255,0.09);
  border: 1px solid rgba(255,255,255,0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.20);
}

.chat-header-info { flex: 1; }

.chat-header-name {
  font-size: 13.5px;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: rgba(255,255,255,0.92);
  line-height: 1.2;
}

.chat-header-status {
  display: flex;
  align-items: center;
  gap: 5px;
  margin-top: 2px;
}

.chat-status-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: rgba(120,220,120,0.80);
  box-shadow: 0 0 5px rgba(100,210,100,0.50);
  animation: chat-pulse 2.6s ease-in-out infinite;
}

.chat-status-text {
  font-size: 11px;
  font-weight: 400;
  color: rgba(255,255,255,0.38);
  letter-spacing: -0.003em;
}

.chat-close {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: none;
  background: rgba(255,255,255,0.07);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(255,255,255,0.50);
  transition: background 0.2s ease, color 0.2s ease;
  flex-shrink: 0;
}
.chat-close:hover {
  background: rgba(255,255,255,0.13);
  color: rgba(255,255,255,0.88);
}

/* ── Messages area ───────────────────────────────────────────── */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 16px 8px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scroll-behavior: smooth;
  position: relative;
  z-index: 1;
}

.chat-messages::-webkit-scrollbar {
  width: 3px;
}
.chat-messages::-webkit-scrollbar-track { background: transparent; }
.chat-messages::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.12);
  border-radius: 999px;
}

/* Bot message bubble */
.msg-bot {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  max-width: 88%;
  align-self: flex-start;
  animation: msg-in 0.35s cubic-bezier(0.22,1,0.36,1) both;
}

@keyframes msg-in {
  from { opacity: 0; transform: translateY(8px) scale(0.96); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.msg-bot-avatar {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.13);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  flex-shrink: 0;
  margin-bottom: 2px;
}

.msg-bot-bubble {
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.11);
  border-radius: 18px 18px 18px 4px;
  padding: 10px 14px;
  font-size: 13.5px;
  font-weight: 400;
  color: rgba(255,255,255,0.82);
  line-height: 1.55;
  letter-spacing: -0.005em;
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.12),
    0 4px 12px rgba(0,0,0,0.22);
}

.msg-bot-bubble a {
  color: rgba(255,255,255,0.75);
  text-decoration: none;
  border-bottom: 1px solid rgba(255,255,255,0.22);
  padding-bottom: 1px;
  transition: color 0.2s ease;
}
.msg-bot-bubble a:hover { color: #fff; }

/* User message bubble */
.msg-user {
  align-self: flex-end;
  max-width: 80%;
  animation: msg-in 0.30s cubic-bezier(0.22,1,0.36,1) both;
}

.msg-user-bubble {
  background: rgba(255,255,255,0.14);
  border: 1px solid rgba(255,255,255,0.24);
  border-radius: 18px 18px 4px 18px;
  padding: 10px 14px;
  font-size: 13.5px;
  font-weight: 400;
  color: rgba(255,255,255,0.92);
  line-height: 1.55;
  letter-spacing: -0.005em;
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.22),
    0 4px 12px rgba(0,0,0,0.22);
}

/* Typing indicator */
.msg-typing .msg-bot-bubble {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 12px 16px;
}

.typing-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: rgba(255,255,255,0.40);
  animation: typing-bounce 1.3s ease-in-out infinite;
}
.typing-dot:nth-child(2) { animation-delay: 0.16s; }
.typing-dot:nth-child(3) { animation-delay: 0.32s; }

@keyframes typing-bounce {
  0%, 60%, 100% { transform: translateY(0); }
  30%           { transform: translateY(-5px); opacity: 0.85; }
}

/* ── Quick reply chips ───────────────────────────────────────── */
.chat-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 8px 16px 10px;
  border-top: 1px solid rgba(255,255,255,0.06);
  position: relative;
  z-index: 1;
}

.chat-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 7px 13px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,0.14);
  background: rgba(255,255,255,0.06);
  font-size: 12.5px;
  font-weight: 450;
  color: rgba(255,255,255,0.65);
  letter-spacing: -0.005em;
  cursor: pointer;
  font-family: inherit;
  transition:
    background 0.22s ease,
    border-color 0.22s ease,
    color 0.22s ease,
    transform 0.22s cubic-bezier(0.22,1,0.36,1);
}

.chat-chip:hover {
  background: rgba(255,255,255,0.12);
  border-color: rgba(255,255,255,0.26);
  color: rgba(255,255,255,0.92);
  transform: translateY(-1px);
}

.chat-chip:active { transform: scale(0.96); }

/* ── Input row ───────────────────────────────────────────────── */
.chat-input-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px 14px;
  border-top: 1px solid rgba(255,255,255,0.06);
  position: relative;
  z-index: 1;
}

.chat-input {
  flex: 1;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.10);
  border-radius: 999px;
  padding: 9px 16px;
  font-size: 13.5px;
  font-weight: 400;
  color: rgba(255,255,255,0.88);
  font-family: inherit;
  letter-spacing: -0.005em;
  outline: none;
  transition: border-color 0.22s ease, background 0.22s ease;
}

.chat-input::placeholder { color: rgba(255,255,255,0.22); }

.chat-input:focus {
  border-color: rgba(255,255,255,0.26);
  background: rgba(255,255,255,0.09);
}

.chat-send {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1px solid rgba(255,255,255,0.22);
  background: rgba(255,255,255,0.10);
  color: rgba(255,255,255,0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.22s ease, color 0.22s ease, transform 0.22s cubic-bezier(0.22,1,0.36,1);
}

.chat-send:hover {
  background: rgba(255,255,255,0.18);
  color: rgba(255,255,255,0.95);
  transform: scale(1.08);
}

.chat-send:active { transform: scale(0.94); }

/* ── Mobile adjustments ──────────────────────────────────────── */
@media (max-width: 480px) {
  #chat-panel {
    right: 12px;
    left: 12px;
    width: auto;
    bottom: calc(128px + env(safe-area-inset-bottom, 0px));
    max-height: 460px;
  }

  #chat-trigger {
    right: 12px;
    bottom: calc(72px + env(safe-area-inset-bottom, 0px));
  }
}
