/* ============================================
   V3 CLASSES — Advanced Chatbot Widget Styles
   Floating bubble, guided quick-replies, typing dots & responsive
   ============================================ */

.v3-chat-widget {
  position: fixed;
  bottom: 96px;
  right: 24px;
  z-index: 9999;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* ── Toggle Floating Button ── */
.v3-chat-toggle {
  width: 58px;
  height: 58px;
  border-radius: 50%;
  background: linear-gradient(135deg, #1D4ED8 0%, #2563EB 50%, #3B82F6 100%);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 28px rgba(29, 78, 216, 0.45);
  transition: transform 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275), box-shadow 0.25s ease;
  color: #fff;
  position: relative;
}

.v3-chat-toggle:hover {
  transform: scale(1.08);
  box-shadow: 0 12px 32px rgba(29, 78, 216, 0.55);
}

.v3-chat-toggle svg {
  width: 26px;
  height: 26px;
  transition: transform 0.2s ease;
}

.v3-chat-toggle .close-icon {
  display: none;
}

.v3-chat-widget.open .v3-chat-toggle .chat-icon {
  display: none;
}

.v3-chat-widget.open .v3-chat-toggle .close-icon {
  display: block;
}

/* Badge dot */
.v3-chat-toggle__badge {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 14px;
  height: 14px;
  background: #10B981;
  border: 2px solid #fff;
  border-radius: 50%;
}

/* ── Chat Window / Panel ── */
.v3-chat-panel {
  position: absolute;
  bottom: 74px;
  right: 0;
  width: 380px;
  height: 560px;
  max-height: calc(100vh - 120px);
  background: #FFFFFF;
  border-radius: 18px;
  box-shadow: 0 16px 48px rgba(15, 23, 42, 0.2), 0 0 1px rgba(0,0,0,0.1);
  display: none;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid #E2E8F0;
  transform-origin: bottom right;
}

.v3-chat-widget.open .v3-chat-panel {
  display: flex;
  animation: v3ChatPop 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes v3ChatPop {
  0% { opacity: 0; transform: scale(0.9) translateY(20px); }
  100% { opacity: 1; transform: scale(1) translateY(0); }
}

/* ── Header ── */
.v3-chat-header {
  padding: 14px 18px;
  background: linear-gradient(135deg, #1D4ED8 0%, #1E40AF 100%);
  color: #FFFFFF;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.v3-chat-header__brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.v3-chat-header__avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  border: 1.5px solid rgba(255,255,255,0.4);
}

.v3-chat-header__info h4 {
  font-size: 0.96rem;
  font-weight: 700;
  margin: 0;
  letter-spacing: -0.2px;
}

.v3-chat-header__info p {
  font-size: 0.72rem;
  color: rgba(255, 255, 255, 0.85);
  margin: 0;
  display: flex;
  align-items: center;
  gap: 5px;
}

.v3-chat-status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #10B981;
  display: inline-block;
  box-shadow: 0 0 6px #10B981;
}

.v3-chat-header__actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.v3-chat-action-btn {
  background: rgba(255, 255, 255, 0.15);
  border: none;
  color: #fff;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s ease;
}

.v3-chat-action-btn:hover {
  background: rgba(255, 255, 255, 0.3);
}

.v3-chat-action-btn svg {
  width: 16px;
  height: 16px;
}

/* ── Messages Stream ── */
.v3-chat-messages {
  flex: 1;
  padding: 16px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: #F8FAFC;
  scroll-behavior: smooth;
}

.v3-chat-msg-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-width: 88%;
}

.v3-chat-msg-row--bot {
  align-self: flex-start;
}

.v3-chat-msg-row--user {
  align-self: flex-end;
}

.v3-chat-bubble {
  padding: 11px 15px;
  border-radius: 16px;
  font-size: 0.9rem;
  line-height: 1.5;
  word-break: break-word;
  white-space: pre-line;
}

.v3-chat-msg-row--bot .v3-chat-bubble {
  background: #FFFFFF;
  color: #1E293B;
  border: 1px solid #E2E8F0;
  border-bottom-left-radius: 4px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

.v3-chat-msg-row--user .v3-chat-bubble {
  background: linear-gradient(135deg, #1D4ED8 0%, #2563EB 100%);
  color: #FFFFFF;
  border-bottom-right-radius: 4px;
  box-shadow: 0 2px 6px rgba(29, 78, 216, 0.25);
}

.v3-chat-time {
  font-size: 0.68rem;
  color: #94A3B8;
  margin-top: 2px;
  padding: 0 4px;
}

.v3-chat-msg-row--user .v3-chat-time {
  text-align: right;
}

/* ── Quick Reply Options ── */
.v3-chat-options {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 4px;
  padding: 2px 0;
}

.v3-chat-option-btn {
  padding: 6px 13px;
  background: #FFFFFF;
  color: #1D4ED8;
  border: 1.5px solid #DBEAFE;
  border-radius: 18px;
  font-size: 0.8rem;
  font-weight: 550;
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: inherit;
  box-shadow: 0 1px 2px rgba(0,0,0,0.03);
}

.v3-chat-option-btn:hover {
  background: #1D4ED8;
  color: #FFFFFF;
  border-color: #1D4ED8;
  transform: translateY(-1px);
  box-shadow: 0 3px 8px rgba(29, 78, 216, 0.25);
}

.v3-chat-option-btn:active {
  transform: scale(0.97);
}

/* ── Typing Indicator ── */
.v3-chat-typing {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 10px 14px;
  background: #FFFFFF;
  border: 1px solid #E2E8F0;
  border-radius: 16px;
  border-bottom-left-radius: 4px;
  width: fit-content;
  align-self: flex-start;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

.v3-chat-typing-dot {
  width: 6px;
  height: 6px;
  background: #94A3B8;
  border-radius: 50%;
  animation: v3TypingBounce 1.3s infinite ease-in-out;
}

.v3-chat-typing-dot:nth-child(1) { animation-delay: 0s; }
.v3-chat-typing-dot:nth-child(2) { animation-delay: 0.2s; }
.v3-chat-typing-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes v3TypingBounce {
  0%, 60%, 100% { transform: translateY(0); }
  30% { transform: translateY(-5px); background: #1D4ED8; }
}

/* ── Input Area ── */
.v3-chat-footer {
  padding: 12px 14px;
  background: #FFFFFF;
  border-top: 1px solid #E2E8F0;
  display: flex;
  align-items: center;
  gap: 8px;
}

.v3-chat-input-wrapper {
  flex: 1;
  position: relative;
}

.v3-chat-input {
  width: 100%;
  padding: 10px 14px;
  background: #F1F5F9;
  border: 1px solid #E2E8F0;
  border-radius: 24px;
  font-size: 0.9rem;
  font-family: inherit;
  color: #1E293B;
  outline: none;
  transition: border-color 0.2s ease, background 0.2s ease;
  box-sizing: border-box;
}

.v3-chat-input:focus {
  border-color: #2563EB;
  background: #FFFFFF;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.v3-chat-send-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: #1D4ED8;
  border: none;
  color: #FFFFFF;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.2s ease, transform 0.15s ease;
}

.v3-chat-send-btn:hover {
  background: #1E40AF;
  transform: scale(1.05);
}

.v3-chat-send-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
}

.v3-chat-send-btn svg {
  width: 18px;
  height: 18px;
  margin-left: 2px;
}

/* ── Responsive adjustments ── */
@media (max-width: 480px) {
  .v3-chat-widget {
    bottom: 80px;
    right: 16px;
  }
  .v3-chat-panel {
    width: calc(100vw - 32px);
    height: calc(100vh - 120px);
    right: -4px;
    bottom: 68px;
    border-radius: 14px;
  }
}
