/* ── Chat Widget ── */

#chat-bubble {
  position: fixed;
  bottom: 1.75rem;
  right: 1.75rem;
  width: 56px;
  height: 56px;
  background: var(--cyan);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 9998;
  box-shadow: 0 4px 20px rgba(0,180,216,0.45);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  border: none;
  outline: none;
}
#chat-bubble:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 28px rgba(0,180,216,0.55);
}
#chat-bubble svg { width: 26px; height: 26px; fill: var(--navy-900); }
#chat-bubble .chat-notif {
  position: absolute;
  top: -3px;
  right: -3px;
  width: 14px;
  height: 14px;
  background: #ff4757;
  border-radius: 50%;
  border: 2px solid white;
  animation: notif-pulse 2s infinite;
}
@keyframes notif-pulse {
  0%,100% { transform: scale(1); }
  50% { transform: scale(1.2); }
}

#chat-panel {
  position: fixed;
  bottom: 5.5rem;
  right: 1.75rem;
  width: 360px;
  max-width: calc(100vw - 2rem);
  height: 520px;
  max-height: calc(100vh - 7rem);
  background: var(--navy-800);
  border-radius: 16px;
  box-shadow: 0 12px 48px rgba(0,0,0,0.4);
  display: flex;
  flex-direction: column;
  z-index: 9999;
  transform: translateY(20px);
  opacity: 0;
  pointer-events: none;
  transition: transform 0.25s ease, opacity 0.25s ease;
  border: 1px solid rgba(0,180,216,0.2);
  overflow: hidden;
}
#chat-panel.open {
  transform: translateY(0);
  opacity: 1;
  pointer-events: all;
}

/* Header */
.chat-header {
  background: linear-gradient(90deg, var(--navy-900), #0d2247);
  padding: 0.85rem 1rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  border-bottom: 1px solid rgba(0,180,216,0.15);
  flex-shrink: 0;
}
.chat-avatar {
  width: 36px;
  height: 36px;
  background: var(--cyan);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--navy-900);
  flex-shrink: 0;
}
.chat-header-info { flex: 1; }
.chat-header-name { font-weight: 700; font-size: 0.9rem; color: white; line-height: 1.2; }
.chat-header-status {
  font-size: 0.7rem;
  color: var(--green);
  display: flex;
  align-items: center;
  gap: 0.3rem;
}
.chat-header-status::before {
  content: '';
  width: 6px; height: 6px;
  background: var(--green);
  border-radius: 50%;
  display: inline-block;
}
#chat-expand-btn {
  background: none;
  border: none;
  color: rgba(255,255,255,0.4);
  cursor: pointer;
  font-size: 1rem;
  padding: 0.2rem 0.3rem;
  line-height: 1;
  transition: color 0.15s;
  margin-right: 0.1rem;
}
#chat-expand-btn:hover { color: var(--cyan); }
.chat-close-btn {
  background: none;
  border: none;
  color: rgba(255,255,255,0.5);
  cursor: pointer;
  font-size: 1.1rem;
  padding: 0.2rem;
  line-height: 1;
  transition: color 0.15s;
}
.chat-close-btn:hover { color: white; }

/* Messages */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  scroll-behavior: smooth;
}
.chat-messages::-webkit-scrollbar { width: 4px; }
.chat-messages::-webkit-scrollbar-track { background: transparent; }
.chat-messages::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); border-radius: 2px; }

.chat-msg {
  max-width: 88%;
  animation: msg-in 0.2s ease;
}
@keyframes msg-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}
.chat-msg.bot { align-self: flex-start; }
.chat-msg.user { align-self: flex-end; }

.chat-bubble-text {
  padding: 0.6rem 0.9rem;
  border-radius: 12px;
  font-size: 0.82rem;
  line-height: 1.6;
}
.chat-msg.bot .chat-bubble-text {
  background: rgba(255,255,255,0.07);
  color: rgba(255,255,255,0.9);
  border-bottom-left-radius: 3px;
}
.chat-msg.user .chat-bubble-text {
  background: var(--cyan);
  color: var(--navy-900);
  font-weight: 600;
  border-bottom-right-radius: 3px;
}

/* Typing indicator */
.chat-typing {
  align-self: flex-start;
  display: flex;
  gap: 4px;
  padding: 0.65rem 0.9rem;
  background: rgba(255,255,255,0.07);
  border-radius: 12px;
  border-bottom-left-radius: 3px;
}
.chat-typing span {
  width: 7px; height: 7px;
  background: rgba(255,255,255,0.4);
  border-radius: 50%;
  animation: typing-bounce 1.2s infinite;
}
.chat-typing span:nth-child(2) { animation-delay: 0.2s; }
.chat-typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes typing-bounce {
  0%,60%,100% { transform: translateY(0); }
  30% { transform: translateY(-5px); background: var(--cyan); }
}

