/**
 * Widget Flotante del Chatbot de Soporte con IA - FiebreParley.com (Fase 1 / Nivel 1)
 * Namespace exclusivo: .fpsoporte-* (no colisiona con Blueprint screen.css, main.css ni publico.css)
 */

@media print {
    .fpsoporte-root,
    .fpsoporte-launcher,
    .fpsoporte-fab,
    .fpsoporte-panel {
        display: none !important;
    }
}

@media screen {
    .fpsoporte-root,
    .fpsoporte-root *,
    .fpsoporte-root *:before,
    .fpsoporte-root *:after {
        box-sizing: border-box;
    }

    .fpsoporte-root {
        font-family: "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
        font-size: 14px;
        line-height: 1.45;
        color: #eaf2fb;
        -webkit-font-smoothing: antialiased;
    }

    /* Botón flotante lanzador (por encima de la barra #calculadora) */
    .fpsoporte-launcher,
    .fpsoporte-fab {
        position: fixed;
        right: 18px;
        bottom: 78px;
        z-index: 9998;
        display: -webkit-inline-flex;
        display: inline-flex;
        -webkit-align-items: center;
        align-items: center;
        gap: 9px;
        min-height: 46px;
        padding: 8px 16px 8px 12px;
        background: linear-gradient(135deg, #03162a 0%, #0b2f66 100%);
        color: #eaf2fb;
        border: 1.5px solid #3cbae3;
        border-radius: 999px;
        box-shadow: 0 8px 24px rgba(3, 22, 42, 0.55), 0 0 0 1px rgba(60, 186, 227, 0.2);
        cursor: pointer;
        font-family: inherit;
        font-size: 14px;
        font-weight: 700;
        letter-spacing: 0.2px;
        text-decoration: none;
        transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease, background-color 0.18s ease;
        user-select: none;
        -webkit-user-select: none;
    }

    .fpsoporte-launcher:hover,
    .fpsoporte-fab:hover {
        transform: translateY(-2px);
        border-color: #9be15d;
        box-shadow: 0 12px 28px rgba(3, 22, 42, 0.7), 0 0 12px rgba(60, 186, 227, 0.35);
    }

    .fpsoporte-launcher:active,
    .fpsoporte-fab:active {
        transform: translateY(0) scale(0.98);
    }

    .fpsoporte-launcher:focus-visible,
    .fpsoporte-fab:focus-visible {
        outline: 2px solid #9be15d;
        outline-offset: 2px;
    }

    .fpsoporte-launcher-icon {
        position: relative;
        display: -webkit-inline-flex;
        display: inline-flex;
        -webkit-align-items: center;
        align-items: center;
        -webkit-justify-content: center;
        justify-content: center;
        width: 28px;
        height: 28px;
        border-radius: 50%;
        background: rgba(60, 186, 227, 0.18);
        color: #3cbae3;
        flex-shrink: 0;
    }

    .fpsoporte-launcher-icon svg {
        width: 18px;
        height: 18px;
        display: block;
        fill: currentColor;
    }

    .fpsoporte-launcher-dot {
        position: absolute;
        top: -1px;
        right: -1px;
        width: 9px;
        height: 9px;
        border-radius: 50%;
        background: #9be15d;
        border: 1.5px solid #03162a;
        box-shadow: 0 0 6px rgba(155, 225, 93, 0.85);
    }

    .fpsoporte-launcher-label {
        color: #eaf2fb;
        font-weight: 700;
        font-size: 14px;
        line-height: 1;
        white-space: nowrap;
    }

    /* Panel principal del chat */
    .fpsoporte-panel {
        position: fixed;
        right: 18px;
        bottom: 134px;
        z-index: 9999;
        width: 385px;
        max-width: calc(100vw - 24px);
        height: 550px;
        max-height: calc(100vh - 150px);
        display: none;
        -webkit-flex-direction: column;
        flex-direction: column;
        background: linear-gradient(180deg, rgba(3, 22, 42, 0.97) 0%, rgba(10, 34, 57, 0.98) 100%);
        background-color: #03162a;
        -webkit-backdrop-filter: blur(12px);
        backdrop-filter: blur(12px);
        border: 1px solid rgba(60, 186, 227, 0.35);
        border-radius: 14px;
        box-shadow: 0 20px 50px rgba(2, 10, 24, 0.72), 0 0 0 1px rgba(60, 186, 227, 0.15);
        overflow: hidden;
        opacity: 0;
        transform: translateY(10px) scale(0.98);
        transition: opacity 0.18s ease, transform 0.18s ease;
    }

    .fpsoporte-panel.fpsoporte-abierto {
        display: -webkit-flex;
        display: flex;
        opacity: 1;
        transform: translateY(0) scale(1);
    }

    /* Cabecera del panel */
    .fpsoporte-header {
        display: -webkit-flex;
        display: flex;
        -webkit-align-items: center;
        align-items: center;
        -webkit-justify-content: space-between;
        justify-content: space-between;
        gap: 8px;
        padding: 12px 14px;
        background: linear-gradient(90deg, #04132c 0%, #0b2f66 100%);
        border-bottom: 1px solid rgba(60, 186, 227, 0.28);
        flex-shrink: 0;
    }

    .fpsoporte-header-info {
        display: -webkit-flex;
        display: flex;
        -webkit-flex-direction: column;
        flex-direction: column;
        min-width: 0;
        gap: 3px;
    }

    .fpsoporte-header-title-row {
        display: -webkit-flex;
        display: flex;
        -webkit-align-items: center;
        align-items: center;
        gap: 7px;
        flex-wrap: wrap;
    }

    .fpsoporte-status-dot {
        width: 8px;
        height: 8px;
        border-radius: 50%;
        background: #9be15d;
        box-shadow: 0 0 6px rgba(155, 225, 93, 0.8);
        flex-shrink: 0;
    }

    .fpsoporte-header-title {
        margin: 0;
        font-size: 14px;
        font-weight: 700;
        color: #ffffff;
        letter-spacing: 0.2px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .fpsoporte-rol-badge {
        display: inline-block;
        padding: 2px 8px;
        border-radius: 999px;
        background: rgba(60, 186, 227, 0.18);
        border: 1px solid rgba(60, 186, 227, 0.45);
        color: #3cbae3;
        font-size: 11px;
        font-weight: 700;
        line-height: 1.25;
        white-space: nowrap;
    }

    .fpsoporte-header-sub {
        font-size: 11px;
        color: #b6c8dd;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .fpsoporte-header-actions {
        display: -webkit-flex;
        display: flex;
        -webkit-align-items: center;
        align-items: center;
        gap: 6px;
        flex-shrink: 0;
    }

    .fpsoporte-btn-reset {
        display: -webkit-inline-flex;
        display: inline-flex;
        -webkit-align-items: center;
        align-items: center;
        -webkit-justify-content: center;
        justify-content: center;
        min-height: 32px;
        padding: 4px 9px;
        background: rgba(255, 255, 255, 0.08);
        color: #eaf2fb;
        border: 1px solid rgba(60, 186, 227, 0.35);
        border-radius: 8px;
        font-family: inherit;
        font-size: 11px;
        font-weight: 600;
        cursor: pointer;
        transition: background-color 0.15s ease, border-color 0.15s ease;
        white-space: nowrap;
    }

    .fpsoporte-btn-reset:hover {
        background: rgba(60, 186, 227, 0.2);
        border-color: #3cbae3;
    }

    .fpsoporte-btn-close {
        display: -webkit-inline-flex;
        display: inline-flex;
        -webkit-align-items: center;
        align-items: center;
        -webkit-justify-content: center;
        justify-content: center;
        width: 32px;
        height: 32px;
        padding: 0;
        background: rgba(255, 255, 255, 0.08);
        color: #eaf2fb;
        border: 1px solid rgba(255, 255, 255, 0.16);
        border-radius: 8px;
        font-family: inherit;
        font-size: 19px;
        font-weight: 700;
        line-height: 1;
        cursor: pointer;
        transition: background-color 0.15s ease, color 0.15s ease;
    }

    .fpsoporte-btn-close:hover {
        background: rgba(239, 68, 68, 0.25);
        color: #ffffff;
        border-color: rgba(239, 68, 68, 0.5);
    }

    .fpsoporte-btn-reset:focus-visible,
    .fpsoporte-btn-close:focus-visible {
        outline: 2px solid #3cbae3;
        outline-offset: 2px;
    }

    /* Banner preventivo ámbar cuando ventas_habilitadas == false */
    .fpsoporte-alerta-ventas {
        display: none;
        padding: 9px 12px;
        background: rgba(245, 158, 11, 0.16);
        border-bottom: 1px solid rgba(245, 158, 11, 0.45);
        color: #fde68a;
        font-size: 12px;
        line-height: 1.38;
        flex-shrink: 0;
    }

    .fpsoporte-alerta-ventas.fpsoporte-visible {
        display: block;
    }

    .fpsoporte-alerta-ventas strong {
        color: #f59e0b;
        font-weight: 700;
    }

    /* Área scrollable de mensajes */
    .fpsoporte-mensajes {
        -webkit-flex: 1 1 auto;
        flex: 1 1 auto;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        padding: 12px 14px;
        display: -webkit-flex;
        display: flex;
        -webkit-flex-direction: column;
        flex-direction: column;
        gap: 10px;
        background: #0a2239;
    }

    .fpsoporte-msg {
        max-width: 90%;
        padding: 10px 12px;
        border-radius: 12px;
        font-size: 13px;
        line-height: 1.48;
        word-wrap: break-word;
        overflow-wrap: break-word;
    }

    .fpsoporte-msg-asistente {
        -webkit-align-self: flex-start;
        align-self: flex-start;
        background: #04132c;
        color: #eaf2fb;
        border: 1px solid rgba(60, 186, 227, 0.25);
        border-top-left-radius: 4px;
    }

    .fpsoporte-msg-usuario {
        -webkit-align-self: flex-end;
        align-self: flex-end;
        background: linear-gradient(135deg, #114e8d 0%, #0b2f66 100%);
        color: #ffffff;
        border: 1px solid rgba(60, 186, 227, 0.45);
        border-top-right-radius: 4px;
    }

    .fpsoporte-msg p {
        margin: 0 0 6px 0;
    }

    .fpsoporte-msg p:last-child {
        margin-bottom: 0;
    }

    .fpsoporte-msg strong {
        color: #9be15d;
        font-weight: 700;
    }

    .fpsoporte-msg-usuario strong {
        color: #ffffff;
    }

    .fpsoporte-lista-pasos {
        margin: 6px 0;
        padding-left: 18px;
    }

    .fpsoporte-lista-pasos li {
        margin-bottom: 4px;
    }

    .fpsoporte-inline-link {
        color: #3cbae3;
        text-decoration: underline;
        font-weight: 600;
    }

    .fpsoporte-inline-link:hover {
        color: #9be15d;
    }

    /* Botón/enlace inline de ubicación en el menú (.fpsoporte-menu-pill) y código limpio (.fpsoporte-code) */
    .fpsoporte-menu-pill {
        display: -webkit-inline-flex;
        display: inline-flex;
        -webkit-align-items: center;
        align-items: center;
        gap: 4px;
        padding: 2px 9px;
        margin: 1px 2px;
        border-radius: 6px;
        background: rgba(60, 186, 227, 0.16);
        border: 1px solid rgba(60, 186, 227, 0.42);
        color: #7dd3fc !important;
        font-weight: 600;
        font-size: 12.5px;
        text-decoration: none !important;
        transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
    }

    .fpsoporte-menu-pill:hover {
        background: rgba(60, 186, 227, 0.28);
        border-color: #9be15d;
        color: #ffffff !important;
    }

    .fpsoporte-code {
        display: inline-block;
        padding: 1px 6px;
        margin: 0 1px;
        border-radius: 4px;
        background: rgba(255, 255, 255, 0.1);
        border: 1px solid rgba(255, 255, 255, 0.16);
        color: #fde68a;
        font-family: inherit;
        font-size: 12px;
        font-weight: 600;
    }

    /* Píldoras de acción interna (enlaces devueltos por el backend) */
    .fpsoporte-acciones {
        display: -webkit-flex;
        display: flex;
        -webkit-flex-wrap: wrap;
        flex-wrap: wrap;
        gap: 6px;
        margin-top: 8px;
    }

    .fpsoporte-accion-pill {
        display: -webkit-inline-flex;
        display: inline-flex;
        -webkit-align-items: center;
        align-items: center;
        gap: 5px;
        min-height: 30px;
        padding: 4px 10px;
        background: rgba(60, 186, 227, 0.14);
        color: #3cbae3 !important;
        border: 1px solid rgba(60, 186, 227, 0.45);
        border-radius: 999px;
        font-size: 12px;
        font-weight: 700;
        text-decoration: none !important;
        transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
    }

    .fpsoporte-accion-pill:hover {
        background: #3cbae3;
        color: #03162a !important;
        border-color: #3cbae3;
    }

    /* Botones de calificación (Feedback Sí / No) */
    .fpsoporte-feedback {
        display: -webkit-flex;
        display: flex;
        -webkit-align-items: center;
        align-items: center;
        -webkit-justify-content: space-between;
        justify-content: space-between;
        gap: 8px;
        margin-top: 8px;
        padding-top: 6px;
        border-top: 1px solid rgba(255, 255, 255, 0.08);
        font-size: 11px;
        color: #b6c8dd;
    }

    .fpsoporte-feedback-btns {
        display: -webkit-inline-flex;
        display: inline-flex;
        gap: 5px;
    }

    .fpsoporte-feedback-btn {
        padding: 2px 8px;
        background: rgba(255, 255, 255, 0.06);
        color: #eaf2fb;
        border: 1px solid rgba(255, 255, 255, 0.15);
        border-radius: 6px;
        font-family: inherit;
        font-size: 11px;
        cursor: pointer;
        transition: background-color 0.15s ease, border-color 0.15s ease;
    }

    .fpsoporte-feedback-btn:hover {
        background: rgba(60, 186, 227, 0.2);
        border-color: #3cbae3;
    }

    .fpsoporte-feedback-btn.fpsoporte-activo {
        background: rgba(155, 225, 93, 0.22);
        border-color: #9be15d;
        color: #9be15d;
        font-weight: 700;
    }

    /* Tarjeta de escalamiento a soporte humano */
    .fpsoporte-escalamiento-card {
        margin-top: 8px;
        padding: 10px 12px;
        background: rgba(245, 158, 11, 0.12);
        border: 1px solid rgba(245, 158, 11, 0.55);
        border-radius: 10px;
        color: #eaf2fb;
        font-size: 12px;
    }

    .fpsoporte-escalamiento-title {
        margin: 0 0 6px 0;
        color: #f59e0b;
        font-size: 12.5px;
        font-weight: 700;
    }

    .fpsoporte-escalamiento-desc {
        margin: 0 0 8px 0;
        color: #fde68a;
        font-size: 11.5px;
    }

    .fpsoporte-escalamiento-links {
        display: -webkit-flex;
        display: flex;
        -webkit-flex-direction: column;
        flex-direction: column;
        gap: 6px;
    }

    .fpsoporte-btn-wa,
    .fpsoporte-btn-canal {
        display: -webkit-inline-flex;
        display: inline-flex;
        -webkit-align-items: center;
        align-items: center;
        -webkit-justify-content: center;
        justify-content: center;
        min-height: 34px;
        padding: 6px 10px;
        border-radius: 8px;
        font-size: 12px;
        font-weight: 700;
        text-align: center;
        text-decoration: none !important;
        transition: opacity 0.15s ease, transform 0.15s ease;
    }

    .fpsoporte-btn-wa {
        background: #25d366;
        color: #04132c !important;
        border: 1px solid #25d366;
    }

    .fpsoporte-btn-wa:hover {
        opacity: 0.92;
    }

    .fpsoporte-btn-canal {
        background: rgba(60, 186, 227, 0.14);
        color: #eaf2fb !important;
        border: 1px solid rgba(60, 186, 227, 0.4);
    }

    .fpsoporte-btn-canal:hover {
        background: rgba(60, 186, 227, 0.26);
    }

    /* Indicador animado de escritura */
    .fpsoporte-typing {
        display: none;
        -webkit-align-items: center;
        align-items: center;
        gap: 8px;
        padding: 6px 14px;
        background: #0a2239;
        color: #3cbae3;
        font-size: 12px;
        font-style: italic;
        border-top: 1px solid rgba(60, 186, 227, 0.14);
        flex-shrink: 0;
    }

    .fpsoporte-typing.fpsoporte-visible {
        display: -webkit-flex;
        display: flex;
    }

    .fpsoporte-dots {
        display: -webkit-inline-flex;
        display: inline-flex;
        gap: 4px;
    }

    .fpsoporte-dots span {
        width: 6px;
        height: 6px;
        border-radius: 50%;
        background: #3cbae3;
        animation: fpsoportePulse 1.2s infinite ease-in-out;
    }

    .fpsoporte-dots span:nth-child(2) {
        animation-delay: 0.2s;
    }

    .fpsoporte-dots span:nth-child(3) {
        animation-delay: 0.4s;
    }

    @keyframes fpsoportePulse {
        0%, 80%, 100% {
            opacity: 0.3;
            transform: scale(0.8);
        }
        40% {
            opacity: 1;
            transform: scale(1.1);
        }
    }

    /* Barra de chips de preguntas frecuentes sugeridas (franja horizontal de 1 sola fila deslizable) */
    .fpsoporte-chips {
        display: -webkit-flex;
        display: flex;
        -webkit-flex-wrap: nowrap;
        flex-wrap: nowrap;
        gap: 6px;
        padding: 6px 12px;
        background: #061a36;
        border-top: 1px solid rgba(60, 186, 227, 0.22);
        max-height: 46px;
        overflow-x: auto;
        overflow-y: hidden;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: thin;
        scrollbar-color: rgba(60, 186, 227, 0.35) transparent;
        flex-shrink: 0;
    }

    .fpsoporte-chips::-webkit-scrollbar {
        height: 4px;
    }

    .fpsoporte-chips::-webkit-scrollbar-track {
        background: transparent;
    }

    .fpsoporte-chips::-webkit-scrollbar-thumb {
        background: rgba(60, 186, 227, 0.35);
        border-radius: 4px;
    }

    .fpsoporte-chip {
        display: -webkit-inline-flex;
        display: inline-flex;
        -webkit-align-items: center;
        align-items: center;
        white-space: nowrap;
        -webkit-flex-shrink: 0;
        flex-shrink: 0;
        padding: 5px 11px;
        background: rgba(60, 186, 227, 0.12);
        color: #eaf2fb;
        border: 1px solid rgba(60, 186, 227, 0.35);
        border-radius: 999px;
        font-family: inherit;
        font-size: 12px;
        font-weight: 600;
        line-height: 1.2;
        cursor: pointer;
        text-align: left;
        transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
    }

    .fpsoporte-chip:hover {
        background: rgba(155, 225, 93, 0.18);
        border-color: #9be15d;
        color: #ffffff;
    }

    .fpsoporte-chip:focus-visible {
        outline: 2px solid #3cbae3;
        outline-offset: 1px;
    }

    /* Pie del panel: entrada de texto y aviso legal */
    .fpsoporte-footer {
        padding: 10px 12px 8px;
        background: #03162a;
        border-top: 1px solid rgba(60, 186, 227, 0.28);
        flex-shrink: 0;
    }

    .fpsoporte-input-row {
        display: -webkit-flex;
        display: flex;
        -webkit-align-items: flex-end;
        align-items: flex-end;
        gap: 8px;
    }

    .fpsoporte-input {
        -webkit-flex: 1 1 auto;
        flex: 1 1 auto;
        min-height: 38px;
        max-height: 84px;
        padding: 8px 10px;
        background: #0a2239;
        color: #ffffff;
        border: 1px solid rgba(60, 186, 227, 0.4);
        border-radius: 10px;
        font-family: inherit;
        font-size: 13px;
        line-height: 1.35;
        resize: none;
        outline: none;
        overflow-y: hidden;
        scrollbar-width: thin;
        scrollbar-color: rgba(60, 186, 227, 0.35) transparent;
    }

    .fpsoporte-input::-webkit-scrollbar {
        width: 4px;
    }

    .fpsoporte-input::-webkit-scrollbar-button {
        display: none;
        width: 0;
        height: 0;
    }

    .fpsoporte-input::-webkit-scrollbar-track {
        background: transparent;
    }

    .fpsoporte-input::-webkit-scrollbar-thumb {
        background: rgba(60, 186, 227, 0.35);
        border-radius: 4px;
    }

    .fpsoporte-input:focus {
        border-color: #9be15d;
        box-shadow: 0 0 0 2px rgba(155, 225, 93, 0.2);
    }

    .fpsoporte-input::-webkit-input-placeholder {
        color: #8fa6c0;
    }

    .fpsoporte-input::placeholder {
        color: #8fa6c0;
    }

    .fpsoporte-btn-send {
        display: -webkit-inline-flex;
        display: inline-flex;
        -webkit-align-items: center;
        align-items: center;
        -webkit-justify-content: center;
        justify-content: center;
        min-width: 72px;
        height: 38px;
        padding: 0 14px;
        background: #9be15d;
        color: #10260a;
        border: 0;
        border-radius: 10px;
        font-family: inherit;
        font-size: 13px;
        font-weight: 700;
        cursor: pointer;
        flex-shrink: 0;
        transition: background-color 0.15s ease, opacity 0.15s ease;
    }

    .fpsoporte-btn-send:hover {
        background: #b3ee7a;
    }

    .fpsoporte-btn-send:disabled {
        opacity: 0.55;
        cursor: not-allowed;
    }

    .fpsoporte-meta-row {
        display: -webkit-flex;
        display: flex;
        -webkit-align-items: center;
        align-items: center;
        -webkit-justify-content: space-between;
        justify-content: space-between;
        gap: 6px;
        margin-top: 6px;
        font-size: 10.5px;
        color: #8fa6c0;
    }

    .fpsoporte-legal {
        line-height: 1.25;
    }

    .fpsoporte-counter {
        white-space: nowrap;
        font-variant-numeric: tabular-nums;
    }

    /* Adaptación móvil (Regla de Oro Responsive + soporte a pantallas sin .fp-resp) */
    @media (max-width: 640px) {
        .fpsoporte-launcher,
        .fpsoporte-fab {
            right: 12px;
            bottom: 74px;
            min-height: 44px;
            padding: 8px 14px 8px 10px;
        }

        .fpsoporte-panel {
            width: calc(100vw - 16px);
            max-width: none;
            left: 8px;
            right: 8px;
            bottom: 8px;
            height: 80vh;
            max-height: 82vh;
            z-index: 10000;
            border-radius: 14px;
        }

        .fpsoporte-btn-reset,
        .fpsoporte-btn-close,
        .fpsoporte-chip,
        .fpsoporte-accion-pill,
        .fpsoporte-btn-wa,
        .fpsoporte-btn-canal,
        .fpsoporte-btn-send {
            min-height: 40px;
        }

        .fpsoporte-btn-close {
            width: 40px;
            height: 40px;
        }

        .fpsoporte-input {
            font-size: 16px;
            min-height: 40px;
        }
    }
}
