/**
 * Edit Innovation AI Chat Widget CSS v2.0
 * Robot flotante animado con colores teal actualizados
 */

/* ============================================
   WIDGET CONTAINER
   ============================================ */
.ai-chat-widget {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 99999;
    font-family: 'Inter', 'Poppins', -apple-system, BlinkMacSystemFont, sans-serif;
}

/* ============================================
   WHATSAPP FLOAT BUTTON (encima del robot)
   ============================================ */
.ai-whatsapp-float {
    position: fixed;
    bottom: 110px;
    right: 22px;
    width: 64px;
    height: 64px;
    background: #25D366;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #ffffff;
    font-size: 32px;
    text-decoration: none;
    box-shadow: 0 8px 24px rgba(37, 211, 102, 0.45), 0 0 0 4px rgba(255, 255, 255, 0.9);
    z-index: 99998;
    cursor: pointer;
    transition: transform 0.25s cubic-bezier(0.68, -0.55, 0.265, 1.55), box-shadow 0.25s ease;
    animation: wa-float-bounce 3s ease-in-out infinite;
}

.ai-whatsapp-float:hover {
    transform: scale(1.12) translateY(-4px);
    color: #ffffff;
    text-decoration: none;
    box-shadow: 0 14px 32px rgba(37, 211, 102, 0.6), 0 0 0 4px rgba(255, 255, 255, 1);
}

.ai-whatsapp-float:active {
    transform: scale(0.95);
}

.ai-whatsapp-float i {
    position: relative;
    z-index: 2;
    line-height: 1;
}

