/* ===== BERMATER FLOATING AI CHAT BUBBLE ===== */

/* --- FAB Trigger Button --- */
.bermater-chat-fab-wrap {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  align-items: center;
  gap: 12px;
  font-family: var(--font-body, 'Inter', sans-serif);
}

.bermater-chat-pill {
  background: rgba(10, 8, 36, 0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  color: #F1F0FB;
  font-size: 0.82rem;
  font-weight: 600;
  padding: 8px 14px;
  border-radius: 9999px;
  border: 1px solid rgba(107, 72, 255, 0.35);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.35);
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  white-space: nowrap;
  user-select: none;
}

.bermater-chat-pill:hover {
  background: rgba(22, 17, 60, 0.98);
  border-color: rgba(107, 72, 255, 0.65);
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(107, 72, 255, 0.25);
}

.bermater-chat-pill-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #10B981;
  box-shadow: 0 0 10px #10B981;
  animation: chatPulseDot 2s infinite ease-in-out;
}

.bermater-chat-fab {
  width: 58px;
  height: 58px;
  border-radius: 50%;
  background: linear-gradient(135deg, #6B48FF 0%, #4A2FD9 100%);
  border: 1px solid rgba(255, 255, 255, 0.25);
  box-shadow: 0 8px 30px rgba(107, 72, 255, 0.45), 0 0 0 0 rgba(107, 72, 255, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #FFFFFF;
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  position: relative;
  outline: none;
  animation: chatFabPulse 3s infinite;
}

.bermater-chat-fab:hover {
  transform: scale(1.06) translateY(-2px);
  box-shadow: 0 12px 35px rgba(107, 72, 255, 0.6);
}

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

.bermater-chat-fab-icon {
  width: 26px;
  height: 26px;
  transition: transform 0.25s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.bermater-chat-fab-badge {
  position: absolute;
  top: -2px;
  right: -2px;
  background: #C8A84B;
  color: #06041A;
  font-size: 0.65rem;
  font-weight: 800;
  padding: 2px 6px;
  border-radius: 9999px;
  letter-spacing: 0.5px;
  border: 2px solid #06041A;
  text-transform: uppercase;
}

@keyframes chatPulseDot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.85); }
}

@keyframes chatFabPulse {
  0%, 100% { box-shadow: 0 8px 30px rgba(107, 72, 255, 0.45), 0 0 0 0 rgba(107, 72, 255, 0.3); }
  50% { box-shadow: 0 8px 30px rgba(107, 72, 255, 0.45), 0 0 0 10px rgba(107, 72, 255, 0); }
}

/* --- Chat Window Container --- */
.bermater-chat-window {
  position: fixed;
  bottom: 96px;
  right: 24px;
  width: 390px;
  max-width: calc(100vw - 32px);
  height: 580px;
  max-height: calc(100vh - 120px);
  background: rgba(10, 8, 36, 0.96);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(107, 72, 255, 0.3);
  border-radius: 20px;
  box-shadow: 0 24px 65px rgba(0, 0, 0, 0.65), 0 0 40px rgba(107, 72, 255, 0.15);
  display: flex;
  flex-direction: column;
  z-index: 10000;
  overflow: hidden;
  font-family: var(--font-body, 'Inter', sans-serif);
  opacity: 0;
  pointer-events: none;
  transform: translateY(20px) scale(0.95);
  transition: opacity 0.25s cubic-bezier(0.16, 1, 0.3, 1), transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.bermater-chat-window.open {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0) scale(1);
}

/* --- Chat Header --- */
.bermater-chat-header {
  padding: 16px 18px;
  background: linear-gradient(180deg, rgba(22, 17, 60, 0.95) 0%, rgba(13, 10, 42, 0.8) 100%);
  border-bottom: 1px solid rgba(107, 72, 255, 0.2);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  user-select: none;
}

.bermater-chat-header-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.bermater-chat-avatar {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  background: linear-gradient(135deg, rgba(107, 72, 255, 0.3), rgba(200, 168, 75, 0.2));
  border: 1px solid rgba(107, 72, 255, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #C8A84B;
  flex-shrink: 0;
}

.bermater-chat-avatar svg {
  width: 20px;
  height: 20px;
}

.bermater-chat-title-wrap {
  display: flex;
  flex-direction: column;
}

.bermater-chat-title {
  font-family: var(--font-head, 'Sora', sans-serif);
  font-size: 0.92rem;
  font-weight: 700;
  color: #FFFFFF;
  display: flex;
  align-items: center;
  gap: 6px;
}

.bermater-chat-status {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.72rem;
  color: #9D9BBB;
  font-weight: 500;
}

.bermater-chat-status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #10B981;
}

.bermater-chat-header-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.bermater-chat-btn-icon {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: transparent;
  border: none;
  color: #9D9BBB;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
  outline: none;
}

.bermater-chat-btn-icon:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #FFFFFF;
}

/* --- Banner Context --- */
.bermater-chat-banner {
  background: rgba(107, 72, 255, 0.08);
  border-bottom: 1px solid rgba(107, 72, 255, 0.15);
  padding: 8px 16px;
  font-size: 0.73rem;
  color: #A5A3C7;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.bermater-chat-banner strong {
  color: #E8C96A;
  font-weight: 600;
}

/* --- Message Thread --- */
.bermater-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  scroll-behavior: smooth;
}

