/* ====================================================== */
/* WIDGET DEL ASISTENTE VIRTUAL TITO - CIARDI HNOS      */
/* ====================================================== */

/* Contenedor principal del widget */
.asistente-widget-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 1050;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

/* Botón flotante del asistente */
.asistente-btn-toggle {
    width: 65px;
    height: 65px;
    border: none;
    border-radius: 50%;
    background: linear-gradient(135deg, #007bff, #0056b3);
    box-shadow: 0 4px 20px rgba(0,123,255,0.4);
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    outline: none;
}

.asistente-btn-toggle:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 25px rgba(0,123,255,0.6);
}

.asistente-btn-toggle:active {
    transform: scale(0.95);
}

/* Avatar de Tito */
.asistente-avatar {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid white;
    transition: transform 0.3s ease;
}

.asistente-btn-toggle:hover .asistente-avatar {
    transform: scale(1.1);
}

/* Avatar de Tito en el header del panel */
.avatar-tito-header {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid white;
}

/* Indicador de notificación */
.asistente-notificacion {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #dc3545;
    color: white;
    border-radius: 50%;
    width: 22px;
    height: 22px;
    font-size: 11px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    border: 2px solid white;
    animation: pulse 2s infinite;
}

/* Pulso para la notificación */
@keyframes pulse {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.1);
    }
    100% {
        transform: scale(1);
    }
}

/* Panel del chat (reemplaza al modal) */
.asistente-panel {
    position: absolute;
    bottom: 80px;
    right: 0;
    width: 420px;
    height: 600px; /* Altura fija */
    max-height: 80vh; /* Máximo 80% de la altura de la ventana */
    background: white;
    border-radius: 15px;
    overflow: hidden;
    box-shadow: 0 20px 40px rgba(0,0,0,0.2);
    transform: translateY(20px) scale(0.95);
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    pointer-events: none;
    display: flex;
    flex-direction: column;
}

.asistente-panel.show {
    transform: translateY(0) scale(1);
    opacity: 1;
    pointer-events: auto;
}

.asistente-panel-content {
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
}

/* Header del panel */
.asistente-panel-header {
    background: linear-gradient(135deg, #007bff, #0056b3);
    color: white;
    padding: 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0; /* No se encoge */
}

.asistente-panel-header h5 {
    font-size: 1.1rem;
    font-weight: 600;
}

.btn-cerrar-asistente {
    background: none;
    border: none;
    color: white;
    font-size: 1.2rem;
    cursor: pointer;
    padding: 0.25rem;
    border-radius: 4px;
    transition: background-color 0.2s ease;
    margin-left: auto;
}

.btn-cerrar-asistente:hover {
    background-color: rgba(255,255,255,0.1);
}

/* Body del panel - CLAVE PARA EL SCROLL */
.asistente-panel-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-height: 0; /* Importante para que funcione el flex */
}

/* Contenedor del chat - AQUÍ ESTÁ EL SCROLL */
.asistente-chat-container {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 1rem;
    background: linear-gradient(180deg, #f8f9fa 0%, #e9ecef 100%);
    scroll-behavior: smooth;
    min-height: 0; /* Importante para que funcione el flex */
}

.asistente-chat-container::-webkit-scrollbar {
    width: 8px;
}

.asistente-chat-container::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

.asistente-chat-container::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 4px;
}

.asistente-chat-container::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* Mensajes del chat */
.mensaje-usuario, .mensaje-asistente {
    margin-bottom: 1rem;
    display: flex;
    align-items: flex-start;
    animation: fadeInUp 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    opacity: 0;
    animation-fill-mode: forwards;
    clear: both;
}

.mensaje-usuario {
    justify-content: flex-end;
}

.mensaje-asistente {
    justify-content: flex-start;
}

/* Burbujas de mensaje */
.burbuja {
    max-width: 80%;
    padding: 0.75rem 1rem;
    border-radius: 18px;
    line-height: 1.4;
    word-wrap: break-word;
    position: relative;
}

