/* ==========================================================
   CHATBOT UNIVERSAL - BOTROBOT 77
   CSS FINAL MODERNO (VERSIÓN SARA)
========================================================== */

/* ==========================================================
   1. VARIABLES DINÁMICAS
========================================================== */
:root {
    --cu-font-family: "Inter", system-ui, sans-serif;
    --cu-font-size: 14px;
    --cu-message-font-size: 14px;

    --cu-launcher-color: #000000;
    --cu-header-color: #1E1E1E;
    --cu-header-text-color: #FFFFFF;
    --cu-bot-message-color: #F1F1F1;
    --cu-user-message-color: #000000;
    --cu-chat-background-color: #FFFFFF;
    --cu-button-color: #000000;

    --cu-shadow-soft: 0 4px 14px rgba(0,0,0,0.12);
    --cu-shadow-medium: 0 8px 24px rgba(0,0,0,0.18);
    --cu-shadow-strong: 0 18px 40px rgba(0,0,0,0.35);

    --cu-radius: 14px;
    --cu-radius-sm: 8px;

    --cu-btn-padding: 10px 12px;
    --cu-btn-font-size: 14px;
}

/* ==========================================================
   2. LAUNCHER + TOOLTIP
========================================================== */

.botrobot-launcher-wrapper {
    position: fixed;
    bottom: 24px;
    z-index: 999999;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.botrobot-launcher-wrapper-left { left: 24px; }
.botrobot-launcher-wrapper-right { right: 24px; }

.botrobot-launcher {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--cu-launcher-color);
    color: #FFF;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: var(--cu-shadow-medium);
    transition: transform .25s ease, box-shadow .25s ease;
    animation: ombraFloat 3s ease-in-out infinite;
}

.botrobot-launcher:hover {
    transform: translateY(-3px);
    box-shadow: var(--cu-shadow-strong);
}

@keyframes ombraFloat {
    0%,100% { transform: translateY(0); }
    50% { transform: translateY(-4px); }
}

/* ==========================================================
   TOOLTIP
========================================================== */

.botrobot-tooltip {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: #FFF;
    color: #000;
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 13px;
    font-family: var(--cu-font-family);
    box-shadow: var(--cu-shadow-soft);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity .25s ease;
    white-space: nowrap;
}

.botrobot-launcher-wrapper-right .botrobot-tooltip { right: 60px; }
.botrobot-launcher-wrapper-left .botrobot-tooltip { left: 60px; }

.botrobot-launcher-wrapper:hover .botrobot-tooltip {
    opacity: 1;
    visibility: visible;
}

/* ==========================================================
   3. CHAT WINDOW
========================================================== */

#botrobot-chat {
    position: fixed;
    bottom: 90px;
    left: 24px;

    width: 360px;
    max-width: 92vw;
    height: 520px;

    background: var(--cu-chat-background-color);
    border-radius: var(--cu-radius);
    box-shadow: var(--cu-shadow-strong);

    display: flex;
    flex-direction: column;
    overflow: hidden;

    font-family: var(--cu-font-family);
    font-size: var(--cu-font-size);

    animation: cuFadeIn .25s ease;

    z-index: 999998;
}

#botrobot-chat * { box-sizing: border-box; }

.botrobot-hidden { display: none !important; }

@keyframes cuFadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ==========================================================
   4. HEADER
========================================================== */

#botrobot-header {
    background: var(--cu-header-color);
    color: var(--cu-header-text-color);
    padding: 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

#botrobot-header span {
    font-weight: 600;
    font-size: 16px;
    font-family: var(--cu-font-family);
}

#botrobot-font-controls {
    display: flex;
    align-items: center;
    gap: 6px;
}

#bot-font-minus,
#bot-font-plus {
    border: none;
    background: rgba(255,255,255,.15);
    color: var(--cu-header-text-color);
    padding: 4px 8px;
    border-radius: var(--cu-radius-sm);
    cursor: pointer;
    font-size: 12px;
    transition: .2s ease;
}

#bot-font-minus:hover,
#bot-font-plus:hover {
    background: rgba(255,255,255,.25);
}

#botrobot-close {
    font-size: 20px;
    cursor: pointer;
    padding: 0 4px;
}

/* ==========================================================
   5. MENSAJES
========================================================== */

