/* ==========================================================================
   JP ASISTENTE LABORAL - ESTILOS DEL CHATBOT FINTECH CON IA GEMINI
   ========================================================================== */

/* Animación sutil del avatar */
@keyframes jpAvatarBreathe {
    0%, 100% {
        transform: translateY(0) scale(1);
    }
    50% {
        transform: translateY(-2px) scale(1.02);
    }
}

@keyframes jpPulseGlow {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.6);
    }
    50% {
        box-shadow: 0 0 0 6px rgba(16, 185, 129, 0);
    }
}

@keyframes jpTypingBounce {
    0%, 80%, 100% {
        transform: scale(0.6);
        opacity: 0.4;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}

@keyframes jpSlideInUp {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.96);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* ---- 1. Botón Flotante del Burrito JP ---- */
.jp-chat-launcher {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 9998;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    background: linear-gradient(135deg, rgba(20, 34, 62, 0.94) 0%, rgba(10, 20, 40, 0.96) 100%);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border: 1.5px solid rgba(56, 189, 248, 0.35);
    border-radius: 999px;
    padding: 6px 16px 6px 8px;
    color: #ffffff;
    cursor: pointer;
    box-shadow: 0 8px 25px -4px rgba(0, 0, 0, 0.6), 0 0 16px -2px rgba(56, 189, 248, 0.3);
    transition: transform 0.22s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.22s, border-color 0.22s;
    user-select: none;
}
.jp-chat-launcher:hover {
    transform: translateY(-3px) scale(1.03);
    border-color: rgba(56, 189, 248, 0.7);
    box-shadow: 0 12px 30px -4px rgba(0, 0, 0, 0.7), 0 0 24px -2px rgba(56, 189, 248, 0.5);
}
.jp-chat-launcher:active {
    transform: scale(0.97);
}

.jp-launcher-avatar-box {
    position: relative;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    overflow: visible;
    flex-shrink: 0;
}
.jp-launcher-avatar {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
    display: block;
    border: 2px solid #10b981;
    background: #000;
    animation: jpAvatarBreathe 3s ease-in-out infinite;
}
.jp-launcher-status-dot {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 12px;
    height: 12px;
    background: #10b981;
    border: 2px solid #0b172a;
    border-radius: 50%;
    animation: jpPulseGlow 2s infinite;
}
.jp-launcher-text {
    display: flex;
    flex-direction: column;
    text-align: left;
    line-height: 1.25;
}
.jp-launcher-badge {
    font-size: 0.68em;
    font-weight: 800;
    text-transform: uppercase;
    color: #38bdf8;
    letter-spacing: 0.6px;
}
.jp-launcher-title {
    font-size: 0.88em;
    font-weight: 700;
    color: #ffffff;
}

/* Ocultar el texto en pantallas muy estrechas si es necesario */
@media (max-width: 380px) {
    .jp-launcher-text {
        display: none;
    }
    .jp-chat-launcher {
        padding: 4px;
        border-radius: 50%;
    }
}

/* ---- 2. Tarjeta de Asistente IA en el Menú Principal (Opción Adicional) ---- */
.jp-home-bot-card {
    display: flex;
    align-items: center;
    gap: 14px;
    width: 100%;
    box-sizing: border-box;
    background: linear-gradient(135deg, rgba(20, 36, 68, 0.88) 0%, rgba(12, 23, 46, 0.94) 100%);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1.5px solid rgba(56, 189, 248, 0.35);
    border-left: 5px solid #38bdf8;
    border-radius: 16px;
    padding: 14px 18px;
    margin-top: 6px;
    margin-bottom: 22px;
    text-align: left;
    cursor: pointer;
    box-shadow: 0 6px 22px -3px rgba(0, 0, 0, 0.45), 0 0 16px -4px rgba(56, 189, 248, 0.25);
    transition: transform 0.22s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.22s, border-color 0.22s;
    user-select: none;
}
.jp-home-bot-card:hover {
    transform: translateY(-3px);
    border-color: rgba(56, 189, 248, 0.65);
    box-shadow: 0 12px 28px -4px rgba(0, 0, 0, 0.6), 0 0 25px -4px rgba(56, 189, 248, 0.45);
}
.jp-home-bot-card:active {
    transform: scale(0.98);
}
.jp-bot-badge-icon {
    position: relative;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    flex-shrink: 0;
}
.jp-bot-img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
    display: block;
    border: 2px solid #10b981;
    background: #000;
    box-shadow: 0 0 14px rgba(16, 185, 129, 0.3);
    animation: jpAvatarBreathe 3s ease-in-out infinite;
}
.jp-bot-pulse-dot {
    position: absolute;
    bottom: -1px;
    right: -1px;
    width: 12px;
    height: 12px;
    background: #10b981;
    border: 2px solid #0e1b34;
    border-radius: 50%;
    animation: jpPulseGlow 2s infinite;
}
.jp-bot-card-text {
    flex: 1;
    min-width: 0;
}
.jp-bot-tag {
    font-size: 0.68em;
    font-weight: 800;
    color: #38bdf8;
    letter-spacing: 0.6px;
    text-transform: uppercase;
    margin-bottom: 2px;
}
.jp-bot-card-title {
    font-size: 1em;
    font-weight: 800;
    color: #ffffff;
    line-height: 1.3;
}
.jp-bot-card-sub {
    font-size: 0.78em;
    color: #94a3b8;
    line-height: 1.3;
    margin-top: 2px;
}
.jp-bot-card-arrow {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: rgba(56, 189, 248, 0.12);
    border: 1px solid rgba(56, 189, 248, 0.25);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #38bdf8;
    flex-shrink: 0;
    transition: transform 0.2s, background 0.2s;
}
.jp-home-bot-card:hover .jp-bot-card-arrow {
    transform: translateX(3px);
    background: rgba(56, 189, 248, 0.25);
    color: #ffffff;
}

