/* ============================================================
   SOVAMOON — CHATBOT WIDGET STYLES
   ============================================================ */

/* ========================
   KEYFRAME ANIMATIONS
   ======================== */
@keyframes sovaButtonPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(0, 212, 255, 0.4), 0 8px 32px rgba(0, 212, 255, 0.3); }
  50%       { box-shadow: 0 0 0 12px rgba(0, 212, 255, 0), 0 8px 32px rgba(0, 212, 255, 0.3); }
}

@keyframes sovaSlideUp {
  from { opacity: 0; transform: translateY(20px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes sovaSlideDown {
  from { opacity: 1; transform: translateY(0) scale(1); }
  to   { opacity: 0; transform: translateY(20px) scale(0.97); }
}

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

@keyframes sovaTyping1 {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30%           { transform: translateY(-6px); opacity: 1; }
}
@keyframes sovaTyping2 {
  0%, 20%, 80%, 100% { transform: translateY(0); opacity: 0.4; }
  50%               { transform: translateY(-6px); opacity: 1; }
}
@keyframes sovaTyping3 {
  0%, 40%, 100% { transform: translateY(0); opacity: 0.4; }
  70%           { transform: translateY(-6px); opacity: 1; }
}

@keyframes sovaNotifBounce {
  0%, 100% { transform: scale(1); }
  50%      { transform: scale(1.15); }
}

@keyframes sovaTooltipFade {
  0%   { opacity: 0; transform: translateY(6px); }
  15%  { opacity: 1; transform: translateY(0); }
  80%  { opacity: 1; transform: translateY(0); }
  100% { opacity: 0; transform: translateY(-4px); }
}

@keyframes sovaStatusPulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.5; }
}

/* ========================
   WIDGET CONTAINER
   ======================== */
#sova-widget {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 99999;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 14px;
  line-height: 1.5;
  color: #ffffff;
}

/* ========================
   TOGGLE BUTTON
   ======================== */
#sova-btn {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: linear-gradient(135deg, #00D4FF 0%, #0099cc 50%, #7B2FFF 100%);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 32px rgba(0, 212, 255, 0.3);
  transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1),
              box-shadow 0.25s ease;
  animation: sovaButtonPulse 3s ease-in-out infinite;
  position: relative;
  outline: none;
}

#sova-btn:hover {
  transform: scale(1.1);
  box-shadow: 0 12px 40px rgba(0, 212, 255, 0.45);
  animation: none;
}

#sova-btn:active {
  transform: scale(0.95);
}

#sova-btn.is-open {
  animation: none;
  background: linear-gradient(135deg, #1a1f3e 0%, #0f1530 100%);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

#sova-btn svg {
  width: 26px;
  height: 26px;
  color: #ffffff;
  transition: opacity 0.2s ease, transform 0.2s ease;
  flex-shrink: 0;
}

/* Notification badge dot */
#sova-notif-dot {
  display: none;
  position: absolute;
  top: -2px;
  right: -2px;
  width: 18px;
  height: 18px;
  background: #FF4D6D;
  border-radius: 50%;
  border: 2px solid rgba(5, 8, 16, 1);
  animation: sovaNotifBounce 1.5s ease-in-out infinite;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 700;
  color: #fff;
}

#sova-notif-dot.is-visible {
  display: flex;
}

/* Tooltip above button */
#sova-tooltip {
  display: none;
  position: absolute;
  bottom: calc(100% + 12px);
  right: 0;
  background: rgba(10, 15, 44, 0.98);
  border: 1px solid rgba(0, 212, 255, 0.25);
  border-radius: 12px;
  padding: 12px 16px;
  white-space: nowrap;
  font-size: 13px;
  font-weight: 500;
  color: #e8eaf0;
  pointer-events: none;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}

#sova-tooltip::after {
  content: '';
  position: absolute;
  top: 100%;
  right: 22px;
  border: 7px solid transparent;
  border-top-color: rgba(0, 212, 255, 0.25);
}

#sova-tooltip::before {
  content: '';
  position: absolute;
  top: calc(100% - 1px);
  right: 23px;
  border: 6px solid transparent;
  border-top-color: rgba(10, 15, 44, 0.98);
  z-index: 1;
}

#sova-tooltip.is-visible {
  display: block;
  animation: sovaTooltipFade 5s ease-in-out forwards;
}

/* ========================
   CHAT PANEL
   ======================== */
#sova-panel {
  display: none;
  position: absolute;
  bottom: 72px;
  right: 0;
  width: 380px;
  height: 520px;
  background: rgba(10, 15, 44, 0.97);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(0, 212, 255, 0.2);
  border-radius: 16px;
  box-shadow: 0 0 40px rgba(0, 212, 255, 0.12),
              0 24px 64px rgba(0, 0, 0, 0.6);
  flex-direction: column;
  overflow: hidden;
}

