@keyframes bubble-pop {
    0% { transform: scale(1); }
    50% { transform: scale(0.9); }
    100% { transform: scale(1); }
}

.animate-pop {
    animation: bubble-pop 0.2s ease-out;
}

/* Opcional: suaviza la aparición de la burbuja de texto */
.msg-content {
    transition: all 0.2s ease;
    overflow-wrap: break-word;
    word-break: break-word;
}


/* Animación de aparición del chat */
@keyframes slide-up {
    from {
        transform: translateY(10%);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* Animación de aparición del chat desde la burbuja */
@keyframes slide-out-up-right {
    0% {
        transform: translate(1.5rem, 4rem) scale(0.7);
        opacity: 0;
    }
    70% {
        transform: translate(-0.2rem, -0.3rem) scale(1.02);
        opacity: 1;
    }
    100% {
        transform: translate(0, 0) scale(1);
        opacity: 1;
    }
}

/* Animación de ocultar el chat hacia la burbuja */
@keyframes slide-in-down-right {
    0% {
        transform: translate(0, 0) scale(1);
        opacity: 1;
    }
    100% {
        transform: translate(2rem, 5rem) scale(0.7);
        opacity: 0;
    }
}

/* Aplicar las animaciones */
.chat-slide-up {
    animation: slide-out-up-right .4s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

.chat-slide-down {
    animation: slide-in-down-right .25s ease-in forwards;
}

@media (min-width: 768px) {
    #chat-window {
        bottom: calc(6rem + 0rem); 
        right: 1.5rem;
    }
}

@keyframes dots-wave {
  0%, 100% {
    transform: scale(0.8);
    opacity: 0.5;
  }
  50% {
    transform: scale(1);
    opacity: 1;
  }
}

.animate-dots {
  animation: dots-wave 1s infinite ease-in-out;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.btn-loading {
  animation: spin 0.8s linear infinite;
}

/* Contenedor del icono para asegurar que la rotación sea central */
#chat-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

/* Estado base del icono */
#chat-toggle svg {
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.3s ease;
    backface-visibility: hidden;
}

/* Clase que aplicaremos cuando el chat esté abierto */
.is-active svg {
    transform: rotate(180deg) scale(0.8);
    opacity: 0;
}

/* Efecto de entrada suave cuando el icono cambia */
.icon-in-animation {
    animation: icon-pop 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes icon-pop {
    0% { transform: rotate(-180deg) scale(0.5); opacity: 0; }
    100% { transform: rotate(0deg) scale(1); opacity: 1; }
}

/* Animación de entrada para el indicador de carga */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(5px); }
    to { opacity: 1; transform: translateY(0); }
}

.animate-fade-in {
    animation: fadeIn 0.3s ease-out forwards;
}



/* Animación suave escalonada para el contenido inicial */
@keyframes fade-in-up {
    0% {
        opacity: 0;
        transform: translateY(15px) scale(0.95);
    }
    100% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.animate-entrance {
    animation: fade-in-up 0.5s cubic-bezier(0.22, 1, 0.36, 1) forwards;
    opacity: 0;
}

.delay-100 { animation-delay: 0.1s; }
.delay-150 { animation-delay: 0.15s; }
.delay-200 { animation-delay: 0.2s; }
.delay-300 { animation-delay: 0.3s; }
.delay-400 { animation-delay: 0.4s; }
.delay-500 { animation-delay: 0.5s; }
.delay-600 { animation-delay: 0.6s; }
.delay-700 { animation-delay: 0.7s; }
.delay-800 { animation-delay: 0.8s; }
.delay-900 { animation-delay: 0.9s; }
.delay-1000 { animation-delay: 1s; }

/* Añade transiciones suaves para la burbuja */
#chat-toggle {
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.2s ease, background-color 0.2s ease;
}

#chat-toggle:hover {
    transform: scale(1.08);
}

#chat-toggle:active {
    transform: scale(0.95);
}

