/* ========================================
   FIN WIDGET - BOT�N FLOTANTE Y MODAL
   ======================================== */

/* Bot�n flotante de Fin */
.fin-floating-btn {
    position: fixed;
    bottom: 96px; /* 24px (base) + 56px (altura FAB) + 16px (gap) */
    right: 24px; /* Alineado con FAB principal */
    width: 56px; /* Mismo tamaño que FAB para consistencia */
    height: 56px;
    background: linear-gradient(135deg, #0e2a47 0%, #103155 100%);
    border-radius: 50%;
    box-shadow: 0 8px 20px rgba(102, 126, 234, 0.4);
    cursor: pointer;
    z-index: 998; /* Justo debajo del FAB principal (999) */
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    border: 3px solid rgba(255, 255, 255, 0.9);
    overflow: hidden;
    animation: finPulse 2s ease-in-out infinite;
}

.fin-floating-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 12px 30px rgba(102, 126, 234, 0.6);
}

.fin-floating-btn img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}

.fin-floating-btn.hidden {
    display: none;
}

/* Animaci�n de pulso */
@keyframes finPulse {
    0%, 100% {
        box-shadow: 0 8px 20px rgba(102, 126, 234, 0.4);
    }
    50% {
        box-shadow: 0 8px 30px rgba(102, 126, 234, 0.7), 0 0 0 10px rgba(102, 126, 234, 0.1);
    }
}

/* Badge de notificaci�n (opcional) */
.fin-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #ef4444;
    color: white;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
    border: 2px solid white;
    animation: badgePulse 1s ease-in-out infinite;
}

@keyframes badgePulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.1);
    }
}

/* Modal del chat de Fin */
.fin-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10000;
    display: none;
    align-items: center;
    justify-content: center;
}

.fin-modal.active {
    display: flex;
}

.fin-modal-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(8px);
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.fin-modal-content {
    position: relative;
    width: 90%;
    max-width: 900px;
    height: 85vh;
    max-height: 800px;
    background: white;
    border-radius: 24px;
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.3);
    overflow: hidden;
    animation: slideUp 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    display: flex;
    flex-direction: column;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(50px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Bot�n de cerrar del modal */
.fin-modal-close {
    position: absolute;
    top: 20px;
    right: 20px;
    background: rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(10px);
    border: none;
    color: white;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 100;
    transition: all 0.2s ease;
}

.fin-modal-close:hover {
    background: rgba(0, 0, 0, 0.5);
    transform: rotate(90deg);
}

.fin-modal-close i {
    font-size: 20px;
}

/* Iframe del chat */
.fin-chat-iframe {
    width: 100%;
    height: 100%;
    border: none;
    border-radius: 24px;
}

/* ========================================
   MODAL DE BIENVENIDA
   ======================================== */
.fin-welcome-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10001;
    display: none;
    align-items: center;
    justify-content: center;
}

.fin-welcome-modal.active {
    display: flex;
}

.fin-welcome-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.95) 0%, rgba(118, 75, 162, 0.95) 100%);
    backdrop-filter: blur(10px);
    animation: fadeIn 0.5s ease;
}

.fin-welcome-content {
    position: relative;
    width: 90%;
    max-width: 480px;
    max-height: 90vh;
    overflow-y: auto;
    background: white;
    border-radius: 20px;
    padding: 32px 28px;
    box-shadow: 0 30px 60px rgba(0, 0, 0, 0.3);
    animation: welcomeSlide 0.6s cubic-bezier(0.16, 1, 0.3, 1);
    text-align: center;
}

