/* =========================================================
   Smart Searcher Chat Widget — Vokraft
   Theme: Dark Glassmorphism + Gold (#cca353)
   ========================================================= */

/* --- Floating Button --- */
.chat-fab {
  position: fixed;
  bottom: 28px;
  right: 28px;
  z-index: 1050;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: #cca353;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 20px rgba(204, 163, 83, 0.45);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.chat-fab:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 28px rgba(204, 163, 83, 0.6);
}
.chat-fab svg {
  pointer-events: none;
}

/* --- Backdrop --- */
.chat-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 1060;
  backdrop-filter: blur(2px);
}
.chat-backdrop.is-open {
  display: block;
}

/* --- Modal Panel --- */
.chat-modal {
  display: none;
  position: fixed;
  bottom: 100px;
  right: 28px;
  width: 360px;
  max-width: calc(100vw - 40px);
  height: 520px;
  max-height: calc(100vh - 140px);
  z-index: 1070;
  border-radius: 16px;
  background: rgba(20, 20, 20, 0.96);
  border: 1px solid rgba(204, 163, 83, 0.25);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  box-shadow: 0 12px 48px rgba(0, 0, 0, 0.6);
  flex-direction: column;
  overflow: hidden;
}
.chat-modal.is-open {
  display: flex;
}

/* --- Header --- */
.chat-modal__header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  background: rgba(204, 163, 83, 0.1);
  border-bottom: 1px solid rgba(204, 163, 83, 0.2);
  flex-shrink: 0;
}
.chat-modal__avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: #cca353;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.chat-modal__title {
  flex: 1;
}
.chat-modal__title strong {
  display: block;
  color: #fff;
  font-size: 0.9rem;
  font-weight: 600;
  letter-spacing: 0.01em;
}
.chat-modal__title span {
  font-size: 0.72rem;
  color: #cca353;
}
.chat-modal__close {
  background: none;
  border: none;
  cursor: pointer;
  color: #999;
  padding: 4px;
  border-radius: 6px;
  line-height: 1;
  transition: color 0.15s;
}
.chat-modal__close:hover {
  color: #fff;
}

/* --- Messages Area --- */
.chat-modal__body {
  flex: 1;
  overflow-y: auto;
  padding: 16px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scrollbar-width: thin;
  scrollbar-color: rgba(204, 163, 83, 0.3) transparent;
}
.chat-modal__body::-webkit-scrollbar {
  width: 4px;
}
.chat-modal__body::-webkit-scrollbar-thumb {
  background: rgba(204, 163, 83, 0.3);
  border-radius: 4px;
}

/* --- Bubbles --- */
.chat-bubble {
  max-width: 82%;
  padding: 10px 13px;
  border-radius: 14px;
  font-size: 0.86rem;
  line-height: 1.5;
  word-wrap: break-word;
  animation: bubbleIn 0.2s ease;
}
@keyframes bubbleIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}
.chat-bubble--user {
  align-self: flex-end;
  background: #cca353;
  color: #1a1a1a;
  border-bottom-right-radius: 4px;
  font-weight: 500;
}
.chat-bubble--assistant {
  align-self: flex-start;
  background: rgba(255, 255, 255, 0.07);
  color: #e8e8e8;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-bottom-left-radius: 4px;
}

/* --- Rich content inside assistant bubbles --- */
.chat-bubble--assistant a {
  color: #cca353;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.chat-bubble--assistant a:hover {
  color: #e0b96a;
}
.chat-bubble--assistant strong {
  color: #fff;
  font-weight: 600;
}
.chat-bubble--assistant .chat-p {
  margin: 0 0 6px;
}
.chat-bubble--assistant .chat-p:last-child {
  margin-bottom: 0;
}

/* --- Portfolio / list cards inside assistant bubble --- */
.chat-card {
  background: rgba(204, 163, 83, 0.08);
  border: 1px solid rgba(204, 163, 83, 0.22);
  border-radius: 10px;
  padding: 9px 12px;
  margin: 5px 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.chat-card__title {
  color: #cca353;
  font-weight: 600;
  font-size: 0.84rem;
  line-height: 1.35;
}
.chat-card__detail {
  color: rgba(232, 232, 232, 0.72);
  font-size: 0.78rem;
  line-height: 1.4;
}

/* --- Error bubble variant --- */
.chat-bubble--error {
  background: rgba(239, 68, 68, 0.12) !important;
  border-color: rgba(239, 68, 68, 0.25) !important;
  color: #fca5a5 !important;
}

/* --- Typing Indicator --- */
.chat-typing {
  display: none;
  align-self: flex-start;
  padding: 10px 14px;
  background: rgba(255, 255, 255, 0.07);
  border-radius: 14px;
  border-bottom-left-radius: 4px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  gap: 5px;
  align-items: center;
  /* Sticky at bottom while inside scrollable body */
  position: sticky;
  bottom: 0;
}
.chat-typing.is-visible {
  display: flex;
}
.chat-typing__dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #cca353;
  animation: typingDot 1.2s infinite ease-in-out;
}
.chat-typing__dot:nth-child(2) { animation-delay: 0.2s; }
.chat-typing__dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes typingDot {
  0%, 80%, 100% { transform: scale(0.7); opacity: 0.5; }
  40%           { transform: scale(1);   opacity: 1; }
}

/* --- Footer / Input --- */
.chat-modal__footer {
  padding: 12px 14px;
  border-top: 1px solid rgba(204, 163, 83, 0.15);
  display: flex;
  gap: 8px;
  align-items: flex-end;
  flex-shrink: 0;
}
.chat-modal__input {
  flex: 1;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(204, 163, 83, 0.25);
  border-radius: 10px;
  color: #fff;
  font-size: 0.86rem;
  padding: 9px 12px;
  resize: none;
  outline: none;
  min-height: 40px;
  max-height: 100px;
  transition: border-color 0.15s;
  font-family: inherit;
  line-height: 1.4;
}
.chat-modal__input::placeholder {
  color: #666;
}
.chat-modal__input:focus {
  border-color: rgba(204, 163, 83, 0.55);
}
.chat-modal__send {
  flex-shrink: 0;
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: #cca353;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, transform 0.15s;
}
.chat-modal__send:hover {
  background: #b8903e;
  transform: scale(1.05);
}
.chat-modal__send:disabled {
  background: #555;
  cursor: not-allowed;
  transform: none;
}
.chat-modal__send svg {
  pointer-events: none;
}

/* --- Desktop header button (replaces search) --- */
.icon-btn.chat-btn {
  cursor: pointer;
  background: none;
  border: none;
  padding: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
}

/* --- Mobile --- */
@media (max-width: 600px) {
  .chat-modal {
    bottom: 84px;
    right: 0;
    left: 0;
    width: 100%;
    max-width: 100%;
    border-radius: 16px 16px 0 0;
    height: 70vh;
    max-height: 70vh;
  }
  .chat-fab {
    bottom: 20px;
    right: 20px;
  }
}
