/* BOTÓN MODERNO DEL ASISTENTE - ARRIBA IZQUIERDA */

#coece-chat-button {
    position: fixed;
    left: 22px;
    top: 22px;
    width: auto;
    min-width: 210px;
    height: 54px;
    padding: 0 20px;
    background: linear-gradient(135deg, #004f73, #008fbd, #00b7df);
    color: #ffffff;
    border-radius: 999px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    cursor: pointer;
    font-family: "Open Sans", Arial, Helvetica, sans-serif;
    font-size: 15px;
    font-weight: 700;
    letter-spacing: 0.2px;
    box-shadow: 0 10px 28px rgba(0, 95, 135, 0.35);
    z-index: 999999;
    transition: all 0.25s ease;
    border: 1px solid rgba(255, 255, 255, 0.35);
    backdrop-filter: blur(8px);
}

#coece-chat-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 14px 36px rgba(0, 95, 135, 0.45);
    background: linear-gradient(135deg, #003f5f, #007fae, #00aeda);
}

#coece-chat-button::before {
    content: "?";
    width: 28px;
    height: 28px;
    background: rgba(255, 255, 255, 0.22);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

#coece-chat-button::after {
    content: "Asistente virtual";
}

/* VENTANA DEL CHAT ARRIBA IZQUIERDA */

#coece-chat-window {
    position: fixed;
    left: 22px;
    top: 88px;
    width: 395px;
    max-width: calc(100vw - 30px);
    height: 570px;
    max-height: calc(100vh - 115px);
    background: #ffffff;
    border-radius: 22px;
    box-shadow: 0 18px 45px rgba(0, 0, 0, 0.22);
    display: none;
    flex-direction: column;
    overflow: hidden;
    z-index: 999999;
    font-family: "Open Sans", Arial, Helvetica, sans-serif;
    border: 1px solid rgba(0, 127, 174, 0.18);
}

/* CABECERA */

#coece-chat-header {
    background: linear-gradient(135deg, #004f73, #007fae, #00a7d7);
    color: #ffffff;
    padding: 14px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
}

#coece-chat-header-main {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

#coece-chat-header-text {
    min-width: 0;
}

.coece-avatar {
    display: block;
    object-fit: cover;
    border-radius: 50%;
}

.coece-avatar-animated {
    animation: coeceAvatarFloat 4.6s ease-in-out infinite;
    transform-origin: center center;
}

.coece-header-avatar {
    width: 48px;
    height: 48px;
    background: rgba(255, 255, 255, 0.2);
    padding: 2px;
    box-shadow: 0 0 0 2px rgba(255,255,255,0.18);
}

#coece-chat-header strong {
    font-size: 16px;
    font-weight: 800;
}

#coece-chat-header span {
    font-size: 12px;
    opacity: 0.95;
}

#coece-chat-close {
    background: rgba(255, 255, 255, 0.18);
    border: none;
    color: #ffffff;
    font-size: 25px;
    cursor: pointer;
    line-height: 1;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    flex: 0 0 34px;
}

#coece-chat-close:hover {
    background: rgba(255, 255, 255, 0.28);
}

/* MENSAJES */

#coece-chat-messages {
    flex: 1;
    padding: 16px;
    overflow-y: auto;
    background: linear-gradient(180deg, #f2f9fc, #ffffff);
}

.coece-msg-row {
    width: 100%;
    display: flex;
    align-items: flex-end;
    gap: 9px;
    margin-bottom: 11px;
}

.coece-msg-row.user-row {
    justify-content: flex-end;
}

.coece-msg {
    max-width: 86%;
    padding: 11px 13px;
    border-radius: 16px;
    font-size: 14px;
    line-height: 1.45;
    white-space: pre-wrap;
    word-break: break-word;
}

.coece-msg-avatar {
    width: 34px;
    height: 34px;
    flex: 0 0 34px;
    margin-bottom: 2px;
    border: 2px solid rgba(0, 127, 174, 0.14);
    background: #ffffff;
}

.coece-msg.bot {
    background: #ffffff;
    color: #1f2d35;
    border: 1px solid #dcebf2;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.04);
    align-self: flex-start;
}

.coece-msg.user {
    background: linear-gradient(135deg, #007fae, #00a7d7);
    color: #ffffff;
    margin-left: auto;
    box-shadow: 0 5px 15px rgba(0, 127, 174, 0.25);
}

/* ZONA DE ESCRITURA */

#coece-chat-input-area {
    display: flex;
    gap: 8px;
    padding: 13px;
    background: #ffffff;
    border-top: 1px solid #dcebf2;
}

#coece-chat-input {
    flex: 1;
    border: 1px solid #c7dce6;
    border-radius: 999px;
    padding: 11px 14px;
    font-size: 14px;
    outline: none;
    font-family: "Open Sans", Arial, Helvetica, sans-serif;
}

#coece-chat-input:focus {
    border-color: #007fae;
    box-shadow: 0 0 0 3px rgba(0, 127, 174, 0.12);
}

#coece-chat-send {
    border: none;
    background: linear-gradient(135deg, #006f9f, #00a7d7);
    color: #ffffff;
    padding: 10px 18px;
    border-radius: 999px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 700;
    font-family: "Open Sans", Arial, Helvetica, sans-serif;
}

#coece-chat-send:hover {
    background: linear-gradient(135deg, #005f85, #008fbd);
}

/* ESTADOS DEL ASISTENTE */
#coece-chat-send:disabled,
#coece-chat-input:disabled {
    opacity: 0.65;
    cursor: not-allowed;
}

.coece-msg.loading {
    opacity: 0.8;
    font-style: italic;
}

/* ANIMACIÓN SUAVE DEL AVATAR */
@keyframes coeceAvatarFloat {
    0% { transform: translateY(0px); }
    25% { transform: translateY(-1px); }
    50% { transform: translateY(-2px); }
    75% { transform: translateY(-1px); }
    100% { transform: translateY(0px); }
}

/* ADAPTACIÓN A MÓVILES */

@media screen and (max-width: 600px) {
    #coece-chat-button {
        left: 14px;
        top: 14px;
        min-width: auto;
        width: 54px;
        height: 54px;
        padding: 0;
        border-radius: 50%;
    }

    #coece-chat-button::before {
        content: "?";
        width: auto;
        height: auto;
        background: transparent;
        font-size: 24px;
    }

    #coece-chat-button::after {
        content: "";
        display: none;
    }

    #coece-chat-window {
        left: 10px;
        right: 10px;
        top: 64px;
        bottom: 14px;
        width: auto;
        height: auto;
        max-height: calc(100dvh - 78px);
        border-radius: 18px;
    }

    #coece-chat-messages {
        padding: 12px;
    }

    #coece-chat-input-area {
        padding: 10px;
    }

    #coece-chat-input {
        padding: 10px 12px;
        font-size: 13px;
    }

    #coece-chat-send {
        padding: 9px 13px;
        font-size: 13px;
    }

    #coece-chat-header {
        padding: 12px 13px;
    }

    .coece-header-avatar {
        width: 44px;
        height: 44px;
    }

    .coece-msg {
        max-width: 82%;
    }
}