/* ---- 3. Tarjeta de Asistencia en el Resultado de la Calculadora ---- */
.jp-result-ai-card {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-top: 20px;
    background: linear-gradient(135deg, rgba(16, 32, 60, 0.85) 0%, rgba(10, 22, 44, 0.95) 100%);
    border: 1.5px solid rgba(56, 189, 248, 0.3);
    border-radius: 14px;
    padding: 14px 16px;
    box-sizing: border-box;
    box-shadow: 0 4px 16px -2px rgba(0, 0, 0, 0.35);
    text-align: left;
}
.jp-result-ai-avatar {
    position: relative;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    flex-shrink: 0;
}
.jp-result-ai-avatar img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid #10b981;
    background: #000;
}
.jp-result-ai-info {
    flex: 1;
    min-width: 0;
}
.jp-result-ai-badge {
    font-size: 0.68em;
    font-weight: 800;
    color: #38bdf8;
    text-transform: uppercase;
    letter-spacing: 0.4px;
}
.jp-result-ai-title {
    font-size: 0.92em;
    font-weight: 700;
    color: #ffffff;
    line-height: 1.3;
}
.jp-result-ai-desc {
    font-size: 0.76em;
    color: #94a3b8;
    line-height: 1.35;
}
.jp-result-ai-btn {
    background: linear-gradient(135deg, #0284c7 0%, #0369a1 100%);
    color: #ffffff;
    border: none;
    border-radius: 10px;
    padding: 8px 14px;
    font-size: 0.84em;
    font-weight: 700;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
    box-shadow: 0 4px 12px rgba(2, 132, 199, 0.35);
    transition: transform 0.18s, box-shadow 0.18s;
}
.jp-result-ai-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(2, 132, 199, 0.5);
}
.jp-result-ai-btn:active {
    transform: scale(0.97);
}
@media (max-width: 540px) {
    .jp-result-ai-card {
        flex-direction: column;
        align-items: stretch;
    }
    .jp-result-ai-avatar {
        margin: 0 auto;
    }
    .jp-result-ai-info {
        text-align: center;
    }
    .jp-result-ai-btn {
        justify-content: center;
        width: 100%;
        margin-top: 4px;
    }
}

