/* ============================================================
    ARCHIVO: chatbot.css
    Componente de Chatbot | UrgencLink
    Botón flotante con ondas animadas, indicador de estado,
    tooltip, tarjeta de chat y área de mensajes
    ============================================================ */

/* ============================================================
    SECCIÓN 1: BOTÓN FLOTANTE DEL CHATBOT
    ============================================================ */

#chatbot-btn {
    position: fixed !important;
    bottom: 30px !important;
    right: 30px !important;
    z-index: 500 !important;
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: linear-gradient(135deg, #16C2F5, #0B5ED7);
    color: #ffffff;
    border: none;
    box-shadow: 0 8px 30px rgba(11, 94, 215, 0.45);
    cursor: pointer;
    font-size: 28px;
    display: flex !important;
    align-items: center;
    justify-content: center;
    transition: all 0.35s ease;
    overflow: visible;
    padding: 0;
    margin: 0;
    outline: none;
}

/* ===== Estado: Oculto cuando el menú móvil está abierto ===== */
#chatbot-btn.hidden {
    opacity: 0 !important;
    visibility: hidden !important;
    pointer-events: none !important;
    transform: scale(0.8) !important;
    transition: opacity 0.3s ease, visibility 0.3s ease, transform 0.3s ease;
}

/* ===== Estado: Oculto cuando el footer está visible ===== */
#chatbot-btn.footer-visible {
    opacity: 0 !important;
    visibility: hidden !important;
    pointer-events: none !important;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

/* ===== Estado: Oculto cuando el hero está visible ===== */
#chatbot-btn.hero-visible {
    opacity: 0 !important;
    visibility: hidden !important;
    pointer-events: none !important;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

/* ===== Interacciones del botón ===== */
#chatbot-btn:hover {
    transform: scale(1.1) translateY(-4px);
    box-shadow: 0 12px 40px rgba(11, 94, 215, 0.6);
}

#chatbot-btn:active {
    transform: scale(0.92);
}

/* ============================================================
    SECCIÓN 1.1: ICONO DEL CHATBOT
    ============================================================ */

#chatbot-btn i {
    font-size: 30px;
    z-index: 1;
    position: relative;
    filter: drop-shadow(0 0 8px rgba(22, 194, 245, 0.3));
}

/* ============================================================
    SECCIÓN 1.2: ONDAS ANIMADAS (EFECTO "ESCUCHANDO")
    ============================================================ */

.chatbot-wave {
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    border: 2px solid rgba(22, 194, 245, 0.3);
    animation: wave-expand 2.5s ease-out infinite;
    pointer-events: none;
    top: 0;
    left: 0;
}

.chatbot-wave:nth-child(2) {
    animation-delay: 0.8s;
}

.chatbot-wave:nth-child(3) {
    animation-delay: 1.6s;
}

/* ===== Animación de expansión de ondas ===== */
@keyframes wave-expand {
    0% {
        transform: scale(1);
        opacity: 0.8;
    }
    100% {
        transform: scale(1.6);
        opacity: 0;
    }
}

/* ============================================================
    SECCIÓN 1.3: INDICADOR "EN LÍNEA"
    ============================================================ */

.chatbot-online {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 14px;
    height: 14px;
    background: #20C997;
    border-radius: 50%;
    border: 2px solid #061224;
    z-index: 2;
    animation: pulse-online 2s ease-in-out infinite;
    box-shadow: 0 0 15px rgba(32, 201, 151, 0.6);
}

/* ===== Animación de pulso del indicador ===== */
@keyframes pulse-online {
    0% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(32, 201, 151, 0.6);
    }
    50% {
        transform: scale(1.15);
        box-shadow: 0 0 0 8px rgba(32, 201, 151, 0);
    }
    100% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(32, 201, 151, 0);
    }
}

/* ============================================================
    SECCIÓN 1.4: TOOLTIP FLOTANTE
    ============================================================ */

