/* ============================================
   IRUS GEAR AI Chatbot Widget
   ============================================ */

/* --- CSS Variables --- */
:root {
  --cb-primary: #4F46E5;
  --cb-primary-light: #818CF8;
  --cb-primary-dark: #3730A3;
  --cb-gradient: linear-gradient(135deg, #4F46E5 0%, #7C3AED 50%, #EC4899 100%);
  --cb-gradient-hover: linear-gradient(135deg, #4338CA 0%, #6D28D9 50%, #DB2777 100%);
  --cb-user-gradient: linear-gradient(135deg, #4F46E5 0%, #7C3AED 100%);
  --cb-bg: #F8FAFC;
  --cb-surface: #FFFFFF;
  --cb-text: #1E293B;
  --cb-text-secondary: #64748B;
  --cb-border: #E2E8F0;
  --cb-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
  --cb-shadow-sm: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
  --cb-radius: 20px;
  --cb-radius-sm: 12px;
  --cb-transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --cb-width: 400px;
  --cb-height: 560px;
}

/* --- Floating Button --- */
.chatbot-fab {
  position: fixed;
  bottom: 28px;
  right: 28px;
  z-index: 9998;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  border: none;
  background: var(--cb-gradient);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 32px rgba(79, 70, 229, 0.4);
  transition: var(--cb-transition);
  outline: none;
}

.chatbot-fab:hover {
  transform: scale(1.1);
  box-shadow: 0 12px 40px rgba(79, 70, 229, 0.55);
  background: var(--cb-gradient-hover);
}

.chatbot-fab:active {
  transform: scale(0.95);
}

.chatbot-fab .fab-icon {
  width: 28px;
  height: 28px;
  transition: var(--cb-transition);
}

.chatbot-fab.is-open .fab-icon-chat {
  opacity: 0;
  transform: rotate(90deg) scale(0);
  position: absolute;
}

.chatbot-fab.is-open .fab-icon-close {
  opacity: 1;
  transform: rotate(0deg) scale(1);
}

.chatbot-fab:not(.is-open) .fab-icon-chat {
  opacity: 1;
  transform: rotate(0deg) scale(1);
}

.chatbot-fab:not(.is-open) .fab-icon-close {
  opacity: 0;
  transform: rotate(-90deg) scale(0);
  position: absolute;
}

/* Pulse ring animation */
.chatbot-fab::before {
  content: "";
  position: absolute;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: var(--cb-gradient);
  opacity: 0;
  animation: cb-pulse 2.5s ease-out infinite;
}

.chatbot-fab.is-open::before {
  animation: none;
  opacity: 0;
}

@keyframes cb-pulse {
  0% { transform: scale(1); opacity: 0.5; }
  100% { transform: scale(1.8); opacity: 0; }
}

/* Badge */
.chatbot-fab-badge {
  position: absolute;
  top: -2px;
  right: -2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #EF4444;
  border: 2.5px solid #fff;
  animation: cb-badge-bounce 0.5s ease;
}

@keyframes cb-badge-bounce {
  0% { transform: scale(0); }
  50% { transform: scale(1.3); }
  100% { transform: scale(1); }
}

/* --- Chat Window --- */
.chatbot-window {
  position: fixed;
  bottom: 100px;
  right: 28px;
  z-index: 9999;
  width: var(--cb-width);
  height: var(--cb-height);
  max-height: calc(100dvh - 130px);
  border-radius: var(--cb-radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: var(--cb-shadow);
  border: 1px solid rgba(255, 255, 255, 0.15);
}

/* Transitions */
.chatbot-slide-enter-active {
  animation: cb-slide-in 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.chatbot-slide-leave-active {
  animation: cb-slide-out 0.25s cubic-bezier(0.4, 0, 1, 1);
}

@keyframes cb-slide-in {
  0% {
    opacity: 0;
    transform: translateY(20px) scale(0.92);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes cb-slide-out {
  0% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
  100% {
    opacity: 0;
    transform: translateY(20px) scale(0.92);
  }
}

/* --- Header --- */
.chatbot-header {
  background: linear-gradient(135deg, #1E1B4B 0%, #312E81 50%, #4338CA 100%);
  padding: 16px 18px;
  display: flex;
  align-items: center;
  gap: 12px;
  position: relative;
  overflow: hidden;
  flex-shrink: 0;
}

.chatbot-header::after {
  content: "";
  position: absolute;
  top: -50%;
  right: -30%;
  width: 200px;
  height: 200px;
  border-radius: 50%;
  background: rgba(124, 58, 237, 0.2);
  filter: blur(40px);
}

.chatbot-header-avatar {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.15);
  backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  position: relative;
  z-index: 1;
}

.chatbot-header-avatar svg {
  width: 22px;
  height: 22px;
  color: #C4B5FD;
}

.chatbot-header-info {
  flex: 1;
  min-width: 0;
  position: relative;
  z-index: 1;
}

.chatbot-header-title {
  font-size: 15px;
  font-weight: 700;
  color: #fff;
  margin: 0;
  letter-spacing: 0.2px;
}

.chatbot-header-status {
  font-size: 12px;
  color: #A5B4FC;
  display: flex;
  align-items: center;
  gap: 5px;
  margin-top: 2px;
}

.chatbot-status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #34D399;
  display: inline-block;
  animation: cb-status-pulse 2s ease infinite;
}

@keyframes cb-status-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

.chatbot-header-actions {
  display: flex;
  gap: 4px;
  position: relative;
  z-index: 1;
}

.chatbot-header-btn {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  border: none;
  background: rgba(255, 255, 255, 0.1);
  color: #C4B5FD;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--cb-transition);
}

.chatbot-header-btn:hover {
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
}

.chatbot-header-btn svg {
  width: 16px;
  height: 16px;
}

/* --- Messages Area --- */
.chatbot-messages {
  flex: 1;
  overflow-y: auto;
  padding: 18px 16px;
  background: var(--cb-bg);
  display: flex;
  flex-direction: column;
  gap: 14px;
  scroll-behavior: smooth;
}

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

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

.chatbot-messages::-webkit-scrollbar-thumb {
  background: #CBD5E1;
  border-radius: 10px;
}

/* Message Bubble */
.chatbot-msg {
  display: flex;
  gap: 8px;
  max-width: 88%;
  animation: cb-msg-in 0.3s ease;
}

@keyframes cb-msg-in {
  0% {
    opacity: 0;
    transform: translateY(10px);
  }
  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

.chatbot-msg.is-user {
  align-self: flex-end;
  flex-direction: row-reverse;
}

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

.chatbot-msg-avatar {
  width: 30px;
  height: 30px;
  border-radius: 10px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 2px;
}

.chatbot-msg.is-bot .chatbot-msg-avatar {
  background: linear-gradient(135deg, #EDE9FE, #DDD6FE);
}

.chatbot-msg.is-bot .chatbot-msg-avatar svg {
  width: 16px;
  height: 16px;
  color: #6D28D9;
}

.chatbot-msg-bubble {
  padding: 12px 16px;
  border-radius: 18px;
  font-size: 14px;
  line-height: 1.55;
  word-break: break-word;
}

.chatbot-msg.is-user .chatbot-msg-bubble {
  background: var(--cb-user-gradient);
  color: #fff;
  border-bottom-right-radius: 6px;
}

.chatbot-msg.is-bot .chatbot-msg-bubble {
  background: var(--cb-surface);
  color: var(--cb-text);
  border-bottom-left-radius: 6px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
  border: 1px solid var(--cb-border);
}

.chatbot-msg.is-bot .chatbot-msg-bubble.is-error {
  background: #FEF2F2;
  border-color: #FECACA;
  color: #991B1B;
}

.chatbot-msg-time {
  font-size: 11px;
  color: var(--cb-text-secondary);
  margin-top: 4px;
  opacity: 0.7;
}

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

/* Bold / markdown-like formatting */
.chatbot-msg-bubble strong,
.chatbot-msg-bubble b {
  font-weight: 600;
}

/* --- Typing Indicator --- */
.chatbot-typing {
  display: flex;
  gap: 8px;
  align-self: flex-start;
  max-width: 88%;
  animation: cb-msg-in 0.3s ease;
}

.chatbot-typing-avatar {
  width: 30px;
  height: 30px;
  border-radius: 10px;
  background: linear-gradient(135deg, #EDE9FE, #DDD6FE);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.chatbot-typing-avatar svg {
  width: 16px;
  height: 16px;
  color: #6D28D9;
}

.chatbot-typing-dots {
  background: var(--cb-surface);
  border: 1px solid var(--cb-border);
  border-bottom-left-radius: 6px;
  border-radius: 18px;
  padding: 14px 20px;
  display: flex;
  gap: 5px;
  align-items: center;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

.chatbot-typing-dots span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #A5B4FC;
  animation: cb-typing 1.4s ease infinite;
}

.chatbot-typing-dots span:nth-child(2) {
  animation-delay: 0.2s;
}

.chatbot-typing-dots span:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes cb-typing {
  0%, 60%, 100% {
    transform: translateY(0);
    opacity: 0.4;
  }
  30% {
    transform: translateY(-6px);
    opacity: 1;
  }
}

/* --- Input Area --- */
.chatbot-input-area {
  padding: 12px 14px;
  background: var(--cb-surface);
  border-top: 1px solid var(--cb-border);
  flex-shrink: 0;
}

.chatbot-input-wrapper {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  background: var(--cb-bg);
  border: 1.5px solid var(--cb-border);
  border-radius: 16px;
  padding: 6px 8px 6px 16px;
  transition: var(--cb-transition);
}

.chatbot-input-wrapper:focus-within {
  border-color: var(--cb-primary-light);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.chatbot-input {
  flex: 1;
  border: none;
  background: transparent;
  font-size: 14px;
  color: var(--cb-text);
  outline: none;
  resize: none;
  min-height: 22px;
  max-height: 100px;
  line-height: 1.5;
  font-family: inherit;
  padding: 4px 0;
}

.chatbot-input::placeholder {
  color: #94A3B8;
}

.chatbot-send-btn {
  width: 36px;
  height: 36px;
  border-radius: 12px;
  border: none;
  background: var(--cb-gradient);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--cb-transition);
  flex-shrink: 0;
}

.chatbot-send-btn:hover:not(:disabled) {
  background: var(--cb-gradient-hover);
  transform: scale(1.05);
}

.chatbot-send-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.chatbot-send-btn svg {
  width: 18px;
  height: 18px;
}

/* --- Powered by --- */
.chatbot-footer {
  text-align: center;
  padding: 6px;
  background: var(--cb-surface);
  font-size: 11px;
  color: var(--cb-text-secondary);
  opacity: 0.6;
}

/* --- Product Cards --- */
.chatbot-msg-content {
  min-width: 0;
}

.chatbot-products {
  margin-top: 8px;
  animation: cb-msg-in 0.3s ease;
}

.chatbot-products-scroll {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
}

.chatbot-products-scroll::-webkit-scrollbar {
  height: 3px;
}

.chatbot-products-scroll::-webkit-scrollbar-thumb {
  background: #CBD5E1;
  border-radius: 10px;
}

.chatbot-product-card {
  flex: 0 0 140px;
  border-radius: 12px;
  background: var(--cb-surface);
  border: 1px solid var(--cb-border);
  overflow: hidden;
  text-decoration: none;
  color: var(--cb-text);
  transition: var(--cb-transition);
  scroll-snap-align: start;
  display: block;
}

.chatbot-product-card:hover {
  border-color: var(--cb-primary-light);
  box-shadow: 0 4px 12px rgba(79, 70, 229, 0.15);
  transform: translateY(-2px);
}

.chatbot-product-img {
  width: 100%;
  height: 100px;
  background: #F1F5F9;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px;
}

.chatbot-product-img img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.chatbot-product-info {
  padding: 8px 10px 10px;
}

.chatbot-product-name {
  font-size: 12px;
  font-weight: 500;
  line-height: 1.35;
  color: var(--cb-text);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-bottom: 6px;
}

.chatbot-product-price {
  font-size: 13px;
  font-weight: 700;
  color: #DC2626;
}

/* Product Skeleton Loading */
.chatbot-products-loading {
  margin-top: 8px;
}

.chatbot-products-skeleton {
  display: flex;
  gap: 8px;
}

.skeleton-card {
  flex: 0 0 140px;
  border-radius: 12px;
  background: var(--cb-surface);
  border: 1px solid var(--cb-border);
  overflow: hidden;
  padding: 0;
}

.skeleton-img {
  width: 100%;
  height: 100px;
  background: linear-gradient(90deg, #F1F5F9 25%, #E2E8F0 50%, #F1F5F9 75%);
  background-size: 200% 100%;
  animation: cb-skeleton-shimmer 1.5s ease infinite;
}

.skeleton-text {
  height: 10px;
  margin: 10px 10px 0;
  border-radius: 4px;
  background: linear-gradient(90deg, #F1F5F9 25%, #E2E8F0 50%, #F1F5F9 75%);
  background-size: 200% 100%;
  animation: cb-skeleton-shimmer 1.5s ease infinite;
}

.skeleton-text.short {
  width: 60%;
  margin-bottom: 10px;
  margin-top: 6px;
}

@keyframes cb-skeleton-shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ============================================
   Responsive — Mobile
   ============================================ */
@media (max-width: 480px) {
  .chatbot-fab {
    bottom: 20px;
    right: 20px;
    width: 54px;
    height: 54px;
  }

  .chatbot-window {
    bottom: 0;
    right: 0;
    left: 0;
    width: 100%;
    height: 100dvh;
    max-height: 100dvh;
    border-radius: 0;
  }

  .chatbot-slide-enter-active {
    animation: cb-slide-up-mobile 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
  }

  .chatbot-slide-leave-active {
    animation: cb-slide-down-mobile 0.25s cubic-bezier(0.4, 0, 1, 1);
  }

  @keyframes cb-slide-up-mobile {
    0% {
      opacity: 0;
      transform: translateY(100%);
    }
    100% {
      opacity: 1;
      transform: translateY(0);
    }
  }

  @keyframes cb-slide-down-mobile {
    0% {
      opacity: 1;
      transform: translateY(0);
    }
    100% {
      opacity: 0;
      transform: translateY(100%);
    }
  }
}