/* Etiqueta "WhatsApp" que aparece al hacer hover */
.ai-whatsapp-float-label {
    position: absolute;
    right: calc(100% + 14px);
    top: 50%;
    transform: translateY(-50%) translateX(10px);
    background: #1a1a1a;
    color: #fff;
    padding: 8px 14px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 700;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: all 0.25s ease;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

.ai-whatsapp-float-label::after {
    content: '';
    position: absolute;
    left: 100%;
    top: 50%;
    transform: translateY(-50%);
    border: 6px solid transparent;
    border-left-color: #1a1a1a;
}

.ai-whatsapp-float:hover .ai-whatsapp-float-label {
    opacity: 1;
    transform: translateY(-50%) translateX(0);
}

/* Anillo de pulso verde para llamar la atención */
.ai-whatsapp-float-pulse {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: #25D366;
    opacity: 0.5;
    z-index: 1;
    animation: wa-pulse 2.5s ease-out infinite;
}

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

/* Rebote sutil del botón */
@keyframes wa-float-bounce {
    0%, 100% { transform: translateY(0); }
    50%      { transform: translateY(-6px); }
}

/* Responsive: en móviles, botón un poco más pequeño */
@media (max-width: 576px) {
    .ai-whatsapp-float {
        width: 56px;
        height: 56px;
        font-size: 28px;
        bottom: 100px;
        right: 16px;
    }
    .ai-whatsapp-float-label {
        display: none;
    }
}

/* Si el usuario prefiere menos movimiento */
@media (prefers-reduced-motion: reduce) {
    .ai-whatsapp-float,
    .ai-whatsapp-float-pulse {
        animation: none;
    }
}

/* ============================================
   ROBOT BUTTON FLOTANTE (ORIGINAL)
   ============================================ */
.ai-chat-button {
    position: relative;
    width: 70px;
    height: 70px;
    background: linear-gradient(135deg, #0D9488 0%, #14B8A6 100%);
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 8px 24px rgba(13, 148, 136, 0.4);
    transition: all 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    animation: float 6s ease-in-out infinite;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ai-chat-button:hover {
    transform: scale(1.1) translateY(-5px);
    box-shadow: 0 12px 32px rgba(13, 148, 136, 0.6);
}

.ai-chat-button.active {
    transform: scale(0.95);
}

/* Animacion flotante */
@keyframes float {
    0% {
        transform: translate(0, 0) rotate(0deg);
    }
    25% {
        transform: translate(-15px, -10px) rotate(-2deg);
    }
    50% {
        transform: translate(0, -20px) rotate(0deg);
    }
    75% {
        transform: translate(15px, -10px) rotate(2deg);
    }
    100% {
        transform: translate(0, 0) rotate(0deg);
    }
}

/* Animacion de pulso */
.pulse-ring {
    position: absolute;
    width: 100%;
    height: 100%;
    border: 3px solid #0D9488;
    border-radius: 50%;
    animation: pulse 2s cubic-bezier(0.215, 0.61, 0.355, 1) infinite;
    opacity: 0;
}

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

/* Badge de notificacion */
.notification-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #EF4444;
    color: white;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
    border: 2px solid white;
    animation: bounce 2s ease-in-out infinite;
}

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

/* ============================================
   ROBOT DESIGN (ORIGINAL)
   ============================================ */
.robot-container {
    position: relative;
    z-index: 2;
}

.robot-head {
    width: 35px;
    height: 30px;
    background: white;
    border-radius: 8px;
    position: relative;
    animation: robot-blink 4s ease-in-out infinite;
}

.robot-antenna {
    position: absolute;
    top: -10px;
    left: 50%;
    transform: translateX(-50%);
    width: 2px;
    height: 8px;
    background: white;
}

.robot-antenna::after {
    content: '';
    position: absolute;
    top: -4px;
    left: 50%;
    transform: translateX(-50%);
    width: 6px;
    height: 6px;
    background: #FCD34D;
    border-radius: 50%;
    animation: antenna-light 1.5s ease-in-out infinite;
}

@keyframes antenna-light {
    0%, 100% {
        opacity: 1;
        box-shadow: 0 0 5px #FCD34D;
    }
    50% {
        opacity: 0.3;
    }
}

.robot-eyes {
    display: flex;
    justify-content: space-around;
    padding: 8px 6px 0;
}

.robot-eye {
    width: 8px;
    height: 8px;
    background: #0D9488;
    border-radius: 50%;
    animation: eye-glow 2s ease-in-out infinite;
}

@keyframes eye-glow {
    0%, 100% {
        box-shadow: 0 0 5px #0D9488;
    }
    50% {
        box-shadow: 0 0 10px #0D9488, 0 0 15px #14B8A6;
    }
}

@keyframes robot-blink {
    0%, 48%, 52%, 100% {
        transform: scaleY(1);
    }
    50% {
        transform: scaleY(0.1);
    }
}

.robot-mouth {
    width: 16px;
    height: 8px;
    border: 2px solid #0D9488;
    border-top: none;
    border-radius: 0 0 8px 8px;
    margin: 2px auto 0;
}

.robot-body {
    width: 20px;
    height: 8px;
    background: white;
    border-radius: 0 0 4px 4px;
    margin: 2px auto 0;
}

/* Robot pequeno en header */
.robot-head-small {
    width: 30px;
    height: 25px;
    background: white;
    border-radius: 6px;
    position: relative;
    display: flex;
    justify-content: space-around;
    align-items: center;
    padding: 5px;
}

.robot-head-small .robot-eye {
    width: 6px;
    height: 6px;
}

/* Robot tiny en mensajes */
.robot-head-tiny {
    width: 24px;
    height: 20px;
    background: #E6F7F5;
    border-radius: 5px;
    position: relative;
    display: flex;
    justify-content: space-around;
    align-items: center;
    padding: 4px;
    border: 2px solid #0D9488;
}

.robot-head-tiny .robot-eye {
    width: 4px;
    height: 4px;
}

/* ============================================
   CHAT WINDOW (MEJORADA)
   ============================================ */
.ai-chat-window {
    position: absolute;
    bottom: 85px;
    right: 0;
    width: 380px;
    max-width: calc(100vw - 40px);
    height: 550px;
    max-height: calc(100vh - 120px);
    background: white;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
    display: flex;
    flex-direction: column;
    opacity: 0;
    transform: scale(0.8) translateY(20px);
    pointer-events: none;
    transition: all 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    overflow: hidden;
}

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

/* ============================================
   CHAT HEADER (TEAL)
   ============================================ */
.ai-chat-header {
    background: linear-gradient(135deg, #0D9488 0%, #14B8A6 100%);
    padding: 16px 20px;
    color: white;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.ai-header-content {
    display: flex;
    align-items: center;
    gap: 12px;
}

.ai-avatar {
    width: 45px;
    height: 45px;
    background: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.ai-header-text h4 {
    margin: 0;
    font-size: 15px;
    font-weight: 600;
}

.ai-status {
    margin: 2px 0 0;
    font-size: 12px;
    opacity: 0.9;
    display: flex;
    align-items: center;
    gap: 6px;
}

.status-dot {
    width: 8px;
    height: 8px;
    background: #10B981;
    border-radius: 50%;
    display: inline-block;
    animation: pulse-dot 2s ease-in-out infinite;
}

@keyframes pulse-dot {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

.ai-header-actions {
    display: flex;
    gap: 8px;
}

.ai-action-btn {
    width: 32px;
    height: 32px;
    background: rgba(255, 255, 255, 0.2);
    border: none;
    border-radius: 50%;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.ai-action-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.1);
}

/* ============================================
   CHAT MESSAGES
   ============================================ */
.ai-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: linear-gradient(180deg, #F9FAFB 0%, #F3F4F6 100%);
    display: flex;
    flex-direction: column;
    gap: 12px;
}

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

.ai-chat-messages::-webkit-scrollbar-track {
    background: #F3F4F6;
}

.ai-chat-messages::-webkit-scrollbar-thumb {
    background: #D1D5DB;
    border-radius: 3px;
}

.ai-chat-messages::-webkit-scrollbar-thumb:hover {
    background: #9CA3AF;
}

.ai-message {
    display: flex;
    flex-direction: column;
    max-width: 75%;
    animation: messageSlideIn 0.3s ease-out;
}

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

.user-message {
    align-self: flex-end;
    align-items: flex-end;
}

.bot-message {
    align-self: flex-start;
    align-items: flex-start;
    flex-direction: row;
    gap: 8px;
    max-width: 85%;
}

.message-content {
    padding: 12px 16px;
    border-radius: 16px;
    font-size: 14px;
    line-height: 1.5;
    word-wrap: break-word;
}

.user-message .message-content {
    background: linear-gradient(135deg, #0D9488 0%, #14B8A6 100%);
    color: white;
    border-bottom-right-radius: 4px;
}

.bot-message .message-content,
.bot-message .message-bubble .message-content {
    background: white;
    color: #1F2937;
    border: 1px solid #E5E7EB;
    border-bottom-left-radius: 4px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}

.message-bubble {
    flex: 1;
}

.message-content a,
.message-content .chat-link {
    color: #0D9488;
    text-decoration: none;
    font-weight: 500;
    display: inline-block;
    margin-top: 5px;
}

.message-content a:hover,
.message-content .chat-link:hover {
    text-decoration: underline;
}

.user-message .message-content a {
    color: white;
}

.message-time {
    font-size: 11px;
    color: #9CA3AF;
    margin-top: 4px;
    padding: 0 4px;
}

.bot-avatar {
    flex-shrink: 0;
    margin-top: 4px;
}

/* Typing indicator */
.typing-indicator {
    max-width: 80px;
}

.typing-dots {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 12px 16px;
    background: white;
    border-radius: 16px;
    border: 1px solid #E5E7EB;
}

.typing-dots span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #0D9488;
    animation: typing 1.4s ease-in-out infinite;
}

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

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

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

/* ============================================
   QUICK ACTIONS (MEJORADAS)
   ============================================ */
.ai-quick-actions {
    padding: 12px 15px;
    background: white;
    border-top: 1px solid #E5E7EB;
    display: flex;
    gap: 8px;
    overflow-x: auto;
}

.ai-quick-actions::-webkit-scrollbar {
    height: 4px;
}

.ai-quick-actions::-webkit-scrollbar-thumb {
    background: #D1D5DB;
    border-radius: 2px;
}

.quick-action-btn {
    padding: 8px 12px;
    background: #F0FDFA;
    border: 1px solid #99F6E4;
    border-radius: 20px;
    font-size: 12px;
    color: #0D9488;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 5px;
    font-weight: 500;
}

.quick-action-btn:hover {
    background: #0D9488;
    color: white;
    border-color: #0D9488;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(13, 148, 136, 0.3);
}

.quick-action-btn i {
    font-size: 12px;
}

/* ============================================
   CHAT INPUT (MEJORADO)
   ============================================ */
.ai-chat-input {
    padding: 12px 15px;
    background: white;
    border-top: 1px solid #E5E7EB;
    display: flex;
    gap: 10px;
    align-items: center;
}

#ai-message-input {
    flex: 1;
    padding: 12px 16px;
    border: 2px solid #E5E7EB;
    border-radius: 24px;
    font-size: 14px;
    outline: none;
    transition: all 0.2s;
    font-family: inherit;
}

#ai-message-input:focus {
    border-color: #0D9488;
    box-shadow: 0 0 0 3px rgba(13, 148, 136, 0.1);
}

.ai-send-btn {
    width: 44px;
    height: 44px;
    background: linear-gradient(135deg, #0D9488 0%, #14B8A6 100%);
    border: none;
    border-radius: 50%;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    box-shadow: 0 4px 12px rgba(13, 148, 136, 0.3);
}

.ai-send-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 16px rgba(13, 148, 136, 0.4);
}

.ai-send-btn:active {
    transform: scale(0.95);
}

/* ============================================
   WHATSAPP FOOTER
   ============================================ */
.ai-whatsapp-footer {
    padding: 12px 15px;
    background: #F9FAFB;
    border-top: 1px solid #E5E7EB;
}

.ai-whatsapp-btn {
    width: 100%;
    padding: 12px 20px;
    background: #25D366;
    border: none;
    border-radius: 12px;
    color: white;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.2s;
    box-shadow: 0 4px 12px rgba(37, 211, 102, 0.3);
}

.ai-whatsapp-btn:hover {
    background: #22C55E;
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(37, 211, 102, 0.4);
}

.ai-whatsapp-btn i {
    font-size: 18px;
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 480px) {
    .ai-chat-widget {
        bottom: 15px;
        right: 15px;
    }

    .ai-chat-button {
        width: 60px;
        height: 60px;
    }

    .ai-chat-window {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        width: 100vw;
        height: 100vh;
        max-width: 100vw;
        max-height: 100vh;
        border-radius: 0;
        z-index: 100000;
    }

    .ai-message {
        max-width: 85%;
    }

    .bot-message {
        max-width: 90%;
    }

    .quick-action-btn {
        padding: 6px 10px;
        font-size: 11px;
    }
}

/* ============================================
   ANIMATIONS EXTRAS
   ============================================ */
@keyframes shake {
    0%, 100% { transform: translateX(0); }
    10%, 30%, 50%, 70%, 90% { transform: translateX(-5px); }
    20%, 40%, 60%, 80% { transform: translateX(5px); }
}

.ai-chat-button.shake {
    animation: shake 0.5s ease-in-out;
}

/* Efecto de ondas al abrir */
.ai-chat-window.open::before {
    content: '';
    position: absolute;
    bottom: -85px;
    right: 15px;
    width: 70px;
    height: 70px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(13, 148, 136, 0.2) 0%, transparent 70%);
    animation: ripple 0.6s ease-out;
}

@keyframes ripple {
    0% {
        transform: scale(0);
        opacity: 1;
    }
    100% {
        transform: scale(2);
        opacity: 0;
    }
}