#chatbot-btn .tooltip {
    position: absolute;
    right: calc(100% + 16px);
    top: 50%;
    transform: translateY(-50%);
    background: rgba(6, 18, 36, 0.9);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    color: #ffffff;
    padding: 8px 18px;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 500;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: all 0.35s ease;
    border: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.3);
    pointer-events: none;
}

/* ===== Triángulo del tooltip ===== */
#chatbot-btn .tooltip::after {
    content: "";
    position: absolute;
    right: -7px;
    top: 50%;
    transform: translateY(-50%);
    border-top: 7px solid transparent;
    border-bottom: 7px solid transparent;
    border-left: 7px solid rgba(6, 18, 36, 0.9);
}

#chatbot-btn:hover .tooltip {
    opacity: 1;
    visibility: visible;
    transform: translateY(-50%) translateX(-6px);
}

/* ============================================================
    SECCIÓN 2: RESPONSIVE - BOTÓN FLOTANTE
    ============================================================ */

/* ===== Tablet (768px) ===== */
@media (max-width: 768px) {
    #chatbot-btn {
        width: 56px !important;
        height: 56px !important;
        font-size: 24px !important;
        bottom: 20px !important;
        right: 20px !important;
    }

    #chatbot-btn i {
        font-size: 26px;
    }

    .chatbot-online {
        width: 12px;
        height: 12px;
        top: 1px;
        right: 1px;
    }

    #chatbot-btn .tooltip {
        display: none;
    }
}

/* ===== Móvil grande (480px) ===== */
@media (max-width: 480px) {
    #chatbot-btn {
        width: 50px !important;
        height: 50px !important;
        font-size: 20px !important;
        bottom: 16px !important;
        right: 16px !important;
    }

    #chatbot-btn i {
        font-size: 22px;
    }

    .chatbot-online {
        width: 10px;
        height: 10px;
        border-width: 1.5px;
    }
}

/* ============================================================
    SECCIÓN 3: TARJETA DEL CHAT (VENTANA DE CONVERSACIÓN)
    ============================================================ */

/* ===== Contenedor principal de la tarjeta ===== */
.chatbot-container {
    position: fixed;
    bottom: 110px;
    right: 30px;
    z-index: 9998;
    display: none;
    animation: chatSlideUp 0.35s ease both;
}

.chatbot-container.open {
    display: block;
}