/* ---- 4. Ventana Modal del Chatbot (Compacta y Proporcional) ---- */
.jp-chat-overlay {
    position: fixed;
    inset: 0;
    background: rgba(4, 9, 20, 0.6);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 9999;
    display: flex;
    align-items: flex-end;
    justify-content: flex-end;
    padding: 18px;
    box-sizing: border-box;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.22s ease;
}
.jp-chat-overlay.open {
    opacity: 1;
    pointer-events: auto;
}

.jp-chat-window {
    width: 100%;
    max-width: 345px;
    height: min(470px, 72vh);
    background: linear-gradient(165deg, rgba(14, 25, 48, 0.98) 0%, rgba(8, 16, 32, 0.99) 100%);
    border: 1.5px solid rgba(56, 189, 248, 0.35);
    border-radius: 18px;
    box-shadow: 0 16px 40px -8px rgba(0, 0, 0, 0.8), 0 0 25px -5px rgba(56, 189, 248, 0.22);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform: translateY(16px) scale(0.97);
    transition: transform 0.24s cubic-bezier(0.16, 1, 0.3, 1);
    box-sizing: border-box;
}
.jp-chat-overlay.open .jp-chat-window {
    transform: translateY(0) scale(1);
}

@media (max-width: 480px) {
    .jp-chat-overlay {
        padding: 12px;
        align-items: flex-end;
        justify-content: center;
    }
    .jp-chat-window {
        max-width: min(350px, 100%);
        height: min(480px, 75vh);
        border-radius: 18px;
    }
}

/* Cabecera del Chat */
.jp-chat-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    background: rgba(20, 36, 68, 0.75);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    flex-shrink: 0;
}
.jp-chat-header-avatar {
    position: relative;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    flex-shrink: 0;
}
.jp-chat-header-avatar img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid #10b981;
    background: #000;
    animation: jpAvatarBreathe 3s ease-in-out infinite;
}
.jp-chat-header-info {
    flex: 1;
    min-width: 0;
}
.jp-chat-header-title {
    font-size: 0.88em;
    font-weight: 800;
    color: #ffffff;
    display: flex;
    align-items: center;
    gap: 6px;
    line-height: 1.2;
}
.jp-chat-header-status {
    font-size: 0.7em;
    color: #34d399;
    display: flex;
    align-items: center;
    gap: 4px;
    margin-top: 1px;
}
.jp-chat-header-actions {
    display: flex;
    align-items: center;
    gap: 5px;
}
.jp-chat-head-btn {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 7px;
    color: #cbd5e1;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.18s, color 0.18s;
}
.jp-chat-head-btn:hover {
    background: rgba(255, 255, 255, 0.18);
    color: #ffffff;
}

/* Banner de advertencia de conectividad */
.jp-chat-offline-banner {
    display: none;
    background: #7f1d1d;
    color: #fecaca;
    font-size: 0.76em;
    padding: 8px 14px;
    text-align: center;
    border-bottom: 1px solid #991b1b;
}
.jp-chat-offline-banner.visible {
    display: block;
}

/* Cuerpo de mensajes */
.jp-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    scroll-behavior: smooth;
    box-sizing: border-box;
}
.jp-chat-messages::-webkit-scrollbar {
    width: 6px;
}
.jp-chat-messages::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 3px;
}

/* Mensaje individual */
.jp-msg {
    display: flex;
    gap: 10px;
    max-width: 88%;
    animation: jpSlideInUp 0.25s ease backwards;
}
.jp-msg.user {
    align-self: flex-end;
    flex-direction: row-reverse;
}
.jp-msg.bot {
    align-self: flex-start;
}

