/* =============================================================================
   Asistente de IA (chat) · xFútbol Total
   ============================================================================= */

:root {
    --chat-navy:   #0f1430;
    --chat-navy-2: #171e42;
    --chat-accent: #e94560;
    --chat-bot:    #1c2450;
    --chat-text:   #eef1ff;
    --chat-faint:  #9aa3c7;
}

/* Botón flotante (píldora con icono IA + etiqueta, estilo diccionario) */
.chat-fab {
    position: fixed;
    right: 24px;
    bottom: 24px;
    z-index: 1200;
    height: 48px;
    padding: 0 18px 0 15px;
    border-radius: 24px;
    border: none;
    background: linear-gradient(135deg, #ff5d78 0%, var(--chat-accent) 55%, #cf3350 100%);
    color: #fff;
    display: inline-flex;
    align-items: center;
    gap: 9px;
    cursor: pointer;
    font-family: inherit;
    box-shadow: 0 8px 22px -4px rgba(233, 69, 96, 0.6);
    transition: transform 0.25s ease, box-shadow 0.3s ease;
}
.chat-fab:hover { transform: translateY(-2px) scale(1.04); box-shadow: 0 12px 26px -6px rgba(233, 69, 96, 0.75); }
.chat-fab:active { transform: translateY(0) scale(0.99); }
.chat-fab:focus-visible { outline: 3px solid rgba(233, 69, 96, 0.4); outline-offset: 2px; }
.chat-fab.is-hidden { display: none; }

/* Icono de destellos IA (animado) */
.chat-fab-icon {
    width: 19px; height: 19px; flex-shrink: 0;
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.2));
    animation: chatFabSparkle 2.6s ease-in-out infinite;
}
@keyframes chatFabSparkle {
    0%, 100% { opacity: .95; transform: scale(1) rotate(0deg); }
    50%      { opacity: 1;   transform: scale(1.08) rotate(8deg); }
}

/* Etiqueta */
.chat-fab-label { display: inline-flex; flex-direction: column; line-height: 1.05; text-align: left; gap: 1px; }
.chat-fab-label-main { font-size: 13px; font-weight: 800; letter-spacing: .03em; }
.chat-fab-label-sub { font-size: 9px; font-weight: 700; letter-spacing: .13em; text-transform: uppercase; opacity: .85; }

/* Puntito de notificación con pulso */
.chat-fab::after {
    content: "";
    position: absolute;
    top: -5px; right: -5px;
    width: 18px; height: 18px;
    background: #1c3278;
    border: 2px solid #fff;
    border-radius: 50%;
    animation: chatFabPulse 2.4s ease-in-out infinite;
    pointer-events: none;
}
@keyframes chatFabPulse {
    0%, 100% { transform: scale(1);    box-shadow: 0 0 0 0 rgba(28, 50, 120, .5); }
    60%      { transform: scale(1.12); box-shadow: 0 0 0 9px rgba(28, 50, 120, 0); }
}
@media (prefers-reduced-motion: reduce) {
    .chat-fab::after, .chat-fab-icon { animation: none; }
}

/* Panel */
.chat-panel {
    position: fixed;
    right: 20px;
    bottom: 20px;
    width: 380px;
    max-width: calc(100vw - 32px);
    height: 560px;
    max-height: calc(100vh - 40px);
    background: var(--chat-navy);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 18px;
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: 1300;
    opacity: 0;
    transform: translateY(16px) scale(0.98);
    pointer-events: none;
    transition: opacity 0.18s ease, transform 0.18s ease;
}
.chat-panel.is-open {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

/* Cabecera */
.chat-head {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    background: var(--chat-navy-2);
    border-bottom: 1px solid rgba(255, 255, 255, 0.07);
    border-top: 4px solid var(--chat-accent);
}
.chat-head-avatar {
    width: 38px; height: 38px;
    border-radius: 50%;
    background: var(--chat-accent);
    color: #fff;
    display: flex; align-items: center; justify-content: center;
    flex: none;
}
.chat-head-avatar svg { width: 22px; height: 22px; }
.chat-head-info { display: flex; flex-direction: column; line-height: 1.2; flex: 1; }
.chat-head-name { font-weight: 800; color: var(--chat-text); font-size: 1rem; }
.chat-head-sub { font-size: 0.78rem; color: var(--chat-faint); display: flex; align-items: center; gap: 6px; }
.chat-dot { width: 8px; height: 8px; border-radius: 50%; background: #37d67a; box-shadow: 0 0 0 3px rgba(55, 214, 122, 0.2); }
.chat-close {
    background: transparent; border: none; color: var(--chat-faint);
    cursor: pointer; padding: 4px; border-radius: 8px; display: flex;
}
.chat-close:hover { color: #fff; background: rgba(255,255,255,0.08); }
.chat-close svg { width: 20px; height: 20px; }

/* Cuerpo (mensajes) */
.chat-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    scroll-behavior: smooth;
}
.chat-msg { display: flex; }
.chat-msg--user { justify-content: flex-end; }
.chat-bubble {
    max-width: 82%;
    padding: 10px 14px;
    border-radius: 14px;
    font-size: 0.92rem;
    line-height: 1.45;
    color: var(--chat-text);
    white-space: pre-wrap;
    word-wrap: break-word;
}
.chat-msg--bot .chat-bubble {
    background: var(--chat-bot);
    border-bottom-left-radius: 4px;
}
.chat-msg--user .chat-bubble {
    background: var(--chat-accent);
    color: #fff;
    border-bottom-right-radius: 4px;
}
.chat-bubble a { color: #ffd0da; }

/* Indicador "escribiendo" */
.chat-typing { display: inline-flex; gap: 4px; align-items: center; }
.chat-typing span {
    width: 7px; height: 7px; border-radius: 50%; background: var(--chat-faint);
    animation: chat-bounce 1.2s infinite ease-in-out;
}
.chat-typing span:nth-child(2) { animation-delay: 0.15s; }
.chat-typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes chat-bounce { 0%,80%,100% { transform: translateY(0); opacity: 0.5; } 40% { transform: translateY(-5px); opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .chat-typing span { animation: none; } }

/* Entrada */
.chat-input {
    display: flex;
    gap: 8px;
    padding: 12px;
    border-top: 1px solid rgba(255, 255, 255, 0.07);
    background: var(--chat-navy-2);
}
.chat-input input {
    flex: 1;
    background: var(--chat-navy);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 12px;
    padding: 10px 14px;
    color: var(--chat-text);
    font-size: 0.92rem;
    outline: none;
}
.chat-input input:focus { border-color: var(--chat-accent); }
.chat-input button {
    flex: none;
    width: 44px; height: 44px;
    border: none; border-radius: 12px;
    background: var(--chat-accent); color: #fff;
    cursor: pointer; display: flex; align-items: center; justify-content: center;
}
.chat-input button:disabled { opacity: 0.5; cursor: default; }
.chat-input button svg { width: 20px; height: 20px; }

/* Móvil: panel a pantalla casi completa */
@media (max-width: 520px) {
    .chat-panel {
        right: 0; bottom: 0; left: 0;
        width: 100%; max-width: 100%;
        height: 88vh; max-height: 88vh;
        border-radius: 18px 18px 0 0;
    }
    .chat-fab { right: 16px; bottom: 16px; }
}
