/* ============================================================
   5INKO ChatBot IA — Estilos Frontend v1.0.2 | 5inko.com
   ============================================================ */

:root {
    --ficbot-accent: #16A34A;
    --ficbot-accent-dark: #0f7a36;
    --ficbot-white: #ffffff;
    --ficbot-gray-50: #f9fafb;
    --ficbot-gray-100: #f3f4f6;
    --ficbot-gray-200: #e5e7eb;
    --ficbot-gray-400: #9ca3af;
    --ficbot-gray-500: #6b7280;
    --ficbot-gray-800: #1f2937;
    --ficbot-wa: #075E54;
    --ficbot-shadow: 0 10px 40px rgba(0,0,0,.18);
    --ficbot-radius: 16px;
    --ficbot-z: 99999;
}

/* Contenedor: ventana arriba, botón abajo */
#ficbot-container {
    position: fixed;
    bottom: 24px;
    z-index: var(--ficbot-z);
    display: flex;
    flex-direction: column;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}
#ficbot-container.ficbot-bottom-right { right: 24px; align-items: flex-end; }
#ficbot-container.ficbot-bottom-left  { left: 24px;  align-items: flex-start; }

/* Reset: protege los botones de los estilos globales del tema (padding, mayúsculas, bordes) */
#ficbot-container button {
    padding: 0 !important;
    margin: 0;
    min-height: 0;
    line-height: 1;
    text-transform: none;
    letter-spacing: normal;
    box-sizing: border-box;
    font-family: inherit;
}
#ficbot-container svg { display: block; flex-shrink: 0; }

/* Botón flotante */
#ficbot-toggle {
    width: 58px; height: 58px;
    border-radius: 50%;
    background: var(--ficbot-accent);
    color: var(--ficbot-white);
    border: none;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    box-shadow: var(--ficbot-shadow);
    transition: transform .2s ease, background .2s;
    position: relative;
    overflow: visible;
}
#ficbot-toggle:hover { background: var(--ficbot-accent-dark); transform: scale(1.06); }
#ficbot-toggle:focus-visible { outline: 3px solid var(--ficbot-accent); outline-offset: 3px; }
#ficbot-icon-open { display: flex; align-items: center; justify-content: center; width: 100%; height: 100%; }
#ficbot-icon-open .ficbot-default-icon { width: 30px !important; height: 30px !important; }
#ficbot-icon-open img { width: 58px !important; height: 58px !important; border-radius: 50%; object-fit: cover; display: block; }
#ficbot-icon-close { width: 24px !important; height: 24px !important; }
.ficbot-has-icon #ficbot-toggle { background: transparent; }
.ficbot-has-icon.ficbot-open #ficbot-toggle { background: var(--ficbot-accent); }

/* Pulso (se detiene con el chat abierto o si el usuario prefiere menos movimiento) */
#ficbot-toggle::after {
    content: '';
    position: absolute; inset: 0;
    border-radius: 50%;
    border: 2px solid var(--ficbot-accent);
    animation: ficbot-pulse 3s ease-out infinite;
    pointer-events: none;
}
.ficbot-open #ficbot-toggle::after { animation: none; opacity: 0; }
@keyframes ficbot-pulse {
    0%   { transform: scale(1);   opacity: .6; }
    60%  { transform: scale(1.5); opacity: 0; }
    100% { transform: scale(1.5); opacity: 0; }
}

/* Ventana */
#ficbot-window {
    width: 350px;
    max-height: min(560px, calc(100vh - 120px));
    background: var(--ficbot-white);
    border-radius: var(--ficbot-radius);
    box-shadow: var(--ficbot-shadow);
    display: flex; flex-direction: column;
    overflow: hidden;
    margin-bottom: 12px;
    animation: ficbot-slide-up .25s ease;
}
@keyframes ficbot-slide-up { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: translateY(0); } }

/* Encabezado */
#ficbot-header {
    background: var(--ficbot-accent);
    color: var(--ficbot-white);
    padding: 14px 16px;
    display: flex; align-items: center; justify-content: space-between;
}
.ficbot-header-info { display: flex; align-items: center; gap: 10px; }
.ficbot-avatar {
    width: 38px; height: 38px; flex: 0 0 38px;
    border-radius: 50%;
    background: rgba(255,255,255,.18);
    display: flex; align-items: center; justify-content: center;
    overflow: hidden;
}
.ficbot-avatar img { width: 38px !important; height: 38px !important; object-fit: cover; display: block; }
.ficbot-avatar .ficbot-default-icon { width: 22px !important; height: 22px !important; color: var(--ficbot-white); }
.ficbot-bot-name { font-weight: 700; font-size: 14px; }
.ficbot-status-text { font-size: 11px; opacity: .9; display: flex; align-items: center; gap: 5px; margin-top: 2px; }
.ficbot-dot { width: 7px; height: 7px; background: #4ade80; border-radius: 50%; display: inline-block; }
#ficbot-close-btn {
    background: none; border: none; color: var(--ficbot-white);
    font-size: 18px; cursor: pointer; opacity: .8;
    width: 32px; height: 32px;
    display: flex; align-items: center; justify-content: center;
    border-radius: 50%;
}
#ficbot-close-btn:hover { opacity: 1; background: rgba(255,255,255,.15); }

/* Mensajes */
#ficbot-messages {
    flex: 1;
    overflow-y: auto;
    padding: 14px 14px 8px;
    display: flex; flex-direction: column; gap: 10px;
    min-height: 180px;
    scroll-behavior: smooth;
    overscroll-behavior: contain;
}
#ficbot-messages::-webkit-scrollbar { width: 4px; }
#ficbot-messages::-webkit-scrollbar-thumb { background: var(--ficbot-gray-200); border-radius: 4px; }

