/* ==========================================================================
   CHATBOT EN MODO ESPERA - CONFIGURACIÓN ESCALA MINI DISCRETA
   ========================================================================== */

/* --- CONTENEDOR FLOTANTE MAESTRO (Mini Escala) --- */
#chatbot-launcher {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 75px;   /* Reducido para ser muy discreto */
    height: 90px;  /* Altura perfecta para el mini robot */
    cursor: pointer;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
    perspective: 500px;
}

/* --- GLOBO DE TEXTO EN MODO ESPERA (Ajustado al mini bot) --- */
.robot-speech-bubble {
    position: absolute;
    bottom: 85px;  /* Bajó de 115px para encajar con la mini cabeza */
    right: -15px;
    width: 145px;  /* Más compacto */
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.96), rgba(240, 248, 255, 0.96));
    border: 2px solid #00b4f1;
    border-radius: 12px;
    padding: 6px 8px;
    font-family: 'Segoe UI', -apple-system, sans-serif;
    font-size: 16px; /* Letra un punto más chica */
    font-weight: 700;
    color: #1a202c;
    text-align: center;
    box-shadow: 0 4px 12px rgba(0,0,0,0.12), 0 0 8px rgba(0,180,241,0.25);
    pointer-events: none;
    backdrop-filter: blur(5px);
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    animation: bubbleFloat 3s ease-in-out infinite, bubbleNeonPulse 2.5s ease-in-out infinite alternate;
}
.robot-speech-bubble::after {
    content: '';
    position: absolute;
    bottom: -6px;
    right: 40px;
    width: 0;
    height: 0;
    border-width: 6px 6px 0;
    border-style: solid;
    border-color: rgba(255,255,255,0.96) transparent transparent;
}
.robot-speech-bubble::before {
    content: '';
    position: absolute;
    bottom: -9px;
    right: 39px;
    width: 0;
    height: 0;
    border-width: 7px 7px 0;
    border-style: solid;
    border-color: #00b4f1 transparent transparent;
    z-index: -1;
}

/* --- INTERACTIVIDAD 3D (HOVER) --- */
#chatbot-launcher:hover .robot-head-replica {
    transform: translateY(-6px) rotateY(12deg) rotateX(6deg) scale(1.02);
    box-shadow: inset 0 3px 6px rgba(255,255,255,0.6), 0 10px 20px rgba(0,0,0,0.25);
}
#chatbot-launcher:hover .robot-body-replica {
    transform: translateY(-1px) scale(1.04);
}
#chatbot-launcher:hover .robot-shadow-floor {
    transform: scale(0.7);
    opacity: 0.18;
}
#chatbot-launcher:hover .robot-speech-bubble {
    transform: translateY(-8px) scale(1.02);
}

/* Sombra inferior */
.robot-shadow-floor {
    width: 42px; /* Reducida */
    height: 5px;  /* Reducida */
    background: rgba(0, 0, 0, 0.4);
    border-radius: 50%;
    position: absolute;
    bottom: 0;
    filter: blur(2px);
    z-index: 1;
    animation: shadowPulse 3s ease-in-out infinite;
    transition: all 0.4s ease;
}