.bermater-chat-messages::-webkit-scrollbar {
  width: 5px;
}

.bermater-chat-messages::-webkit-scrollbar-thumb {
  background: rgba(107, 72, 255, 0.3);
  border-radius: 4px;
}

.bermater-chat-messages::-webkit-scrollbar-track {
  background: transparent;
}

/* --- Suggestions Pills --- */
.bermater-chat-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 4px;
}

.bermater-chat-chip {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(107, 72, 255, 0.25);
  color: #C5C3E8;
  font-size: 0.75rem;
  padding: 6px 12px;
  border-radius: 9999px;
  cursor: pointer;
  transition: all 0.2s ease;
  outline: none;
  text-align: left;
}

.bermater-chat-chip:hover {
  background: rgba(107, 72, 255, 0.18);
  border-color: rgba(107, 72, 255, 0.6);
  color: #FFFFFF;
  transform: translateY(-1px);
}

/* --- Message Bubbles --- */
.bermater-msg {
  display: flex;
  flex-direction: column;
  max-width: 86%;
  animation: chatMsgFadeIn 0.22s ease-out;
}

@keyframes chatMsgFadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.bermater-msg.bot {
  align-self: flex-start;
}

.bermater-msg.user {
  align-self: flex-end;
}

.bermater-msg-bubble {
  padding: 11px 15px;
  font-size: 0.84rem;
  line-height: 1.55;
  word-break: break-word;
}

.bermater-msg.bot .bermater-msg-bubble {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.09);
  color: #E2E1F4;
  border-radius: 16px 16px 16px 4px;
}

.bermater-msg.user .bermater-msg-bubble {
  background: linear-gradient(135deg, #6B48FF 0%, #5031E2 100%);
  color: #FFFFFF;
  border-radius: 16px 16px 4px 16px;
  box-shadow: 0 4px 16px rgba(107, 72, 255, 0.3);
}

.bermater-msg-time {
  font-size: 0.68rem;
  color: #6B6987;
  margin-top: 4px;
  padding: 0 4px;
}

.bermater-msg.user .bermater-msg-time {
  text-align: right;
}

/* Formatting within bot bubbles */
.bermater-msg-bubble p {
  margin: 0 0 8px 0;
}

.bermater-msg-bubble p:last-child {
  margin-bottom: 0;
}

.bermater-msg-bubble ul, .bermater-msg-bubble ol {
  margin: 6px 0 8px 18px;
  padding: 0;
}

.bermater-msg-bubble li {
  margin-bottom: 4px;
}

.bermater-msg-bubble strong {
  color: #FFFFFF;
  font-weight: 600;
}

/* --- Typing Indicator --- */
.bermater-typing {
  align-self: flex-start;
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 12px 18px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 16px 16px 16px 4px;
}

.bermater-typing-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #6B48FF;
  animation: chatTypingBounce 1.4s infinite ease-in-out;
}

.bermater-typing-dot:nth-child(2) { animation-delay: 0.2s; }
.bermater-typing-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes chatTypingBounce {
  0%, 80%, 100% { transform: scale(0.7); opacity: 0.4; }
  40% { transform: scale(1.1); opacity: 1; }
}

/* --- Input Area --- */
.bermater-chat-input-area {
  padding: 12px 14px 14px 14px;
  background: rgba(13, 10, 42, 0.95);
  border-top: 1px solid rgba(107, 72, 255, 0.2);
}

.bermater-chat-form {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(107, 72, 255, 0.3);
  border-radius: 14px;
  padding: 4px 6px 4px 14px;
  transition: all 0.2s ease;
}

.bermater-chat-form:focus-within {
  border-color: #6B48FF;
  box-shadow: 0 0 0 3px rgba(107, 72, 255, 0.2);
  background: rgba(255, 255, 255, 0.07);
}

.bermater-chat-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: #FFFFFF;
  font-family: inherit;
  font-size: 0.85rem;
  padding: 8px 0;
}

.bermater-chat-input::placeholder {
  color: #6B6987;
}

.bermater-chat-send-btn {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, #6B48FF 0%, #4A2FD9 100%);
  border: none;
  color: #FFFFFF;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
  outline: none;
  flex-shrink: 0;
}

.bermater-chat-send-btn:hover:not(:disabled) {
  transform: scale(1.05);
  box-shadow: 0 4px 14px rgba(107, 72, 255, 0.4);
}

.bermater-chat-send-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.bermater-chat-disclaimer {
  text-align: center;
  font-size: 0.67rem;
  color: #6B6987;
  margin-top: 8px;
}

/* --- Mobile Responsiveness --- */
@media (max-width: 480px) {
  .bermater-chat-pill {
    display: none;
  }
  .bermater-chat-fab-wrap {
    bottom: 16px;
    right: 16px;
  }
  .bermater-chat-fab {
    width: 50px;
    height: 50px;
  }
  .bermater-chat-fab-icon {
    width: 22px;
    height: 22px;
  }
  .bermater-chat-fab-badge {
    font-size: 0.58rem;
    padding: 1px 5px;
    top: -3px;
    right: -3px;
  }
  .bermater-chat-window {
    bottom: 0;
    right: 0;
    left: 0;
    width: 100%;
    max-width: 100%;
    height: 84vh;
    max-height: 84vh;
    border-radius: 20px 20px 0 0;
    border-bottom: none;
  }
}