#sova-panel.is-open {
  display: flex;
  animation: sovaSlideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

#sova-panel.is-closing {
  animation: sovaSlideDown 0.25s ease-in forwards;
}

/* ========================
   CHAT HEADER
   ======================== */
.sova-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 18px;
  background: rgba(0, 212, 255, 0.04);
  border-bottom: 1px solid rgba(0, 212, 255, 0.1);
  flex-shrink: 0;
}

.sova-header-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, #00D4FF 0%, #7B2FFF 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 800;
  font-size: 16px;
  color: #fff;
  flex-shrink: 0;
  position: relative;
}

.sova-header-status {
  position: absolute;
  bottom: 1px;
  right: 1px;
  width: 10px;
  height: 10px;
  background: #22c55e;
  border-radius: 50%;
  border: 2px solid rgba(10, 15, 44, 0.97);
  animation: sovaStatusPulse 2s ease-in-out infinite;
}

.sova-header-info {
  flex: 1;
  min-width: 0;
}

.sova-header-name {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 14px;
  font-weight: 700;
  color: #ffffff;
  line-height: 1.2;
}

.sova-header-subtitle {
  font-size: 11px;
  color: rgba(160, 174, 192, 0.7);
  margin-top: 2px;
}

.sova-header-actions {
  display: flex;
  gap: 4px;
}

.sova-header-btn {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: rgba(160, 174, 192, 0.7);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  line-height: 1;
  transition: background 0.15s ease, color 0.15s ease;
  outline: none;
}

.sova-header-btn:hover {
  background: rgba(0, 212, 255, 0.12);
  color: #ffffff;
  border-color: rgba(0, 212, 255, 0.2);
}

/* ========================
   MESSAGES AREA
   ======================== */
.sova-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scroll-behavior: smooth;
}

/* Custom scrollbar */
.sova-messages::-webkit-scrollbar {
  width: 4px;
}
.sova-messages::-webkit-scrollbar-track {
  background: transparent;
}
.sova-messages::-webkit-scrollbar-thumb {
  background: rgba(0, 212, 255, 0.25);
  border-radius: 4px;
}
.sova-messages::-webkit-scrollbar-thumb:hover {
  background: rgba(0, 212, 255, 0.45);
}

/* Message row wrappers */
.sova-msg-row {
  display: flex;
  gap: 8px;
  animation: sovaFadeIn 0.3s ease forwards;
}

.sova-msg-row.is-bot {
  align-items: flex-end;
}

.sova-msg-row.is-user {
  flex-direction: row-reverse;
}

/* Bot avatar in messages */
.sova-msg-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: linear-gradient(135deg, #00D4FF 0%, #7B2FFF 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 800;
  font-size: 11px;
  color: #fff;
  flex-shrink: 0;
}

/* Message bubbles */
.sova-bubble {
  max-width: 80%;
  padding: 10px 14px;
  border-radius: 14px;
  line-height: 1.55;
  font-size: 13.5px;
  position: relative;
  word-break: break-word;
}

.sova-msg-row.is-bot .sova-bubble {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-left: 3px solid rgba(0, 212, 255, 0.5);
  border-radius: 4px 14px 14px 4px;
  color: rgba(255, 255, 255, 0.9);
}

.sova-msg-row.is-user .sova-bubble {
  background: linear-gradient(135deg, rgba(0, 212, 255, 0.85) 0%, rgba(0, 153, 204, 0.9) 100%);
  color: #ffffff;
  border-radius: 14px 4px 4px 14px;
  border: none;
}