/* ===== Animación de entrada de la tarjeta ===== */
@keyframes chatSlideUp {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* ===== Tarjeta del chat ===== */
.chat-card {
    width: 450px;
    max-width: 92vw;
    max-height: 580px;
    background: #ffffff;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
    border: 1px solid rgba(255, 255, 255, 0.12);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* ============================================================
    SECCIÓN 3.1: HEADER DE LA TARJETA
    ============================================================ */

.chat-header {
    background: linear-gradient(135deg, #081B3D, #0B5ED7);
    color: #ffffff;
    padding: 18px 24px;
    font-size: 18px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

.chat-header::before {
    content: "🤖";
    font-size: 24px;
}

.chat-header .chat-status {
    font-size: 13px;
    font-weight: 400;
    color: rgba(255, 255, 255, 0.7);
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 6px;
}

.chat-header .chat-status::before {
    content: "";
    display: inline-block;
    width: 8px;
    height: 8px;
    background: #20C997;
    border-radius: 50%;
    animation: pulse-online 2s ease-in-out infinite;
}

/* ============================================================
    SECCIÓN 3.2: ÁREA DE MENSAJES
    ============================================================ */

.chat-box {
    flex: 1;
    padding: 20px 18px;
    overflow-y: auto;
    background: #F7FAFD;
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-height: 320px;
    max-height: 420px;
}

/* ===== Scrollbar personalizada ===== */
.chat-box::-webkit-scrollbar {
    width: 5px;
}

.chat-box::-webkit-scrollbar-track {
    background: #E9ECEF;
    border-radius: 10px;
}

.chat-box::-webkit-scrollbar-thumb {
    background: #0B5ED7;
    border-radius: 10px;
}

/* ============================================================
    SECCIÓN 3.3: MENSAJES
    ============================================================ */

.msg {
    max-width: 85%;
    padding: 12px 18px;
    border-radius: 16px;
    font-size: 14px;
    line-height: 1.7;
    word-wrap: break-word;
    animation: msgFade 0.3s ease both;
}

/* ===== Animación de entrada de mensajes ===== */
@keyframes msgFade {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ===== Mensaje del bot ===== */
.msg.bot {
    align-self: flex-start;
    background: #ffffff;
    color: #1E293B;
    border-bottom-left-radius: 4px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
    border: 1px solid #E9ECEF;
}

/* ===== Mensaje del usuario ===== */
.msg.user {
    align-self: flex-end;
    background: linear-gradient(135deg, #16C2F5, #0B5ED7);
    color: #ffffff;
    border-bottom-right-radius: 4px;
    box-shadow: 0 2px 8px rgba(11, 94, 215, 0.15);
}

/* ============================================================
    SECCIÓN 3.4: ÁREA DE INPUT
    ============================================================ */

.input-area {
    display: flex;
    gap: 10px;
    padding: 16px 18px;
    background: #ffffff;
    border-top: 1px solid #E9ECEF;
    flex-shrink: 0;
}

.input-area input {
    flex: 1;
    min-width: 0;
    padding: 12px 16px;
    border: 2px solid #E9ECEF;
    border-radius: 12px;
    font-size: 14px;
    font-family: 'Poppins', sans-serif;
    outline: none;
    transition: border-color 0.3s ease;
    background: #F7FAFD;
    color: #1E293B;
}

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

.input-area input:focus {
    border-color: #16C2F5;
    background: #ffffff;
}

.input-area button {
    flex-shrink: 0;
    padding: 12px 28px;
    background: linear-gradient(135deg, #16C2F5, #0B5ED7);
    color: #ffffff;
    border: none;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(11, 94, 215, 0.25);
    font-family: 'Poppins', sans-serif;
    white-space: nowrap;
}

.input-area button:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(11, 94, 215, 0.35);
}

.input-area button:active {
    transform: scale(0.95);
}

.input-area button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

/* ============================================================
    SECCIÓN 4: RESPONSIVE - TARJETA DEL CHAT
    ============================================================ */

/* ===== Tablet (768px) ===== */
@media (max-width: 768px) {
    .chatbot-container {
        bottom: 90px;
        right: 16px;
    }

    .chat-card {
        width: 380px;
        max-width: 88vw;
        max-height: 480px;
    }

    .chat-header {
        font-size: 16px;
        padding: 14px 18px;
    }

    .chat-header .chat-status {
        font-size: 12px;
    }

    .chat-box {
        min-height: 260px;
        max-height: 340px;
        padding: 16px 14px;
    }

    .msg {
        font-size: 13px;
        padding: 10px 14px;
        max-width: 90%;
    }

    .input-area {
        padding: 12px 14px;
        gap: 8px;
    }

    .input-area input {
        font-size: 13px;
        padding: 10px 14px;
    }

    .input-area button {
        font-size: 13px;
        padding: 10px 20px;
    }
}

/* ===== Móvil grande (480px) ===== */
@media (max-width: 480px) {
    .chatbot-container {
        bottom: 80px;
        right: 10px;
        left: 10px;
    }

    .chat-card {
        width: 100%;
        max-width: 100%;
        max-height: 420px;
        border-radius: 16px;
    }

    .chat-header {
        font-size: 15px;
        padding: 12px 16px;
    }

    .chat-header .chat-status {
        font-size: 11px;
    }

    .chat-box {
        min-height: 200px;
        max-height: 280px;
        padding: 12px;
    }

    .msg {
        font-size: 12px;
        padding: 8px 12px;
        max-width: 95%;
    }

    .input-area {
        padding: 10px 12px;
        gap: 6px;
        flex-wrap: nowrap;
    }

    .input-area input {
        font-size: 12px;
        padding: 8px 12px;
        flex: 1;
        min-width: 60px;
    }

    .input-area button {
        font-size: 12px;
        padding: 8px 16px;
        flex-shrink: 0;
    }
}