/* Quick chips */
.chat-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.5rem;
}
.chat-chip {
  background: rgba(0,180,216,0.12);
  border: 1px solid rgba(0,180,216,0.3);
  color: var(--cyan);
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.3rem 0.7rem;
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}
.chat-chip:hover {
  background: rgba(0,180,216,0.25);
  border-color: var(--cyan);
}

/* Info card inside message */
.chat-card {
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(0,180,216,0.2);
  border-radius: 10px;
  padding: 0.75rem;
  margin-top: 0.4rem;
  font-size: 0.79rem;
}
.chat-card-row {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  padding: 0.2rem 0;
  color: rgba(255,255,255,0.8);
  line-height: 1.5;
  flex-wrap: wrap;
}
.chat-card-row strong {
  color: var(--cyan);
  min-width: 90px;
  max-width: 110px;
  flex-shrink: 0;
  word-break: break-word;
}
.chat-card-row span {
  flex: 1;
  min-width: 0;
  word-break: break-word;
  overflow-wrap: break-word;
}
.chat-card a { color: var(--cyan); text-decoration: none; word-break: break-all; }
.chat-card a:hover { text-decoration: underline; }
.chat-card-title {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--cyan);
  margin-bottom: 0.4rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* Resume buttons */
.chat-resume-btns {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.5rem;
  flex-wrap: wrap;
}
.chat-resume-btns a {
  background: var(--cyan);
  color: var(--navy-900) !important;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.35rem 0.9rem;
  border-radius: 6px;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  transition: background 0.15s;
}
.chat-resume-btns a:hover { background: var(--cyan-light); }

/* Input area */
.chat-input-row {
  padding: 0.75rem 1rem;
  border-top: 1px solid rgba(255,255,255,0.08);
  display: flex;
  gap: 0.5rem;
  flex-shrink: 0;
}
#chat-input {
  flex: 1;
  background: rgba(255,255,255,0.07);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 8px;
  color: white;
  font-size: 0.82rem;
  padding: 0.5rem 0.75rem;
  outline: none;
  transition: border-color 0.15s;
  font-family: inherit;
}
#chat-input::placeholder { color: rgba(255,255,255,0.3); }
#chat-input:focus { border-color: var(--cyan); }
#chat-send {
  background: var(--cyan);
  border: none;
  border-radius: 8px;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.15s;
}
#chat-send:hover { background: var(--cyan-light); }
#chat-send svg { width: 16px; height: 16px; fill: var(--navy-900); }

/* Nudge tooltip above bubble */
#chat-nudge {
  position: fixed;
  bottom: 5rem;
  right: 1.75rem;
  background: var(--navy-800);
  border: 1px solid rgba(0,180,216,0.35);
  color: rgba(255,255,255,0.92);
  font-size: 0.78rem;
  font-weight: 600;
  padding: 0.45rem 0.85rem;
  border-radius: 10px;
  white-space: nowrap;
  z-index: 9997;
  box-shadow: 0 4px 16px rgba(0,0,0,0.3);
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 0.3s ease, transform 0.3s ease;
  pointer-events: none;
}
#chat-nudge::after {
  content: '';
  position: absolute;
  bottom: -6px;
  right: 18px;
  width: 10px;
  height: 10px;
  background: var(--navy-800);
  border-right: 1px solid rgba(0,180,216,0.35);
  border-bottom: 1px solid rgba(0,180,216,0.35);
  transform: rotate(45deg);
}
#chat-nudge.visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
  cursor: pointer;
}

/* Expanded panel — slides wider to the left */
#chat-panel.expanded {
  width: 520px;
  max-width: calc(100vw - 2rem);
}

/* Mobile adjustments */
@media (max-width: 576px) {
  #chat-panel {
    right: 0.75rem;
    left: 0.75rem;
    width: auto;
    bottom: 5rem;
  }
  #chat-panel.expanded {
    width: auto;
    left: 0.75rem;
    right: 0.75rem;
  }
  #chat-expand-btn { display: none; }
  #chat-bubble { bottom: 1.25rem; right: 1.25rem; }
  #chat-nudge { right: 0.75rem; bottom: 4.5rem; }
}