.ficbot-msg {
    max-width: 85%;
    padding: 9px 13px;
    border-radius: 14px;
    font-size: 14px;
    line-height: 1.45;
    word-break: break-word;
    animation: ficbot-fade-in .2s ease;
}
@keyframes ficbot-fade-in { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }
.ficbot-msg-bot  { background: var(--ficbot-gray-100); color: var(--ficbot-gray-800); border-bottom-left-radius: 4px; align-self: flex-start; }
.ficbot-msg-user { background: var(--ficbot-accent); color: var(--ficbot-white); border-bottom-right-radius: 4px; align-self: flex-end; }

/* Respuestas fijas con formato */
.ficbot-msg-rich { line-height: 1.5; }
.ficbot-msg-rich p { margin: 0 0 8px; }
.ficbot-msg-rich ul, .ficbot-msg-rich ol { margin: 0 0 8px 18px; padding: 0; }
.ficbot-msg-rich li { margin: 0 0 4px; }
.ficbot-msg-rich a:not(.ficbot-cta-wa):not(.ficbot-cta-mail) { color: var(--ficbot-accent); font-weight: 600; text-decoration: underline; }
.ficbot-msg-rich .ficbot-cta-lead { margin: 10px 0 6px; font-weight: 600; }

/* Botones de contacto */
.ficbot-cta { display: flex; gap: 8px; margin-top: 2px; }
.ficbot-cta a {
    flex: 1;
    display: flex; align-items: center; justify-content: center;
    box-sizing: border-box;
    min-height: 42px;
    padding: 8px 12px;
    border-radius: 999px;
    line-height: 1.2;
    font-size: 14px; font-weight: 600;
    text-decoration: none !important;
    transition: transform .15s, opacity .15s;
}
.ficbot-cta a:hover { transform: translateY(-1px); opacity: .92; }
.ficbot-cta a:focus-visible { outline: 2px solid var(--ficbot-accent); outline-offset: 2px; }
.ficbot-cta-wa   { background: var(--ficbot-wa); color: #fff !important; }
.ficbot-cta-mail { background: #fff; color: var(--ficbot-accent) !important; border: 2px solid var(--ficbot-accent); }

/* Escribiendo... */
.ficbot-typing {
    display: flex; gap: 4px;
    padding: 10px 14px;
    background: var(--ficbot-gray-100);
    border-radius: 14px; border-bottom-left-radius: 4px;
    align-self: flex-start; width: fit-content;
}
.ficbot-typing span { width: 7px; height: 7px; background: var(--ficbot-gray-400); border-radius: 50%; animation: ficbot-bounce .9s infinite; }
.ficbot-typing span:nth-child(2) { animation-delay: .15s; }
.ficbot-typing span:nth-child(3) { animation-delay: .30s; }
@keyframes ficbot-bounce { 0%, 60%, 100% { transform: translateY(0); } 30% { transform: translateY(-5px); } }

/* Sugerencias */
#ficbot-suggestions-wrap { display: flex; flex-wrap: wrap; gap: 6px; padding: 6px 14px 4px; }
#ficbot-suggestions-wrap:empty { display: none; }
#ficbot-container .ficbot-suggestion {
    font-size: 12.5px;
    padding: 7px 12px !important;
    border-radius: 99px;
    border: 1.5px solid var(--ficbot-accent);
    color: var(--ficbot-accent);
    background: var(--ficbot-white);
    cursor: pointer;
    transition: background .15s, color .15s;
    line-height: 1.2;
    text-align: left;
}
#ficbot-container .ficbot-suggestion:hover { background: var(--ficbot-accent); color: var(--ficbot-white); }

/* Entrada de texto */
#ficbot-input-area {
    display: flex; align-items: center; gap: 8px;
    padding: 10px 12px;
    border-top: 1px solid var(--ficbot-gray-200);
    background: var(--ficbot-white);
}
#ficbot-input {
    flex: 1; min-width: 0;
    border: 1.5px solid var(--ficbot-gray-200);
    border-radius: 99px;
    padding: 9px 14px;
    font-size: 16px; /* 16px evita el zoom automático en iPhone */
    outline: none;
    color: var(--ficbot-gray-800);
    background: var(--ficbot-gray-50);
    transition: border-color .15s;
}
#ficbot-input:focus { border-color: var(--ficbot-accent); }
#ficbot-send {
    width: 40px; height: 40px; flex: 0 0 40px;
    border-radius: 50%;
    background: var(--ficbot-accent);
    border: none; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    color: var(--ficbot-white);
    transition: background .15s, transform .1s;
}
#ficbot-send:hover { background: var(--ficbot-accent-dark); transform: scale(1.05); }
#ficbot-send svg { width: 18px !important; height: 18px !important; }

/* Pie */
#ficbot-footer-brand {
    text-align: center;
    font-size: 11px;
    color: var(--ficbot-gray-500);
    padding: 5px 10px 8px;
    background: var(--ficbot-white);
}
#ficbot-footer-brand a { color: var(--ficbot-accent); text-decoration: none; font-weight: 600; }

/* Móvil */
@media (max-width: 480px) {
    #ficbot-container.ficbot-bottom-right { right: 12px; bottom: 16px; }
    #ficbot-container.ficbot-bottom-left  { left: 12px;  bottom: 16px; }
    #ficbot-window { width: calc(100vw - 24px); max-height: calc(100vh - 110px); max-height: calc(100dvh - 110px); }
}

@media (prefers-reduced-motion: reduce) {
    #ficbot-toggle::after, #ficbot-window, .ficbot-msg, .ficbot-typing span { animation: none !important; }
}
