/*
=======================================================================================
SUNHO K-BEAUTY
=======================================================================================
*/

/* Spacing variables fallback */
:root {
  --sp-2: 0.5rem;
  --sp-3: 0.75rem;
  --sp-4: 1rem;
  --sp-5: 1.25rem;
  --sp-6: 1.5rem;
}

.sunho-ai-assistant {

  position: fixed;
  bottom: var(--sp-6);
  right: var(--sp-6);
  z-index: 1000;
  font-family: var(--font-ui);
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}

/* --- Floating Button --- */
.ai-trigger {
  width: 64px;
  height: 64px;
  border-radius: var(--radius-full);
  background: var(--primary);
  color: var(--white);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-xl);
  cursor: pointer;
  transition: all var(--transition-base);
  border: none;
  position: relative;
  /* overflow: hidden; Removed to allow badge to overlay */
}


.ai-trigger:hover {
  transform: scale(1.05) translateY(-4px);
  background: var(--primary-dark);
  box-shadow: 0 12px 28px rgba(155, 111, 223, 0.4);
}

.ai-trigger svg {
  width: 28px;
  height: 28px;
  transition: transform var(--transition-base);
}

.ai-trigger.active svg {
  /* transform removed */
}

.ai-badge {
    position: absolute;
    top: -2px;
    right: -2px;
    z-index: 10;

    width: 16px;
    height: 16px;
    background: #FF4757; /* Rojo vibrante de notificación */
    border-radius: 50%;
    border: 3px solid var(--white);
    box-shadow: 0 2px 8px rgba(255, 71, 87, 0.4);
    animation: pulseBadge 2s infinite;
}

@keyframes pulseBadge {
    0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(255, 71, 87, 0.7); }
    70% { transform: scale(1.2); box-shadow: 0 0 0 10px rgba(255, 71, 87, 0); }
    100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(255, 71, 87, 0); }
}

/* --- Chat Window --- */
.ai-chat-window {
  position: absolute;
  bottom: 80px;
  right: 0;
  width: 380px;
  max-width: 90vw;
  height: 520px;
  max-height: 70vh;
  background: var(--white);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  transform: translateY(20px) scale(0.95);
  pointer-events: none;
  transition: all var(--transition-base);
  border: 1px solid var(--gray-100);
}

.ai-chat-window.active {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: all;
}

/* Header */
.ai-chat-header {
  padding: var(--sp-5) var(--sp-6);
  background: var(--primary);
  color: var(--white);
  display: flex;
  align-items: center;
  gap: var(--sp-3);
}

.ai-avatar-header {
  width: 40px;
  height: 40px;
  background: var(--white);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.ai-avatar-header img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  padding: 2px;
}

.ai-header-info h2 {
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 700;
  margin: 0;
}

.ai-status {
  font-size: 0.75rem;
  opacity: 0.9;
  display: flex;
  align-items: center;
  gap: 4px;
}

.ai-status-dot {
  width: 8px;
  height: 8px;
  background: #4ADE80;
  border-radius: 50%;
}

.ai-close-btn {
    margin-left: auto;
    color: var(--white);
    font-size: 1.2rem;
    cursor: pointer;
    opacity: 0.8;
    transition: opacity var(--transition-fast);
}

.ai-close-btn:hover {
    opacity: 1;
}

/* Body */
.ai-chat-body {
  flex: 1;
  padding: var(--sp-6);
  overflow-y: auto;
  background: var(--gray-50);
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
  scrollbar-width: thin;
  scrollbar-color: var(--gray-200) transparent;
}

.ai-chat-body::-webkit-scrollbar {
  width: 6px;
}

.ai-chat-body::-webkit-scrollbar-thumb {
  background: var(--gray-200);
  border-radius: 3px;
}

/* Messages */
.message {
  max-width: 85%;
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--radius-lg);
  font-size: 0.9rem;
  line-height: 1.5;
  animation: messageIn 0.3s var(--ease-out);
}

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

.message-ai {
  align-self: flex-start;
  background: var(--white);
  color: var(--gray-800);
  border-bottom-left-radius: 2px;
  box-shadow: var(--shadow-sm);
}

.message-user {
  align-self: flex-end;
  background: var(--primary);
  color: var(--white);
  border-bottom-right-radius: 2px;
  box-shadow: 0 4px 12px rgba(155, 111, 223, 0.2);
}

/* Typing Indicator */
.typing {
  display: flex;
  gap: 4px;
  padding: var(--sp-2) var(--sp-3);
  background: var(--white);
  border-radius: var(--radius-lg);
  width: fit-content;
}

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

.typing span:nth-child(1) { animation-delay: -0.32s; }
.typing span:nth-child(2) { animation-delay: -0.16s; }

@keyframes typing {
  0%, 80%, 100% { transform: scale(0); }
  40% { transform: scale(1); }
}

/* Footer */
.ai-chat-footer {
  padding: var(--sp-4) var(--sp-6);
  background: var(--white);
  border-top: 1px solid var(--gray-100);
}

.ai-input-wrapper {
  display: flex;
  background: var(--gray-50);
  border-radius: var(--radius-full);
  padding: 4px 4px 4px 16px;
  border: 1.5px solid var(--gray-100);
  transition: all var(--transition-fast);
}

.ai-input-wrapper:focus-within {
  border-color: var(--primary-light);
  background: var(--white);
  box-shadow: 0 0 0 4px var(--primary-bg);
}

.ai-chat-input {
  flex: 1;
  border: none;
  background: transparent;
  padding: 8px 0;
  font-size: 0.9rem;
  outline: none;
  color: var(--gray-800);
}

.ai-send-btn {
  width: 36px;
  height: 36px;
  background: var(--primary);
  color: var(--white);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
  border: none;
}

.ai-send-btn:hover {
  background: var(--primary-dark);
  transform: scale(1.05);
}

.ai-send-btn svg {
  width: 16px;
  height: 16px;
}

/* Quick Actions */
.quick-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;
}

.quick-btn {
    padding: 6px 12px;
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-full);
    font-size: 0.75rem;
    color: var(--gray-600);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.quick-btn:hover {
    border-color: var(--primary-light);
    color: var(--primary);
    background: var(--primary-bg);
}

/* Responsive */
@media (max-width: 480px) {
    .sunho-ai-assistant {
        bottom: var(--sp-4);
        right: var(--sp-4);
    }

    .ai-trigger {
        width: 48px;
        height: 48px;
    }

    .ai-trigger svg {
        width: 20px;
        height: 20px;
    }

    .ai-chat-window {
        width: calc(100vw - 40px);
        right: -10px;
        height: 60vh;
        bottom: 60px;
    }
}

/* AI Product Card Recommendations */
.ai-product-card {
    display: flex;
    gap: 12px;
    background: var(--white);
    border: 1px solid var(--primary-light);
    border-radius: var(--radius-md);
    padding: 10px;
    margin-top: 10px;
    align-items: center;
    box-shadow: 0 4px 12px rgba(155, 111, 223, 0.1);
    transition: transform var(--transition-fast);
    text-decoration: none;
    color: inherit;
}

.ai-product-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(155, 111, 223, 0.15);
}

.ai-product-img {
    width: 50px;
    height: 50px;
    background: var(--primary-bg);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary);
}

.ai-product-info {
    flex: 1;
}

.ai-product-title {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--gray-800);
    margin: 0 0 2px 0;
}

.ai-product-desc {
    font-size: 0.75rem;
    color: var(--gray-500);
    margin: 0;
    line-height: 1.3;
}

.ai-product-action {
    background: var(--primary);
    color: var(--white);
    border: none;
    border-radius: var(--radius-full);
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}