/* Timestamp on hover */
.sova-bubble::after {
  content: attr(data-time);
  display: block;
  font-size: 10px;
  color: rgba(255, 255, 255, 0.3);
  margin-top: 4px;
  text-align: right;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.sova-bubble:hover::after {
  opacity: 1;
}

/* ========================
   TYPING INDICATOR
   ======================== */
.sova-typing-row {
  display: none;
  gap: 8px;
  align-items: flex-end;
  animation: sovaFadeIn 0.25s ease forwards;
}

.sova-typing-row.is-visible {
  display: flex;
}

.sova-typing-bubble {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-left: 3px solid rgba(0, 212, 255, 0.5);
  border-radius: 4px 14px 14px 4px;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 5px;
}

.sova-dot {
  width: 7px;
  height: 7px;
  background: rgba(0, 212, 255, 0.7);
  border-radius: 50%;
}

.sova-dot:nth-child(1) { animation: sovaTyping1 1.2s ease-in-out infinite; }
.sova-dot:nth-child(2) { animation: sovaTyping2 1.2s ease-in-out infinite; }
.sova-dot:nth-child(3) { animation: sovaTyping3 1.2s ease-in-out infinite; }

/* ========================
   QUICK REPLY BUTTONS
   ======================== */
.sova-quick-replies {
  display: none;
  flex-wrap: wrap;
  gap: 7px;
  padding: 0 16px 12px;
  flex-shrink: 0;
}

.sova-quick-replies.is-visible {
  display: flex;
}

.sova-quick-btn {
  background: transparent;
  border: 1px solid rgba(0, 212, 255, 0.3);
  border-radius: 100px;
  padding: 6px 14px;
  font-size: 12.5px;
  font-weight: 500;
  color: rgba(0, 212, 255, 0.9);
  cursor: pointer;
  transition: background 0.18s ease, border-color 0.18s ease, color 0.18s ease, transform 0.15s ease;
  outline: none;
  white-space: nowrap;
  font-family: inherit;
}

.sova-quick-btn:hover {
  background: rgba(0, 212, 255, 0.1);
  border-color: rgba(0, 212, 255, 0.6);
  color: #ffffff;
  transform: translateY(-1px);
}

.sova-quick-btn:active {
  transform: translateY(0);
}

/* ========================
   INPUT AREA
   ======================== */
.sova-input-area {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 14px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  background: rgba(0, 0, 0, 0.2);
  flex-shrink: 0;
}

#sova-input {
  flex: 1;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 100px;
  padding: 10px 16px;
  color: #ffffff;
  font-size: 13.5px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  min-width: 0;
}

#sova-input::placeholder {
  color: rgba(160, 174, 192, 0.4);
}

#sova-input:focus {
  border-color: rgba(0, 212, 255, 0.5);
  box-shadow: 0 0 0 3px rgba(0, 212, 255, 0.1);
  background: rgba(255, 255, 255, 0.08);
}

#sova-input:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

#sova-send {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: linear-gradient(135deg, #00D4FF 0%, #0099cc 100%);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: transform 0.2s ease, box-shadow 0.2s ease, opacity 0.2s ease;
  outline: none;
}

#sova-send svg {
  width: 16px;
  height: 16px;
  color: #ffffff;
}

#sova-send:hover {
  transform: scale(1.08);
  box-shadow: 0 4px 16px rgba(0, 212, 255, 0.35);
}

#sova-send:active {
  transform: scale(0.95);
}

#sova-send:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

/* ========================
   WELCOME BACK BADGE
   ======================== */
.sova-welcome-back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(0, 212, 255, 0.08);
  border: 1px solid rgba(0, 212, 255, 0.2);
  border-radius: 100px;
  padding: 5px 12px;
  font-size: 11px;
  font-weight: 600;
  color: rgba(0, 212, 255, 0.9);
  align-self: center;
  margin-bottom: 4px;
}

/* ========================
   MOBILE — FULL SCREEN
   ======================== */
@media (max-width: 480px) {
  #sova-widget {
    bottom: 16px;
    right: 16px;
  }

  #sova-panel {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100vw;
    height: 100%;
    border-radius: 0;
    border: none;
    box-shadow: none;
    /* Safe area padding for notched phones */
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }

  #sova-panel.is-open {
    animation: none;
  }

  .sova-bubble {
    max-width: 88%;
  }

  /* Ensure input stays above keyboard */
  .sova-input-area {
    padding-bottom: max(12px, env(safe-area-inset-bottom, 12px));
  }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  #sova-btn,
  .sova-msg-row,
  .sova-typing-bubble,
  .sova-dot,
  #sova-panel.is-open {
    animation: none !important;
  }
  #sova-panel.is-open {
    opacity: 1;
    transform: none;
  }
}

/* ─── New Conversation Button ─────────────────────────────────── */
.sova-new-convo-btn {
  display:         block;
  width:           calc(100% - 24px);
  margin:          0 12px 12px;
  padding:         10px 16px;
  background:      linear-gradient(135deg, rgba(0,212,255,0.15), rgba(123,47,255,0.15));
  border:          1px solid rgba(0,212,255,0.35);
  border-radius:   8px;
  color:           #00D4FF;
  font-size:       0.875rem;
  font-weight:     600;
  cursor:          pointer;
  text-align:      center;
  transition:      all 0.2s;
  letter-spacing:  0.02em;
}

.sova-new-convo-btn:hover {
  background:      linear-gradient(135deg, rgba(0,212,255,0.22), rgba(123,47,255,0.22));
  border-color:    rgba(0,212,255,0.6);
  box-shadow:      0 0 16px rgba(0,212,255,0.2);
}