#botrobot-messages {
    flex: 1;
    padding: 16px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.botrobot-message {
    max-width: 85%;
    padding: 12px 16px;
    border-radius: 12px;
    font-size: var(--cu-message-font-size);
    line-height: 1.45;
    font-family: var(--cu-font-family);
    animation: cuMessageIn .25s ease;
    white-space: pre-line;
    word-break: break-word;
}

@keyframes cuMessageIn {
    from { opacity: 0; transform: translateY(4px); }
    to { opacity: 1; transform: translateY(0); }
}

.botrobot-message.bot {
    background: var(--cu-bot-message-color);
    color: #000;
    align-self: flex-start;
    border-radius: 12px 12px 12px 0;
}

.botrobot-message.user {
    background: var(--cu-user-message-color);
    color: #FFF;
    align-self: flex-end;
    border-radius: 12px 12px 0 12px;
}

/* ==========================================================
   6. TYPING
========================================================== */

.botrobot-typing {
    background: var(--cu-bot-message-color);
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 10px 12px;
    border-radius: 12px;
}

.botrobot-typing .dot {
    width: 6px;
    height: 6px;
    background: #999;
    border-radius: 50%;
    animation: cuTyping 1.2s infinite ease-in-out;
}

.botrobot-typing .dot:nth-child(2) { animation-delay: .15s; }
.botrobot-typing .dot:nth-child(3) { animation-delay: .30s; }

@keyframes cuTyping {
    0%,80%,100% { opacity: .3; transform: translateY(0); }
    40% { opacity: 1; transform: translateY(-3px); }
}

/* ==========================================================
   7. OPCIONES (BOTONES)
========================================================== */

#botrobot-options {
    padding: 16px;
    border-top: 1px solid #EEE;
    background: #FFF;
}

.botrobot-option {
    width: 100%;
    background: #FFFFFF;
    color: #000;
    border: 1px solid #D9D9D9;
    border-radius: 10px;
    padding: var(--cu-btn-padding);
    margin-top: 10px;
    cursor: pointer;
    font-family: var(--cu-font-family);
    font-size: var(--cu-btn-font-size);
    font-weight: 500;
    line-height: 1.4;
    transition: all .2s ease;
    box-shadow: 0 1px 2px rgba(0,0,0,.04);
}

.botrobot-option:hover {
    background: #F2F2F2;
    border-color: #C7C7C7;
    color: #000;
}

.botrobot-option:active {
    transform: scale(.99);
}

/* ==========================================================
   8. INPUTS
========================================================== */

