/* TG Bot CTA — botón flotante y panel (100% responsivo) */

.tg-bot-cta {
    --tg-primary: #4f46e5;
    --tg-primary2: #9333ea;
    --tg-bg: #ffffff;
    --tg-text: #1f2937;
    --tg-muted: #6b7280;
    --tg-border: #e5e7eb;
    --tg-ok: #16a34a;
    --tg-err: #dc2626;
    position: fixed;
    right: 18px;
    bottom: 18px;
    z-index: 99990;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
}

/* ── Botón flotante ─────────────────────────────────────── */
.tg-bot-fab {
    width: 60px;
    height: 60px;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    font-size: 26px;
    color: #fff;
    background: linear-gradient(135deg, var(--tg-primary), var(--tg-primary2));
    box-shadow: 0 8px 24px rgba(79, 70, 229, 0.45);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    animation: tg-bot-pulse 2.4s infinite;
}
.tg-bot-fab:hover {
    transform: scale(1.08);
    box-shadow: 0 12px 30px rgba(79, 70, 229, 0.55);
}
@keyframes tg-bot-pulse {
    0%   { box-shadow: 0 8px 24px rgba(79, 70, 229, 0.45), 0 0 0 0 rgba(147, 51, 234, 0.45); }
    70%  { box-shadow: 0 8px 24px rgba(79, 70, 229, 0.45), 0 0 0 16px rgba(147, 51, 234, 0); }
    100% { box-shadow: 0 8px 24px rgba(79, 70, 229, 0.45), 0 0 0 0 rgba(147, 51, 234, 0); }
}

/* ── Panel ──────────────────────────────────────────────── */
.tg-bot-panel {
    position: absolute;
    right: 0;
    bottom: 74px;
    width: 360px;
    max-width: calc(100vw - 24px);
    background: var(--tg-bg);
    border-radius: 18px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.25);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    max-height: min(640px, calc(100vh - 110px));
}
.tg-bot-panel[hidden] { display: none; }

.tg-bot-head {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 16px;
    color: #fff;
    background: linear-gradient(135deg, var(--tg-primary), var(--tg-primary2));
}
.tg-bot-avatar { font-size: 30px; line-height: 1; }
.tg-bot-head strong { display: block; font-size: 15px; }
.tg-bot-head small { display: block; font-size: 12px; opacity: 0.9; }
.tg-bot-close {
    margin-left: auto;
    border: none;
    background: rgba(255, 255, 255, 0.18);
    color: #fff;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
}
.tg-bot-close:hover { background: rgba(255, 255, 255, 0.3); }

.tg-bot-body {
    padding: 14px;
    overflow-y: auto;
}

/* ── Chips (primer filtro, sin IA) ───────────────────────── */
.tg-bot-chips { display: flex; flex-direction: column; gap: 8px; }
.tg-bot-chip {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    text-align: left;
    padding: 10px 12px;
    border: 1px solid var(--tg-border);
    border-radius: 12px;
    background: #fafafa;
    cursor: pointer;
    transition: transform 0.12s ease, border-color 0.12s ease, box-shadow 0.12s ease;
}
.tg-bot-chip:hover {
    transform: translateY(-1px);
    border-color: var(--tg-primary);
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.15);
}
.tg-bot-chip.loading { opacity: 0.6; pointer-events: none; }
.tg-bot-chip-icon { font-size: 22px; }
.tg-bot-chip-txt strong { display: block; font-size: 14px; color: var(--tg-text); }
.tg-bot-chip-txt small { display: block; font-size: 12px; color: var(--tg-muted); }

/* ── Divisor ────────────────────────────────────────────── */
.tg-bot-divider {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 14px 0 10px;
    color: var(--tg-muted);
    font-size: 12px;
}
.tg-bot-divider::before,
.tg-bot-divider::after {
    content: "";
    flex: 1;
    height: 1px;
    background: var(--tg-border);
}