@keyframes welcomeSlide {
    from {
        opacity: 0;
        transform: scale(0.8) translateY(50px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.fin-welcome-avatar {
    width: 90px;
    height: 90px;
    margin: 0 auto 16px;
    background: linear-gradient(135deg, #0e2a47 0%, #103155 100%);
    border-radius: 50%;
    padding: 6px;
    box-shadow: 0 8px 20px rgba(102, 126, 234, 0.4);
}

.fin-welcome-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
    background: white;
}

.fin-welcome-title {
    font-size: 26px;
    font-weight: 700;
    color: #1f2937;
    margin: 0 0 8px 0;
}

.fin-welcome-subtitle {
    font-size: 15px;
    color: #6b7280;
    margin: 0 0 20px 0;
}

.fin-welcome-message {
    font-size: 14px;
    color: #4b5563;
    line-height: 1.5;
    margin: 0 0 24px 0;
    padding: 18px;
    background: #f9fafb;
    border-radius: 12px;
    border-left: 3px solid #0e2a47;
    text-align: left;
}

.fin-welcome-message p {
    margin: 0 0 12px 0;
}

.fin-welcome-message p:last-child {
    margin-bottom: 0;
}

.fin-welcome-message ul {
    margin: 12px 0;
    padding-left: 0;
    list-style: none;
}

.fin-welcome-message li {
    padding: 6px 0;
}

.fin-welcome-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
    flex-wrap: wrap;
}

.fin-welcome-btn {
    padding: 12px 24px;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    border: none;
    display: flex;
    align-items: center;
    gap: 6px;
}

.fin-welcome-btn.primary {
    background: linear-gradient(135deg, #0e2a47 0%, #103155 100%);
    color: white;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
}

.fin-welcome-btn.primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.6);
}

.fin-welcome-btn.secondary {
    background: #f3f4f6;
    color: #4b5563;
}

.fin-welcome-btn.secondary:hover {
    background: #e5e7eb;
}

.fin-welcome-footer {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid #e5e7eb;
}

.fin-welcome-checkbox {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-size: 13px;
    color: #6b7280;
}

.fin-welcome-checkbox input {
    cursor: pointer;
}

/* ========================================
   RESPONSIVE
   ======================================== */
@media (max-width: 768px) {
    .fin-floating-btn {
        bottom: 148px; /* 80px (FAB mobile) + 52px (altura FAB mobile) + 16px (gap) */
        right: 16px; /* Alineado con FAB mobile */
        width: 52px; /* Mismo tamaño que FAB mobile */
        height: 52px;
    }

    .fin-modal-content {
        width: 100%;
        height: 100vh;
        max-height: 100vh;
        border-radius: 0;
    }

    .fin-chat-iframe {
        border-radius: 0;
    }

    .fin-welcome-content {
        width: 92%;
        max-width: 420px;
        padding: 28px 22px;
    }

    .fin-welcome-avatar {
        width: 80px;
        height: 80px;
    }

    .fin-welcome-title {
        font-size: 22px;
    }

    .fin-welcome-subtitle {
        font-size: 14px;
    }

    .fin-welcome-message {
        font-size: 13px;
        padding: 16px;
    }

    .fin-welcome-actions {
        flex-direction: column;
    }

    .fin-welcome-btn {
        width: 100%;
    }
}

@media (max-width: 480px) {
    .fin-floating-btn {
        bottom: 148px; /* Mantener la misma posición que en 768px para consistencia */
        right: 16px;
        width: 48px; /* Ligeramente más pequeño en móviles muy pequeños */
        height: 48px;
    }

    .fin-welcome-content {
        width: 94%;
        max-width: 95%;
        padding: 24px 18px;
    }

    .fin-welcome-avatar {
        width: 70px;
        height: 70px;
    }

    .fin-welcome-title {
        font-size: 20px;
    }

    .fin-welcome-subtitle {
        font-size: 13px;
    }

    .fin-welcome-message {
        font-size: 13px;
        padding: 14px;
    }

    .fin-welcome-btn {
        padding: 10px 20px;
        font-size: 13px;
    }
}

/* ========================================
   ESTADO DE CARGA
   ======================================== */
.fin-loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    color: #0e2a47;
}

.fin-loading-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid #e5e7eb;
    border-top-color: #0e2a47;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 16px;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* ========================================
   MODAL DE ONBOARDING COMPLETO
   ======================================== */
.fin-onboarding-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10002;
    display: none;
    align-items: center;
    justify-content: center;
}

.fin-onboarding-modal.active {
    display: flex;
}

.fin-onboarding-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(10px);
    animation: fadeIn 0.4s ease;
}

.fin-onboarding-content {
    position: relative;
    width: 100%;
    height: 100%;
    background: transparent;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.5s ease;
}

.fin-onboarding-iframe {
    width: 100%;
    height: 100%;
    border: none;
    background: white;
}
