/* ============================================================
   ACR Chatbot — Estilos
   Verde principal: #6DBE2E / #4A8F1A
   ============================================================ */

:root {
    --acr-green-light: #66BB6A;
    --acr-green-main:  #4CAF50;
    --acr-green-dark:  #388E3C;
    --acr-shadow:      rgba(56, 142, 60, 0.35);
    --acr-radius:      16px;
    --acr-font:        -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* ── Contenedor principal ── */
#acr-chat-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 999999;
    font-family: var(--acr-font);
    font-size: 14px;
    line-height: 1.5;
}

/* ── Burbuja flotante ── */
#acr-chat-toggle {
    width: 62px;
    height: 62px;
    border-radius: 50%;
    background: linear-gradient(140deg, var(--acr-green-light), var(--acr-green-dark));
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 16px var(--acr-shadow);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.25s ease, box-shadow 0.25s ease;
    overflow: hidden;
    padding: 0;
    outline: none;
}

#acr-chat-toggle:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 22px var(--acr-shadow);
}

#acr-chat-toggle:focus-visible {
    outline: 3px solid var(--acr-green-light);
    outline-offset: 3px;
}

#acr-chat-toggle img {
    width: 42px;
    height: 42px;
    object-fit: contain;
    border-radius: 50%;
}

/* ── Ventana del chat ── */
#acr-chat-window {
    position: absolute;
    bottom: 74px;
    right: 0;
    width: 370px;
    height: 520px;
    background: #ffffff;
    border-radius: var(--acr-radius);
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.18);
    display: flex;
    flex-direction: column;
    overflow: hidden;

    /* Animación de entrada */
    opacity: 0;
    transform: translateY(16px) scale(0.96);
    pointer-events: none;
    transition: opacity 0.28s ease, transform 0.28s ease;
}

#acr-chat-window:not([hidden]) {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: all;
}

/* Cuando está hidden forzamos la animación de salida */
#acr-chat-window[hidden] {
    display: flex !important; /* sobreescribir hidden para animar */
}

/* ── Encabezado ── */
#acr-chat-header {
    background: linear-gradient(140deg, var(--acr-green-light), var(--acr-green-dark));
    color: #fff;
    padding: 13px 16px;
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

#acr-chat-header img {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    object-fit: contain;
    background: rgba(255,255,255,0.2);
    padding: 4px;
}

#acr-chat-header svg {
    flex-shrink: 0;
}

#acr-chat-title {
    flex: 1;
    font-weight: 600;
    font-size: 15px;
    letter-spacing: 0.01em;
}

#acr-chat-close {
    background: none;
    border: none;
    cursor: pointer;
    color: rgba(255,255,255,0.85);
    padding: 4px;
    display: flex;
    align-items: center;
    border-radius: 50%;
    transition: background 0.2s, color 0.2s;
}

#acr-chat-close:hover {
    background: rgba(255,255,255,0.2);
    color: #fff;
}

/* ── Área de mensajes ── */
#acr-messages {
    flex: 1;
    overflow-y: auto;
    padding: 14px 14px 8px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    background: #f5f6f8;
    scroll-behavior: smooth;
}

#acr-messages::-webkit-scrollbar { width: 5px; }
#acr-messages::-webkit-scrollbar-track { background: transparent; }
#acr-messages::-webkit-scrollbar-thumb { background: #ccc; border-radius: 4px; }

/* ── Mensajes ── */
.acr-message {
    max-width: 85%;
    padding: 10px 14px;
    border-radius: 18px;
    word-break: break-word;
    animation: acr-fadein 0.2s ease;
}

@keyframes acr-fadein {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}

.acr-bot {
    background: #ffffff;
    color: #1a1a1a;
    align-self: flex-start;
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}

.acr-user {
    background: linear-gradient(140deg, var(--acr-green-light), var(--acr-green-main));
    color: #ffffff;
    align-self: flex-end;
    border-bottom-right-radius: 4px;
}

/* Links dentro de mensajes del bot */
.acr-bot a {
    color: var(--acr-green-main);
    text-decoration: underline;
    font-weight: 500;
    word-break: break-all;
}

.acr-bot a:hover {
    color: var(--acr-green-dark);
}

/* ── Indicador "escribiendo..." ── */
.acr-typing {
    display: flex;
    gap: 5px;
    align-items: center;
    padding: 12px 16px;
    min-height: 42px;
}

.acr-typing span {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--acr-green-light);
    animation: acr-bounce 1.3s infinite ease-in-out;
}

.acr-typing span:nth-child(2) { animation-delay: 0.18s; }
.acr-typing span:nth-child(3) { animation-delay: 0.36s; }

@keyframes acr-bounce {
    0%, 60%, 100% { transform: translateY(0);    opacity: 0.6; }
    30%            { transform: translateY(-7px); opacity: 1;   }
}

/* ── Área de input ── */
#acr-chat-input-area {
    padding: 10px 12px;
    border-top: 1px solid #e8eaed;
    display: flex;
    gap: 8px;
    align-items: center;
    background: #fff;
    flex-shrink: 0;
}

#acr-chat-input {
    flex: 1;
    border: 1.5px solid #dde1e7;
    border-radius: 22px;
    padding: 9px 16px;
    font-size: 14px;
    font-family: var(--acr-font);
    outline: none;
    transition: border-color 0.2s;
    background: #f9fafb;
    color: #1a1a1a;
}

#acr-chat-input:focus {
    border-color: var(--acr-green-light);
    background: #fff;
}

#acr-send-btn {
    width: 40px;
    height: 40px;
    min-width: 40px;
    border-radius: 50%;
    background: linear-gradient(140deg, var(--acr-green-light), var(--acr-green-dark));
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s, box-shadow 0.2s;
    box-shadow: 0 2px 8px var(--acr-shadow);
    outline: none;
}

#acr-send-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 12px var(--acr-shadow);
}

#acr-send-btn:disabled {
    opacity: 0.55;
    cursor: not-allowed;
    transform: none;
}

/* ── Responsive móvil ── */
@media (max-width: 480px) {
    #acr-chat-container {
        bottom: 16px;
        right: 16px;
    }
    #acr-chat-window {
        width: calc(100vw - 32px);
        height: calc(100vh - 120px);
        right: -8px;
        bottom: 78px;
        border-radius: 14px;
    }
}