.jp-msg-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    flex-shrink: 0;
    overflow: hidden;
    border: 1.5px solid #10b981;
    background: #000;
}
.jp-msg-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.jp-msg-bubble {
    padding: 11px 14px;
    border-radius: 14px;
    font-size: 0.88em;
    line-height: 1.48;
    word-break: break-word;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
}
.jp-msg.user .jp-msg-bubble {
    background: linear-gradient(135deg, #0284c7 0%, #0369a1 100%);
    color: #ffffff;
    border-bottom-right-radius: 4px;
    border: 1px solid rgba(255, 255, 255, 0.15);
}
.jp-msg.bot .jp-msg-bubble {
    background: rgba(24, 40, 72, 0.85);
    color: #f1f5f9;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-bottom-left-radius: 4px;
}

.jp-msg-bubble p {
    margin: 0 0 8px 0;
}
.jp-msg-bubble p:last-child {
    margin-bottom: 0;
}
.jp-msg-bubble ul, .jp-msg-bubble ol {
    margin: 4px 0 8px 18px;
    padding: 0;
}
.jp-msg-bubble li {
    margin-bottom: 4px;
}
.jp-msg-bubble strong {
    color: #38bdf8;
    font-weight: 700;
}
.jp-msg.user .jp-msg-bubble strong {
    color: #ffffff;
}

/* Indicador de escribiendo (Typing Dots) */
.jp-typing-wrapper {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 5px;
}
.jp-typing-indicator {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 10px 14px;
    background: rgba(24, 40, 72, 0.85);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 14px;
    border-bottom-left-radius: 4px;
    width: fit-content;
}
.jp-typing-status {
    font-size: 0.72em;
    color: #38bdf8;
    background: rgba(14, 28, 54, 0.8);
    border: 1px solid rgba(56, 189, 248, 0.25);
    border-radius: 8px;
    padding: 3px 9px;
    animation: jpStatusFade 0.3s ease-out;
    display: inline-flex;
    align-items: center;
    gap: 5px;
}
@keyframes jpStatusFade {
    from { opacity: 0; transform: translateY(3px); }
    to { opacity: 1; transform: translateY(0); }
}
.jp-typing-dot {
    width: 7px;
    height: 7px;
    background: #38bdf8;
    border-radius: 50%;
    animation: jpTypingBounce 1.4s infinite ease-in-out both;
}
.jp-typing-dot:nth-child(1) { animation-delay: -0.32s; }
.jp-typing-dot:nth-child(2) { animation-delay: -0.16s; }

/* Chips de preguntas frecuentes sugeridas */
.jp-chat-suggestions {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-top: 6px;
}
.jp-chat-suggestions-title {
    font-size: 0.72em;
    font-weight: 700;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    margin-bottom: 2px;
}
.jp-suggestion-chip {
    background: rgba(56, 189, 248, 0.1);
    border: 1px solid rgba(56, 189, 248, 0.25);
    border-radius: 10px;
    color: #e0f2fe;
    font-size: 0.82em;
    padding: 7px 11px;
    text-align: left;
    cursor: pointer;
    transition: background 0.18s, transform 0.15s, border-color 0.18s;
}
.jp-suggestion-chip:hover {
    background: rgba(56, 189, 248, 0.22);
    border-color: rgba(56, 189, 248, 0.5);
    transform: translateX(2px);
    color: #ffffff;
}

/* Área de Input */
.jp-chat-input-box {
    padding: 9px 12px 11px;
    background: rgba(14, 25, 48, 0.95);
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex-shrink: 0;
}
.jp-chat-input-row {
    display: flex;
    align-items: center;
    gap: 6px;
    width: 100%;
}
.jp-chat-input {
    flex: 1;
    background: #081427 !important;
    border: 1.5px solid #1e3a66 !important;
    border-radius: 10px !important;
    padding: 8px 12px !important;
    color: #ffffff !important;
    font-size: 0.88em !important;
    outline: none !important;
    transition: border-color 0.18s, box-shadow 0.18s;
}
.jp-chat-input:focus {
    border-color: #38bdf8 !important;
    box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.22) !important;
}
.jp-chat-input::placeholder {
    color: #64748b;
}
.jp-chat-send-btn {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: linear-gradient(135deg, #0284c7 0%, #0369a1 100%);
    border: none;
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    box-shadow: 0 4px 12px rgba(2, 132, 199, 0.35);
    transition: transform 0.15s, opacity 0.15s;
}
.jp-chat-send-btn:hover {
    transform: scale(1.05);
}
.jp-chat-send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}
.jp-chat-disclaimer {
    font-size: 0.65em;
    color: #64748b;
    text-align: center;
    line-height: 1.3;
}
