/* ========================================
   UGuide Chatbot – Styling & Animation
   ======================================== */

/* --- Floating Bubble --- */
.uguide-bubble {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: var(--gradient-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 9999;
  box-shadow: 0 4px 20px rgba(79,70,229,0.4);
  transition: all 0.3s ease;
  border: none;
  outline: none;
}

.uguide-bubble:hover {
  transform: scale(1.1);
  box-shadow: 0 6px 30px rgba(79,70,229,0.5);
}

.uguide-bubble svg {
  stroke: white;
  transition: transform 0.3s ease;
}

.uguide-bubble.active svg {
  transform: rotate(90deg);
}

.uguide-bubble-ping {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: rgba(79,70,229,0.4);
  animation: bubblePing 2s ease-out infinite;
  pointer-events: none;
}

@keyframes bubblePing {
  0% { transform: scale(1); opacity: 0.6; }
  100% { transform: scale(1.8); opacity: 0; }
}

/* --- Chat Window --- */
.uguide-window {
  position: fixed;
  bottom: 6rem;
  right: 2rem;
  width: 380px;
  max-height: 560px;
  background: var(--color-white);
  border-radius: var(--radius-xl);
  box-shadow: 0 20px 60px rgba(0,0,0,0.15), 0 0 0 1px rgba(0,0,0,0.05);
  display: flex;
  flex-direction: column;
  z-index: 9998;
  overflow: hidden;
  opacity: 0;
  transform: translateY(20px) scale(0.95);
  pointer-events: none;
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.uguide-window.open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: all;
}

/* --- Header --- */
.uguide-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1.25rem 1.25rem 1rem;
  background: var(--gradient-hero);
  color: white;
  position: relative;
}

.uguide-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: rgba(255,255,255,0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 0.85rem;
  flex-shrink: 0;
  border: 2px solid rgba(255,255,255,0.2);
}

.uguide-header-info h4 {
  color: white;
  font-size: 0.95rem;
  font-weight: 700;
  margin: 0;
}

.uguide-header-info span {
  font-size: 0.75rem;
  color: rgba(255,255,255,0.6);
}

.uguide-status {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.uguide-status::before {
  content: '';
  width: 7px;
  height: 7px;
  background: #34D399;
  border-radius: 50%;
  display: inline-block;
}

.uguide-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  background: rgba(255,255,255,0.1);
  border: none;
  color: white;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}

.uguide-close:hover {
  background: rgba(255,255,255,0.2);
}

/* --- Messages Area --- */
.uguide-messages {
  flex: 1;
  overflow-y: auto;
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  min-height: 280px;
  max-height: 360px;
  scroll-behavior: smooth;
}

.uguide-messages::-webkit-scrollbar {
  width: 4px;
}

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

.uguide-messages::-webkit-scrollbar-thumb {
  background: var(--color-gray-200);
  border-radius: 2px;
}

/* --- Message Bubbles --- */
.uguide-msg {
  max-width: 85%;
  padding: 0.75rem 1rem;
  border-radius: 1rem;
  font-size: 0.88rem;
  line-height: 1.5;
  animation: msgSlideIn 0.3s ease;
}

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

.uguide-msg--bot {
  background: var(--color-gray-50);
  color: var(--color-gray-800);
  border-bottom-left-radius: 4px;
  align-self: flex-start;
  border: 1px solid var(--color-gray-100);
}

.uguide-msg--user {
  background: var(--gradient-primary);
  color: white;
  border-bottom-right-radius: 4px;
  align-self: flex-end;
}

/* --- Option Buttons --- */
.uguide-options {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-top: 0.25rem;
  animation: msgSlideIn 0.3s ease;
}

.uguide-option-btn {
  display: block;
  width: 100%;
  padding: 0.7rem 1rem;
  background: var(--color-white);
  border: 1.5px solid var(--color-gray-200);
  border-radius: var(--radius-md);
  font-family: var(--font-main);
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--color-gray-700);
  cursor: pointer;
  text-align: left;
  transition: all 0.2s ease;
}

.uguide-option-btn:hover {
  border-color: var(--color-primary);
  color: var(--color-primary);
  background: rgba(79,70,229,0.04);
  transform: translateX(4px);
}

/* --- Typing Indicator --- */
.uguide-typing {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 0.75rem 1rem;
  background: var(--color-gray-50);
  border-radius: 1rem;
  border-bottom-left-radius: 4px;
  align-self: flex-start;
  border: 1px solid var(--color-gray-100);
}

.uguide-typing span {
  width: 6px;
  height: 6px;
  background: var(--color-gray-400);
  border-radius: 50%;
  animation: typingBounce 1.4s ease-in-out infinite;
}

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

@keyframes typingBounce {
  0%, 60%, 100% { transform: translateY(0); }
  30% { transform: translateY(-5px); }
}

/* --- CTA Link in Message --- */
.uguide-msg a {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  color: var(--color-primary);
  font-weight: 600;
  text-decoration: underline;
  margin-top: 0.5rem;
}

/* --- Input Area --- */
.uguide-input-area {
  padding: 0.75rem 1rem;
  border-top: 1px solid var(--color-gray-100);
  background: var(--color-white);
}

.uguide-input-form {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.uguide-input {
  flex: 1;
  padding: 0.65rem 0.85rem;
  border: 1.5px solid var(--color-gray-200);
  border-radius: var(--radius-md);
  font-family: var(--font-main);
  font-size: 0.88rem;
  color: var(--color-gray-800);
  background: var(--color-gray-50);
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.uguide-input:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(79,70,229,0.08);
  background: var(--color-white);
}

.uguide-input::placeholder {
  color: var(--color-gray-400);
}

.uguide-send {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--gradient-primary);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: transform 0.2s, box-shadow 0.2s;
  color: white;
}

.uguide-send:hover {
  transform: scale(1.08);
  box-shadow: 0 2px 12px rgba(79,70,229,0.3);
}

.uguide-send svg {
  stroke: white;
}

/* --- Responsive --- */
@media (max-width: 480px) {
  .uguide-window {
    right: 0;
    bottom: 0;
    width: 100%;
    max-height: 100vh;
    border-radius: 0;
  }

  .uguide-bubble {
    bottom: 1rem;
    right: 1rem;
    width: 54px;
    height: 54px;
  }

  .uguide-messages {
    max-height: calc(100vh - 180px);
  }
}
