
/* Estilos para el Widget de Chat Dyna */

:root {
    --dyna-primary: #0A2540;
    --dyna-accent: #00A86B;
    --dyna-background: #ffffff;
    --dyna-header: linear-gradient(135deg, var(--dyna-primary) 0%, #0d3a5f 100%);
    --dyna-user-msg-bg: #e9f7ef;
    --dyna-user-msg-text: #333;
    --dyna-bot-msg-bg: #f6f9fc;
    --dyna-bot-msg-text: #2c2c2c;
    --dyna-border-color: #e6ebf1;
    --dyna-box-shadow: 0 10px 30px rgba(10, 37, 64, 0.15);
}

/* Contenedor del Botón Flotante */
#dyna-widget-button {
    position: fixed;
    bottom: 0px;
    right: -10px;
    width: 150px;
    height: 150px;
    cursor: pointer;
    z-index: 9998;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

#dyna-widget-button:hover {
    transform: scale(1.1);
}

/* Burbuja de Mensaje Proactivo */
#dyna-teaser-bubble {
    position: fixed;
    bottom: 160px; /* Adjusted for new button position */
    right: 10px;   /* Adjusted for new button position */
    background: var(--dyna-header);
    color: white;
    padding: 12px 18px;
    border-radius: 20px 20px 0 20px;
    box-shadow: var(--dyna-box-shadow);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.4s, transform 0.4s, visibility 0.4s;
    transform: translateY(20px);
    z-index: 9997;
    font-size: 14px;
    max-width: 250px;
}

#dyna-teaser-bubble.visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

/* Contenedor de la Ventana de Chat */
#dyna-chat-window {
    position: fixed;
    bottom: 165px; /* Adjusted for new button position */
    right: -10px;   /* Adjusted for new button position */
    width: 350px;
    max-width: calc(100% - 30px);
    height: 500px;
    max-height: calc(100vh - 200px);
    background: var(--dyna-background);
    border-radius: 16px;
    box-shadow: var(--dyna-box-shadow);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: 9999;

    /* Animaciones */
    opacity: 0;
    visibility: hidden;
    transform: translateY(30px) scale(0.95);
    transition: opacity 0.3s, transform 0.3s, visibility 0.3s;
}

#dyna-chat-window.visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

/* Encabezado del Chat */
#dyna-chat-header {
    background: var(--dyna-header);
    color: white;
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-top-left-radius: 16px;
    border-top-right-radius: 16px;
}

#dyna-chat-header h3 {
    font-size: 18px;
    font-weight: 600;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 10px;
}

#dyna-chat-header .icon {
    font-size: 20px;
}

#dyna-chat-controls button {
    background: none;
    border: none;
    color: white;
    font-size: 18px;
    cursor: pointer;
    opacity: 0.8;
    transition: opacity 0.2s;
    padding: 5px;
}

#dyna-chat-controls button:hover {
    opacity: 1;
}

/* Cuerpo de Mensajes */
#dyna-chat-body {
    flex-grow: 1;
    padding: 20px;
    overflow-y: auto;
    background-color: #E5DDD5; /* WhatsApp-like background color */
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='400' height='400' viewBox='0 0 800 800'%3E%3Cg fill='none' stroke='%23BDBDBD' stroke-width='1'%3E%3Cpath d='M769 229L1037 260.9M927 880L731 737 520 660 309 538 40 599 295 764 126.5 879.5 40 599-197 493-43 252 212 164 421 250 620 150 769 229 940 300 927 880z'/%3E%3Cpath d='M-43 252L212 164LL620 150L769 229L940 300L927 880L731 737L520 660L309 538L40 599L295 764L126.5 879.5L40 599L-197 493L-43 252z'/%3E%3Cpath d='M520 660L578 842L731 737L927 880L940 300L769 229L620 150L421 250L212 164L-43 252L-197 493L40 599L126.5 879.5L295 764L309 538L520 660z'/%3E%3Cpath d='M578 842L731 737L927 880L940 300L769 229L620 150L421 250L212 164L-43 252L-197 493L40 599L126.5 879.5L295 764L309 538L520 660z'/%3E%3Cpath d='M-43 252L212 164L421 250L620 150L769 229L940 300L927 880L731 737L520 660L309 538L40 599L295 764L126.5 879.5L40 599L-197 493L-43 252z'/%3E%3C/g%3E%3C/svg%3E");
}

.dyna-message {
    display: flex;
    margin-bottom: 15px;
    max-width: 90%;
}

.dyna-message .avatar {
    width: 35px;
    height: 35px;
    border-radius: 50%;
    margin-right: 12px;
    flex-shrink: 0;
}

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

/* Mensajes del Bot (Dyna) */
.dyna-message.bot {
    align-self: flex-start;
}

.dyna-message.bot .message-content {
    background-color: var(--dyna-bot-msg-bg);
    color: var(--dyna-bot-msg-text);
    border: 1px solid var(--dyna-border-color);
    border-top-left-radius: 0;
}

/* Mensajes del Usuario */
.dyna-message.user {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.dyna-message.user .message-content {
    background-color: var(--dyna-user-msg-bg);
    color: var(--dyna-user-msg-text);
    border-top-right-radius: 0;
}

.dyna-message.user .avatar {
    margin-left: 12px;
    margin-right: 0;
    background-color: var(--dyna-accent); /* Placeholder for user avatar */
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 600;
}


/* Efecto de Escritura */
.typing-indicator span {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: #ccc;
    margin: 0 2px;
    animation: typing-bounce 1.2s infinite ease-in-out;
}

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

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

@keyframes typing-bounce {
    0%, 80%, 100% {
        transform: scale(0);
    }
    40% {
        transform: scale(1.0);
    }
}

.typing-caret {
    display: inline-block;
    width: 2px;
    height: 1em;
    background-color: var(--dyna-primary);
    animation: blink 0.7s infinite;
    margin-left: 2px;
    vertical-align: middle;
}

@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0; }
}

/* Pie de página del Chat (Input) */
#dyna-chat-footer {
    padding: 15px;
    border-top: 1px solid var(--dyna-border-color);
    background-color: var(--dyna-background);
}

#dyna-input-form {
    display: flex;
    gap: 10px;
}

#dyna-input-form input {
    flex-grow: 1;
    border: 2px solid var(--dyna-border-color);
    border-radius: 20px;
    padding: 10px 15px;
    font-size: 14px;
    transition: border-color 0.2s;
}

#dyna-input-form input:focus {
    outline: none;
    border-color: var(--dyna-accent);
}

#dyna-input-form button {
    background-color: var(--dyna-accent);
    border: none;
    color: white;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    font-size: 18px;
    cursor: pointer;
    flex-shrink: 0;
    transition: background-color 0.2s;
}

#dyna-input-form button:hover {
    background-color: var(--dyna-primary);
}