.botrobot-open-field {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.botrobot-input {
    width: 100%;
    padding: var(--cu-btn-padding);
    border: 1px solid #DDD;
    border-radius: var(--cu-radius);
    background: #FFF;
    color: #000;
    font-family: var(--cu-font-family);
    font-size: var(--cu-btn-font-size);
    line-height: 1.4;
    transition: border-color .2s ease, box-shadow .2s ease;
}

.botrobot-input:focus {
    outline: none;
    border-color: var(--cu-button-color);
    box-shadow: 0 0 0 2px rgba(0,0,0,.18);
}

/* ==========================================================
   9. BOTÓN PRINCIPAL
========================================================== */

.botrobot-primary-btn {
    width: 100%;
    border: none;
    background: var(--cu-button-color);
    color: #FFF;
    padding: var(--cu-btn-padding);
    border-radius: 8px;
    font-family: var(--cu-font-family);
    font-size: var(--cu-btn-font-size);
    font-weight: 600;
    cursor: pointer;
    box-shadow: var(--cu-shadow-medium);
    transition: background .2s ease, box-shadow .2s ease, transform .15s ease;
}

.botrobot-primary-btn:hover {
    background: #333;
    box-shadow: var(--cu-shadow-strong);
}

.botrobot-primary-btn:active {
    transform: scale(.99);
}

/* ==========================================================
   10. PRIVACIDAD
========================================================== */

.cu-privacy-link {
    color: #007bff;
    text-decoration: underline;
    font-family: var(--cu-font-family);
    transition: color .2s ease;
}

.cu-privacy-link:hover {
    color: #0056b3;
    text-decoration: none;
}

.botrobot-privacy,
.botrobot-consent,
.cu-privacy-box {
    margin-top: 12px;
    padding: 12px 14px;
    border: 1px solid #E5E5E5;
    border-radius: 10px;
    background: #FAFAFA;
    font-family: var(--cu-font-family);
    font-size: 13px;
    line-height: 1.45;
    color: #444;
    max-width: 100%;
}

.botrobot-privacy p,
.botrobot-consent p,
.cu-privacy-box p {
    margin: 0;
}

/* ==========================================================
   11. RESPONSIVE (MÓVIL)
========================================================== */

@media (max-width: 480px) {

    .botrobot-launcher {
        width: 52px;
        height: 52px;
    }

    .botrobot-launcher-wrapper {
        bottom: 16px;
    }

    .botrobot-launcher-wrapper-left { left: 12px; }
    .botrobot-launcher-wrapper-right { right: 12px; }

    #botrobot-chat {
        width: calc(100% - 24px);
        max-width: 420px;
        height: 72vh;
        left: 12px;
        right: 12px;
        bottom: 84px;
        border-radius: 14px;
    }

    #botrobot-header { padding: 14px; }
    #botrobot-header span { font-size: 15px; }

    #botrobot-messages {
        padding: 14px;
        gap: 10px;
    }

    .botrobot-message {
        font-size: var(--cu-message-font-size);
        padding: 10px 14px;
    }

    #botrobot-options { padding: 14px; }

    .botrobot-option {
        padding: 8px 10px;
        font-size: var(--cu-btn-font-size);
        margin-top: 8px;
    }

    .botrobot-input {
        padding: 8px 10px;
        font-size: var(--cu-btn-font-size);
    }

    .botrobot-primary-btn {
        padding: 8px 10px;
        font-size: var(--cu-btn-font-size);
    }

    .botrobot-tooltip { display: none; }
}

/* ==========================================================
   12. AJUSTES FINALES
========================================================== */

#botrobot-chat,
#botrobot-chat * {
    font-family: var(--cu-font-family);
}

.botrobot-message,
.botrobot-option,
.botrobot-input,
.botrobot-primary-btn {
    word-break: break-word;
}

#botrobot-messages {
    scrollbar-width: thin;
}

#botrobot-messages::-webkit-scrollbar {
    width: 6px;
}

#botrobot-messages::-webkit-scrollbar-thumb {
    background: rgba(0,0,0,.18);
    border-radius: 8px;
}

#botrobot-messages::-webkit-scrollbar-track {
    background: transparent;
}

/* ==========================================================
   ⭐ BOTÓN WHATSAPP BLANCO (ESTILO OMBRA)
========================================================== */

.botrobot-option.whatsapp-button {
    background: #fff;
    color: #000;
    border: 1px solid #ddd;
    border-radius: var(--cu-radius-sm);
    padding: var(--cu-btn-padding);
    font-family: var(--cu-font-family);
    font-size: var(--cu-btn-font-size);
    transition: background .2s ease, color .2s ease, opacity .2s ease;
}

.botrobot-option.whatsapp-button:hover {
    background: #f5f5f5;
    color: #000;
    opacity: 0.85;
}

/* ==========================================================
   ⭐ FIXES CSS AÑADIDOS (VERSIÓN SARA)
========================================================== */

#botrobot-chat .cu-privacy-link {
    color: #007bff;
    text-decoration: underline;
    cursor: pointer;
    font-weight: 500;
}

#botrobot-chat .botrobot-message.bot a {
    color: #007bff;
    text-decoration: underline;
}

/* Botón WhatsApp no cambia a azul al volver */
#botrobot-chat .botrobot-option:visited,
#botrobot-chat .botrobot-option:focus {
    background-color: #fff;
    color: #000;
}

/* A+ y A− funcionando en móvil */
#botrobot-chat {
    contain: none;
}

#botrobot-chat .botrobot-message {
    font-size: var(--cu-message-font-size);
}

#botrobot-chat .botrobot-option,
#botrobot-chat .botrobot-primary-btn {
    font-size: var(--cu-btn-font-size);
}

#botrobot-chat .botrobot-input {
    font-size: var(--cu-btn-font-size);
}

/* ==========================================================
   ⭐ FIN DE FIXES CSS
========================================================== */