.burbuja-usuario {
    background: linear-gradient(135deg, #007bff, #0056b3);
    color: white;
    border-bottom-right-radius: 4px;
}

.burbuja-asistente {
    background: white;
    color: #333;
    border: 1px solid #e9ecef;
    border-bottom-left-radius: 4px;
}

/* Avatar de Tito en mensajes */
.avatar-tito {
    width: 35px;
    height: 35px;
    border-radius: 50%;
    object-fit: cover;
    margin-right: 0.5rem;
    border: 2px solid #007bff;
    flex-shrink: 0;
}

/* Tarjetas de productos */
.card-producto {
    max-width: 300px;
    margin: 0.5rem 0;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    overflow: hidden;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    background: white;
}

.card-producto:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.card-producto img {
    width: 100%;
    height: 150px;
    object-fit: cover;
}

.card-producto .p-3 {
    padding: 1rem;
}

.card-producto .card-title {
    font-size: 0.9rem;
    font-weight: 600;
    color: #333;
    margin-bottom: 0.5rem;
}

.card-producto .card-text {
    font-size: 0.8rem;
    color: #666;
    margin-bottom: 0.5rem;
}

/* Animación de puntos "escribiendo" */
.puntos {
    display: inline-block;
}

.punto {
    opacity: 0;
    animation: blink 1.4s infinite both;
}

.punto:nth-child(2) {
    animation-delay: 0.2s;
}

.punto:nth-child(3) {
    animation-delay: 0.4s;
}

/* Animaciones */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(15px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes blink {
    0%, 80%, 100% {
        opacity: 0;
    }
    40% {
        opacity: 1;
    }
}

/* Footer del panel */
.asistente-panel-footer {
    background: white;
    padding: 1rem;
    border-top: 1px solid #e9ecef;
    flex-shrink: 0; /* No se encoge */
}

.asistente-panel-footer form {
    display: flex;
    gap: 0.5rem;
}

.asistente-panel-footer input {
    flex: 1;
    border: 1px solid #ced4da;
    border-radius: 20px;
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
}

.asistente-panel-footer input:focus {
    outline: none;
    border-color: #007bff;
    box-shadow: 0 0 0 2px rgba(0,123,255,0.25);
}

.asistente-panel-footer button[type="submit"] {
    background: linear-gradient(135deg, #007bff, #0056b3);
    color: white;
    border: none;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.asistente-panel-footer button[type="submit"]:hover {
    transform: scale(1.05);
    box-shadow: 0 2px 8px rgba(0,123,255,0.3);
}

/* Responsive Design */
@media (max-width: 768px) {
    .asistente-widget-container {
        bottom: 15px;
        right: 15px;
    }

    .asistente-btn-toggle {
        width: 60px;
        height: 60px;
    }

    .asistente-avatar {
        width: 45px;
        height: 45px;
    }

    .asistente-panel {
        width: 95vw;
        height: 70vh;
        right: 50%;
        transform: translateX(50%) translateY(20px) scale(0.95);
        bottom: 90px;
    }

    .asistente-panel.show {
        transform: translateX(50%) translateY(0) scale(1);
    }

    .asistente-chat-container {
        padding: 0.75rem;
    }

    .burbuja {
        font-size: 0.9rem;
        max-width: 85%;
    }

    .card-producto {
        max-width: 100%;
    }
}

@media (max-width: 480px) {
    .asistente-panel {
        width: 98vw;
        height: 75vh;
        right: 50%;
        bottom: 80px;
    }

    .asistente-chat-container {
        padding: 0.5rem;
    }

    .burbuja {
        font-size: 0.85rem;
        padding: 0.6rem 0.8rem;
    }

    .avatar-tito {
        width: 30px;
        height: 30px;
    }

    .card-producto {
        margin: 0.25rem 0;
    }
}

/* Estados especiales */
.asistente-btn-toggle.conectando {
    animation: conectando 1s infinite;
}

@keyframes conectando {
    0%, 100% {
        box-shadow: 0 4px 20px rgba(0,123,255,0.4);
    }
    50% {
        box-shadow: 0 4px 30px rgba(0,123,255,0.7);
    }
}

/* Accesibilidad */
.asistente-btn-toggle:focus-visible {
    outline: 2px solid #007bff;
    outline-offset: 2px;
}

.asistente-panel-footer input:focus-visible {
    outline: 2px solid #007bff;
    outline-offset: 2px;
}

/* Clase helper para ocultar */
.asistente-panel.d-none {
    display: none !important;
} 