/* ── Formulario texto libre ─────────────────────────────── */
.tg-bot-form { display: flex; gap: 8px; }
.tg-bot-form input {
    flex: 1;
    min-width: 0;
    padding: 10px 12px;
    border: 1px solid var(--tg-border);
    border-radius: 10px;
    font-size: 14px;
    outline: none;
}
.tg-bot-form input:focus { border-color: var(--tg-primary); }
#tg-bot-send {
    width: 42px;
    height: 42px;
    border: none;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--tg-primary), var(--tg-primary2));
    color: #fff;
    font-size: 18px;
    cursor: pointer;
    flex-shrink: 0;
}
#tg-bot-send:disabled { opacity: 0.6; cursor: wait; }

/* ── Mensajes ───────────────────────────────────────────── */
.tg-bot-msg {
    margin-top: 10px;
    padding: 10px 12px;
    border-radius: 10px;
    font-size: 13px;
    background: #f3f4f6;
    color: var(--tg-text);
}
.tg-bot-msg.ok { background: #ecfdf5; color: var(--tg-ok); }
.tg-bot-msg.err { background: #fef2f2; color: var(--tg-err); }
.tg-bot-dots i {
    animation: tg-bot-blink 1.2s infinite;
    font-style: normal;
}
.tg-bot-dots i:nth-child(2) { animation-delay: 0.2s; }
.tg-bot-dots i:nth-child(3) { animation-delay: 0.4s; }
@keyframes tg-bot-blink { 0%, 100% { opacity: 0.2; } 50% { opacity: 1; } }

.tg-bot-foot {
    padding: 8px 14px;
    text-align: center;
    font-size: 11px;
    color: var(--tg-muted);
    border-top: 1px solid var(--tg-border);
}

/* ── Responsivo: móvil = bottom sheet ────────────────────── */
@media (max-width: 560px) {
    .tg-bot-cta { right: 12px; bottom: 12px; }
    .tg-bot-fab { width: 56px; height: 56px; font-size: 24px; }
    .tg-bot-panel {
        position: fixed;
        left: 8px;
        right: 8px;
        bottom: 8px;
        width: auto;
        max-width: none;
        border-radius: 18px 18px 12px 12px;
        max-height: 82vh;
    }
}
@media (prefers-reduced-motion: reduce) {
    .tg-bot-fab { animation: none; }
}

/* ── Burbuja de saludo ──────────────────────────────────── */
.tg-bot-teaser {
    position: absolute;
    right: 4px;
    bottom: 76px;
    background: #fff;
    color: var(--tg-text);
    border: 1px solid var(--tg-border);
    border-radius: 16px 16px 4px 16px;
    padding: 10px 14px;
    font-size: 13.5px;
    font-weight: 600;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.18);
    max-width: 230px;
    cursor: pointer;
    animation: tg-bot-teaser-in 0.35s ease;
    white-space: nowrap;
}
.tg-bot-teaser[hidden] { display: none; }
@keyframes tg-bot-teaser-in {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}
@media (max-width: 560px) {
    .tg-bot-teaser { max-width: calc(100vw - 80px); }
}

/* ── Diálogo (chat) ─────────────────────────────────────── */
.tg-bot-chat {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 10px;
    max-height: 240px;
    overflow-y: auto;
    padding: 2px;
}
.tg-bot-bubble {
    max-width: 85%;
    padding: 9px 12px;
    border-radius: 14px;
    font-size: 13.5px;
    line-height: 1.4;
    word-wrap: break-word;
}
.tg-bot-bubble.bot {
    align-self: flex-start;
    background: #f1f0ff;
    border-bottom-left-radius: 4px;
    color: var(--tg-text);
}
.tg-bot-bubble.user {
    align-self: flex-end;
    background: linear-gradient(135deg, var(--tg-primary), var(--tg-primary2));
    border-bottom-right-radius: 4px;
    color: #fff;
}
.tg-bot-bubble.typing { color: var(--tg-muted); }

.tg-bot-cta-wa {
    align-self: center;
    margin-top: 4px;
    padding: 11px 16px;
    border: none;
    border-radius: 24px;
    background: #25D366;
    color: #fff;
    font-weight: 700;
    font-size: 14px;
    cursor: pointer;
    box-shadow: 0 4px 14px rgba(37, 211, 102, 0.4);
    transition: transform 0.12s ease;
}
.tg-bot-cta-wa:hover { transform: scale(1.03); }

.tg-bot-ya {
    display: block;
    margin: 8px auto 0;
    border: none;
    background: none;
    color: var(--tg-primary);
    font-size: 12.5px;
    font-weight: 600;
    cursor: pointer;
    text-decoration: underline;
}
.tg-bot-ya:hover { color: var(--tg-primary2); }

.tg-bot-back {
    display: block;
    margin: 0 0 8px;
    border: none;
    background: none;
    color: var(--tg-muted);
    font-size: 12px;
    cursor: pointer;
}
.tg-bot-back:hover { color: var(--tg-text); }


/* v2.2.0: la burbuja ahora es clicable (abre el panel) */
.tg-bot-teaser { cursor: pointer; }

/* ── v2.4.0: pildora junto al FAB (variante B de entry_mechanic_v1) ── */
.tg-bot-pill {
    position: absolute;
    right: 70px;
    bottom: 34px;
    background: #fff;
    color: var(--tg-primary);
    border: 1px solid var(--tg-primary);
    border-radius: 20px;
    padding: 8px 14px;
    font-size: 13px;
    font-weight: 700;
    box-shadow: 0 6px 18px rgba(79, 70, 229, 0.25);
    cursor: pointer;
    white-space: nowrap;
    animation: tg-bot-teaser-in 0.35s ease;
}
.tg-bot-pill:hover { background: var(--tg-primary); color: #fff; }
.tg-bot-pill[hidden] { display: none; }
@media (max-width: 560px) {
    .tg-bot-pill { right: 66px; bottom: 28px; max-width: calc(100vw - 90px); overflow: hidden; text-overflow: ellipsis; }
}

/* ── v2.4.0: bloque inline de chips (prueba inline_cta_v1) ────────── */
.tg-inline-cta {
    margin: 24px 0;
    padding: 16px;
    border: 1px solid var(--tg-border);
    border-left: 4px solid var(--tg-primary);
    border-radius: 12px;
    background: #fafbff;
}
.tg-inline-cta[hidden] { display: none; }
.tg-inline-cta-titulo {
    margin: 0 0 10px;
    font-size: 15px;
    font-weight: 700;
    color: var(--tg-text);
}
.tg-inline-cta-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.tg-inline-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border: 1px solid var(--tg-border);
    border-radius: 10px;
    background: #fff;
    text-decoration: none;
    color: var(--tg-text);
    transition: border-color 0.12s ease, box-shadow 0.12s ease;
}
.tg-inline-chip:hover { border-color: var(--tg-primary); box-shadow: 0 4px 12px rgba(79, 70, 229, 0.15); }
.tg-inline-chip-icon { font-size: 20px; }
.tg-inline-chip-txt strong { display: block; font-size: 13.5px; color: var(--tg-text); }
.tg-inline-chip-txt small { display: block; font-size: 11.5px; color: var(--tg-muted); }

/* ── v2.4.0: captura de email en panel (prueba panel_email_v1) ────── */
.tg-bot-email {
    margin-top: 12px;
    padding: 12px;
    border: 1px dashed var(--tg-border);
    border-radius: 10px;
    background: #fafbff;
    font-size: 13px;
}
.tg-bot-email[hidden] { display: none; }
.tg-bot-email p { margin: 0 0 8px; color: var(--tg-text); }
.tg-bot-email form { display: flex; gap: 8px; }
.tg-bot-email input {
    flex: 1;
    min-width: 0;
    padding: 9px 12px;
    border: 1px solid var(--tg-border);
    border-radius: 8px;
    font-size: 13.5px;
    outline: none;
}
.tg-bot-email input:focus { border-color: var(--tg-primary); }
.tg-bot-email button {
    border: none;
    border-radius: 8px;
    background: linear-gradient(135deg, var(--tg-primary), var(--tg-primary2));
    color: #fff;
    font-size: 13px;
    font-weight: 600;
    padding: 0 14px;
    cursor: pointer;
    flex-shrink: 0;
}
.tg-bot-email .tg-bot-msg { margin-top: 8px; }
