/* ── Botón flotante ── */

.chat-btn {
    position: fixed;
    bottom: 28px;
    right: 28px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background-color: var(--azul);
    color: white;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    box-shadow: 0 6px 24px rgba(10, 67, 139, 0.45);
    z-index: 999;
    transition: transform 0.2s, background-color 0.2s;
}

.chat-btn:hover {
    transform: scale(1.1);
    background-color: #0d55b0;
}

.chat-btn ion-icon {
    color: white;
    font-size: 28px;
}

/* ── Ventana del chat ── */

.chat-window {
    position: fixed;
    bottom: 100px;
    right: 28px;
    width: 350px;
    height: 520px;
    background-color: white;
    border-radius: 20px;
    box-shadow: 0 16px 50px rgba(0, 0, 0, 0.2);
    display: flex;
    flex-direction: column;
    z-index: 998;
    overflow: hidden;
    transform: scale(0.85) translateY(30px);
    opacity: 0;
    pointer-events: none;
    transition: transform 0.25s ease, opacity 0.25s ease;
    transform-origin: bottom right;
}

.chat-window.open {
    transform: scale(1) translateY(0);
    opacity: 1;
    pointer-events: all;
}

/* ── Header del chat ── */

.chat-header {
    background-color: var(--azul);
    color: white;
    padding: 16px 18px;
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

.chat-header-avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background-color: var(--amarillo, rgb(255, 196, 0));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    flex-shrink: 0;
}

.chat-header-avatar ion-icon {
    color: var(--azul);
    font-size: 20px;
}

.chat-header-info {
    flex: 1;
}

.chat-header-info strong {
    color: white;
    font-size: 15px;
    display: block;
}

.chat-header-info span {
    color: rgba(255, 255, 255, 0.7);
    font-size: 12px;
}

.chat-close {
    background: none;
    border: none;
    cursor: pointer;
    color: white;
    font-size: 22px;
    display: flex;
    align-items: center;
    padding: 4px;
    border-radius: 50%;
    transition: background-color 0.2s;
}

.chat-close:hover {
    background-color: rgba(255, 255, 255, 0.15);
}

.chat-close ion-icon {
    color: white;
    font-size: 20px;
}

/* ── Área de mensajes ── */

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    background-color: #f5f7fb;
    scrollbar-width: thin;
    scrollbar-color: #ccc transparent;
}

.chat-messages::-webkit-scrollbar {
    width: 4px;
}

.chat-messages::-webkit-scrollbar-thumb {
    background-color: #ccc;
    border-radius: 4px;
}

/* ── Burbujas ── */

.chat-bubble {
    max-width: 82%;
    padding: 10px 14px;
    border-radius: 16px;
    font-size: 14px;
    line-height: 1.5;
    word-break: break-word;
}

.chat-bubble.bot {
    background-color: white;
    color: #222;
    border-bottom-left-radius: 4px;
    align-self: flex-start;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.07);
}

.chat-bubble.user {
    background-color: var(--azul);
    color: white;
    border-bottom-right-radius: 4px;
    align-self: flex-end;
}

.chat-bubble.user * {
    color: white;
}

/* Negritas en mensajes del bot */
.chat-bubble.bot strong {
    color: var(--azul);
}

/* ── Indicador de escritura ── */

.chat-typing {
    display: flex;
    gap: 5px;
    align-items: center;
    padding: 12px 14px;
    background-color: white;
    border-radius: 16px;
    border-bottom-left-radius: 4px;
    align-self: flex-start;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.07);
}

.chat-typing span {
    width: 7px;
    height: 7px;
    background-color: #aaa;
    border-radius: 50%;
    animation: typing-dot 1.2s infinite ease-in-out;
}

.chat-typing span:nth-child(2) { animation-delay: 0.2s; }
.chat-typing span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typing-dot {
    0%, 80%, 100% { transform: scale(0.8); opacity: 0.5; }
    40%            { transform: scale(1.2); opacity: 1; }
}

/* ── Input ── */

.chat-input-area {
    display: flex;
    align-items: center;
    padding: 12px 14px;
    border-top: 1px solid #eee;
    gap: 10px;
    background-color: white;
    flex-shrink: 0;
}

.chat-input {
    flex: 1;
    border: 1.5px solid #ddd;
    border-radius: 24px;
    padding: 10px 16px;
    font-size: 14px;
    outline: none;
    color: #333;
    transition: border-color 0.2s;
    font-family: inherit;
    resize: none;
}

.chat-input:focus {
    border-color: var(--azul);
}

.chat-send {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background-color: var(--azul);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background-color 0.2s, transform 0.15s;
}

.chat-send:hover {
    background-color: #0d55b0;
    transform: scale(1.08);
}

.chat-send:disabled {
    background-color: #aaa;
    cursor: not-allowed;
    transform: none;
}

.chat-send ion-icon {
    color: white;
    font-size: 18px;
}

/* ── Responsive móvil ── */

@media (max-width: 750px) {
    .chat-window {
        width: calc(100vw - 24px);
        height: 70vh;
        right: 12px;
        bottom: 90px;
    }

    .chat-btn {
        bottom: 20px;
        right: 20px;
        width: 54px;
        height: 54px;
    }
}