/* --- CUERPO MINI --- */
.robot-body-replica {
    width: 44px;   /* Reducido de 58px */
    height: 22px;  /* Reducido de 30px */
    background: linear-gradient(135deg, #009ad4, #004f70);
    border-radius: 12px 12px 8px 8px;
    position: relative;
    z-index: 2;
    box-shadow: inset 0 1px 3px rgba(255,255,255,0.4), 0 3px 6px rgba(0,0,0,0.2);
    display: flex;
    justify-content: center;
    margin-bottom: 4px;
    transition: all 0.4s ease;
}
.robot-chest-plate {
    width: 16px;
    height: 11px;
    background: linear-gradient(180deg, #b8c1c6, #737c80);
    border-radius: 3px;
    margin-top: 4px;
    box-shadow: inset 0 1px 2px rgba(0,0,0,0.4);
    position: relative;
}
.robot-chest-plate::after {
    content: '';
    position: absolute;
    width: 10px;
    height: 1px;
    background: #3a4454;
    top: 3px;
    left: 3px;
    box-shadow: 0 2px 0 #3a4454, 0 4px 0 #3a4454;
}

.robot-neck-joint {
    width: 14px;
    height: 8px;
    background: repeating-linear-gradient(180deg, #1a202c, #1a202c 2px, #2d3748 2px, #2d3748 4px);
    position: absolute;
    bottom: 24px;
    z-index: 2;
    border-radius: 1px;
}

/* --- CABEZA MINI --- */
.robot-head-replica {
    width: 65px;   /* Reducido de 86px */
    height: 54px;  /* Reducido de 72px */
    background: linear-gradient(135deg, #00a8e8, #00557a);
    border-radius: 28px;
    position: absolute;
    bottom: 28px;  /* Ajustado para encajar con el nuevo cuello */
    z-index: 3;
    box-shadow: inset 0 3px 5px rgba(255,255,255,0.5), 0 5px 12px rgba(0,0,0,0.22);
    animation: floatRobot 3s ease-in-out infinite;
    transition: all 0.4s cubic-bezier(0.25, 0.8, 0.25, 1);
}

.robot-jaw-plate {
    position: absolute;
    bottom: 2px;
    left: 7px;
    width: 51px;
    height: 10px;
    background: linear-gradient(180deg, #ffffff, #e2e8f0);
    border-radius: 0 0 14px 14px;
    z-index: 4;
}

.robot-screen-border {
    position: absolute;
    top: 4px;
    left: 5px;
    width: 55px;
    height: 39px;
    background: linear-gradient(135deg, #f7fafc, #cbd5e0, #718096);
    border-radius: 18px;
    padding: 2px;
    box-sizing: border-box;
}

.robot-screen-dark {
    width: 100%;
    height: 100%;
    background: radial-gradient(circle at center, #1a202c 0%, #080b11 100%);
    border-radius: 15px;
    position: relative;
    overflow: hidden;
}

.robot-screen-dark::before {
    content: '';
    position: absolute;
    width: 100%;
    height: 2px;
    background: linear-gradient(90deg, transparent, #46f0f0, transparent);
    opacity: 0.6;
    top: 0;
    left: 0;
    animation: laserScan 2.5s linear infinite;
    z-index: 5;
}

/* Ojos Mini */
.robot-eye-cyan {
    position: absolute;
    top: 9px;
    width: 11px;
    height: 15px;
    background: linear-gradient(180deg, #71f7f7, #00c4c4);
    border-radius: 4px;
    box-shadow: 0 0 8px #46f0f0, inset 0 1px 1px #fff;
    animation: blinkRobot 4s infinite;
}
.eye-left-replica { left: 9px; }
.eye-right-replica { right: 9px; }

.robot-eye-cyan::after {
    content: '';
    position: absolute;
    top: 1px;
    left: 2px;
    width: 3px;
    height: 3px;
    background: #ffffff;
    border-radius: 50%;
    opacity: 0.9;
}

/* --- ANIMACIONES GENERALES --- */
@keyframes floatRobot {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-4px); }
}
@keyframes bubbleFloat {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-4px); }
}
@keyframes shadowPulse {
    0%, 100% { transform: scale(1); opacity: 0.45; }
    50% { transform: scale(0.85); opacity: 0.22; }
}
@keyframes blinkRobot {
    0%, 90%, 100% { transform: scaleY(1); }
    3% { transform: scaleY(0.05); }
}
@keyframes laserScan {
    0% { top: -5%; }
    50% { top: 105%; }
    100% { top: -5%; }
}
@keyframes bubbleNeonPulse {
    0% { border-color: #00b4f1; box-shadow: 0 4px 12px rgba(0,0,0,0.12), 0 0 5px rgba(0,180,241,0.2); }
    100% { border-color: #bc3ca2; box-shadow: 0 4px 12px rgba(0,0,0,0.12), 0 0 10px rgba(188,60,162,0.35); }
}

/* ==========================================================================
   ESTRUCTURA DE INTERFAZ DEL CHAT (VENTANA DE DIÁLOGO)
   ========================================================================== */
#chatbot-container {
    position: fixed;
    bottom: 120px; /* Bajó de 155px porque el mini bot ahora es más bajito */
    right: 20px;
    width: 330px; 
    height: 440px; 
    background-color: #ffffff;
    border: 1px solid rgba(0, 0, 0, 0.06);
    border-radius: 20px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.18);
    display: none;
    flex-direction: column;
    font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, Roboto, sans-serif;
    z-index: 2000;
    overflow: hidden;
    transition: transform 0.3s ease, opacity 0.3s ease;
    animation: slideUpChat 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes slideUpChat {
    from { transform: translateY(25px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

/* Cabecera del Chat */
#chat-header {
    background: linear-gradient(135deg, #005f87, #8a2c74);
    color: #ffffff;
    padding: 14px 18px;
    font-weight: 600;
    font-size: 14.5px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 10px rgba(0,0,0,0.08);
}
#chat-header .close-chat {
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.85);
    font-size: 24px;
    cursor: pointer;
    line-height: 1;
    transition: color 0.2s ease;
}
#chat-header .close-chat:hover {
    color: #ffffff;
}

/* Caja de Mensajes */
#chat-box {
    flex: 1;
    padding: 18px;
    overflow-y: auto;
    background-color: #f8fafc;
    display: flex;
    flex-direction: column;
    gap: 12px;
    scroll-behavior: smooth;
}

/* Burbujas del Chat */
.chat-message {
    padding: 11px 15px;
    border-radius: 16px;
    max-width: 82%;
    font-size: 13.5px;
    line-height: 1.5;
    word-wrap: break-word;
}
.bot-msg { 
    background-color: #ffffff; 
    color: #1a202c; 
    align-self: flex-start; 
    border-top-left-radius: 3px;
    font-weight: 500;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.04), 0 1px 2px rgba(0, 0, 0, 0.02);
    border: 1px solid #edf2f7;
}

/* Área de Texto Inferior */
#chat-input-area {
    display: flex;
    border-top: 1px solid #edf2f7;
    padding: 12px 15px;
    background: #ffffff;
    align-items: center;
}
#user-input {
    flex: 1;
    border: 1px solid #e2e8f0;
    border-radius: 20px;
    padding: 9px 16px;
    outline: none;
    font-size: 13px;
    background-color: #f1f5f9;
    color: #94a3b8;
    cursor: not-allowed;
    transition: all 0.3s ease;
}
#send-btn {
    background: #cbd5e0;
    color: #ffffff;
    border: none;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    margin-left: 10px;
    cursor: not-allowed;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    transition: all 0.3s ease;
}

/* ==========================================================================
   MÓDULO RESPONSIVO - OPTIMIZACIÓN EXCLUSIVA PARA CELULARES
   ========================================================================== */
@media screen and (max-width: 480px) {
    #chatbot-launcher {
        bottom: 12px;
        right: 12px;
        transform: scale(0.9); /* Le da un toque extra mini automático en celulares */
    }
    
    .robot-speech-bubble {
        right: -8px;
        bottom: 78px;
        width: 135px;
        font-size: 16px;
    }

    #chatbot-container {
        bottom: 75px;       /* Ajustado milimétricamente arriba del mini bot */
        right: 12px;        
        left: 12px;         
        width: calc(100% - 24px); 
        height: 310px;      /* Altura compacta ideal de tarjeta */
        border-radius: 18px; 
        border: 1px solid rgba(0, 0, 0, 0.05);
        box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    }
    
    #chat-header {
        padding: 11px 15px;
        font-size: 13.5px;
    }
    #chat-header .close-chat {
        font-size: 22px;
    }
    
    #chat-box {
        padding: 12px;
        gap: 8px;
    }
    .chat-message {
        font-size: 12.5px;
        max-width: 90%;
    }
    
    #chat-input-area {
        padding: 8px 12px;
    }
    #user-input {
        padding: 7px 12px;
        font-size: 12.5px;
    }
    #send-btn {
        width: 32px;
        height: 32px;
        font-size: 12px;
        margin-left: 6px;
    }
}