/* Animación para mobile */
@media (max-width: 768px) {
    .chat-slide-up {
        animation: slide-up-in 0.35s ease-out forwards;
    }
    
    .chat-slide-down {
        animation: slide-up-out 0.25s ease-out forwards;
    }
    
    @keyframes slide-up-in {
        from {
            transform: translateY(100%);
            opacity: 0;
        }
        to {
            transform: translateY(0);
            opacity: 1;
        }
    }
    
    @keyframes slide-up-out {
        from {
            transform: translateY(0);
            opacity: 1;
        }
        to {
            transform: translateY(100%);
            opacity: 0;
        }
    }
}

/* ====== IMAGE BUBBLE ====== */
.msg-image img {
    max-width: 100%;
    border-radius: 16px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    display: block;
}

/* ====== VIDEO BUBBLE ====== */
.msg-video {
    width: 100%;
}
.msg-video iframe,
.msg-video video {
    border-radius: 16px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    background: #000;
}

/* ====== AUDIO BUBBLE ====== */
.msg-audio audio {
    border-radius: 8px;
    height: 44px;
}
.msg-audio audio::-webkit-media-controls-panel {
    background: #f3f4f6;
}

/* ====== EMBED BUBBLE ====== */
.msg-embed iframe {
    border-radius: 16px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

/* ====== PICTURE CHOICE ====== */
.picture-choice-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
}
.picture-choice-item {
    border: 2px solid #e5e7eb;
    border-radius: 12px;
    cursor: pointer;
    overflow: hidden;
    transition: border-color 0.2s, box-shadow 0.2s;
    outline: none;
    background: white;
}
.picture-choice-item:hover {
    border-color: #93c5fd;
    box-shadow: 0 2px 8px rgba(59,130,246,0.15);
}
.picture-choice-item:focus-visible {
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59,130,246,0.25);
}
.picture-choice-item.selected {
    border-color: #3b82f6;
    background: #eff6ff;
    box-shadow: 0 2px 8px rgba(59,130,246,0.2);
}

/* ====== RATING INPUT ====== */
.rating-star {
    color: #d1d5db;
    cursor: pointer;
    transition: color 0.15s, transform 0.15s;
    background: none;
    border: none;
    padding: 4px;
    line-height: 1;
}
.rating-star:hover {
    transform: scale(1.15);
}
.rating-star.text-amber-400 {
    color: #fbbf24;
}
.rating-star.text-amber-400 svg {
    fill: #fbbf24;
}

.rating-number {
    cursor: pointer;
    transition: all 0.15s;
    background: none;
    line-height: 1;
}
.rating-number:hover {
    border-color: #3b82f6;
    color: #2563eb;
}

/* ====== DATE/TIME INPUT ====== */
.date-picker-input {
    border: 1px solid #d1d5db;
    border-radius: 10px;
    padding: 10px 12px;
    font-size: 14px;
    color: #374151;
    background: white;
    outline: none;
    width: 100%;
    transition: border-color 0.2s, box-shadow 0.2s;
    box-sizing: border-box;
}
.date-picker-input:focus {
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59,130,246,0.15);
}

/* ====== CARDS INPUT ====== */
.cards-grid {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.card-item {
    border: 1px solid #e5e7eb;
    border-radius: 14px;
    overflow: hidden;
    transition: box-shadow 0.2s, border-color 0.2s;
    background: white;
    outline: none;
}
.card-item:hover {
    box-shadow: 0 2px 12px rgba(0,0,0,0.08);
    border-color: #d1d5db;
}
.card-item:focus-visible {
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59,130,246,0.2);
}

/* ====== FILE UPLOAD ====== */
.file-upload-label {
    transition: all 0.2s;
}
.file-upload-label:hover {
    border-color: #93c5fd;
    background: #eff6ff;
}

/* ====== TYPING BUBBLE ====== */
.typing-bubble {
    min-width: 60px;
    justify-content: center;
}
.typing-bubble span {
    display: inline-block;
}

/* ====== MSG WRAPPER TRANSITION ====== */
.msg-wrapper {
    transition: opacity 0.2s ease;
}

/* ====== LINE-CLAMP UTILITY ====== */
.line-clamp-2 {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* ====== SCROLLBAR ESTILIZADO ====== */
#chat-content::-webkit-scrollbar {
    width: 4px;
}
#chat-content::-webkit-scrollbar-track {
    background: transparent;
}
#chat-content::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 4px;
}
#chat-content::-webkit-scrollbar-thumb:hover {
    background: #9ca3af;
}