/* =============================================================================
   IAFLOW - Conversión y UX (bloque C)
   =============================================================================
   Componentes: newsletter inline, sticky CTA móvil, exit intent popup,
   scroll progress, scroll-to-top, author card, share buttons SVG, toasts.
   Todo compatible con dark mode usando las variables de global.css.
   ============================================================================= */

/* -----------------------------------------------------------------------------
   1. NEWSLETTER INLINE
   -------------------------------------------------------------------------- */

.iaflow-newsletter {
    background: var(--white, #ffffff);
    border: 1px solid var(--border, #e2e8f0);
    border-radius: 16px;
    padding: 32px 28px;
    margin: 40px auto;
    max-width: 720px;
    text-align: center;
    box-shadow: 0 4px 20px rgba(14, 165, 233, 0.06);
}

[data-theme="dark"] .iaflow-newsletter {
    background: var(--surface-2, #1e293b);
    border-color: var(--border-dark, #334155);
}

.iaflow-newsletter__badge {
    display: inline-block;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--primary, #0ea5e9);
    padding: 4px 12px;
    background: rgba(14, 165, 233, 0.1);
    border-radius: 999px;
    margin-bottom: 12px;
}

.iaflow-newsletter__title {
    font-family: var(--font-titles);
    font-size: 1.5rem;
    font-weight: 700;
    margin: 0 0 8px;
    color: var(--text-main, #0f172a);
    letter-spacing: -0.02em;
}

.iaflow-newsletter__desc {
    font-size: 1rem;
    color: var(--text-muted, #64748b);
    margin: 0 0 24px;
    line-height: 1.5;
}

.iaflow-newsletter__form {
    display: flex;
    gap: 8px;
    max-width: 460px;
    margin: 0 auto;
    flex-wrap: wrap;
}

.iaflow-newsletter__form input[type="email"] {
    flex: 1 1 240px;
    padding: 12px 16px;
    font-size: 1rem;
    border: 1px solid var(--border, #cbd5e1);
    border-radius: 10px;
    background: var(--white, #ffffff);
    color: var(--text-main, #0f172a);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

[data-theme="dark"] .iaflow-newsletter__form input[type="email"] {
    background: var(--surface, #0f172a);
    border-color: var(--border-dark, #475569);
    color: var(--text-main-dark, #e2e8f0);
}

.iaflow-newsletter__form input[type="email"]:focus {
    outline: none;
    border-color: var(--primary, #0ea5e9);
    box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.15);
}

.iaflow-newsletter__form button {
    padding: 12px 24px;
    font-size: 1rem;
    font-weight: 600;
    color: white;
    background: var(--primary, #0ea5e9);
    border: none;
    border-radius: 10px;
    cursor: pointer;
    transition: background 0.15s ease, transform 0.1s ease;
    white-space: nowrap;
}

.iaflow-newsletter__form button:hover {
    background: var(--primary-dark, #0284c7);
}

.iaflow-newsletter__form button:active {
    transform: scale(0.98);
}

.iaflow-newsletter__form button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.iaflow-newsletter__legal {
    font-size: 0.75rem;
    color: var(--text-muted, #64748b);
    margin: 12px 0 0;
}

.iaflow-newsletter__legal a {
    color: var(--primary, #0ea5e9);
    text-decoration: underline;
}

/* Honeypot: ocultar visualmente sin display:none (bots lo detectan) */
.iaflow-honeypot {
    position: absolute !important;
    left: -9999px !important;
    width: 1px !important;
    height: 1px !important;
    opacity: 0 !important;
    pointer-events: none !important;
}

/* -----------------------------------------------------------------------------
   2. STICKY CTA MÓVIL (solo en blog/artículos, solo móvil)
   -------------------------------------------------------------------------- */

.iaflow-sticky-cta {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 200;
    background: var(--white, #ffffff);
    border-top: 1px solid var(--border, #e2e8f0);
    padding: 12px 16px;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.08);
    display: none;
    transform: translateY(100%);
    transition: transform 0.3s ease;
}

.iaflow-sticky-cta.visible {
    transform: translateY(0);
}

[data-theme="dark"] .iaflow-sticky-cta {
    background: var(--surface-2, #1e293b);
    border-top-color: var(--border-dark, #334155);
}

.iaflow-sticky-cta__inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    max-width: 720px;
    margin: 0 auto;
}

.iaflow-sticky-cta__text {
    font-size: 0.85rem;
    color: var(--text-main, #0f172a);
    line-height: 1.3;
}

.iaflow-sticky-cta__text strong {
    display: block;
    font-size: 0.95rem;
    font-weight: 700;
    margin-bottom: 2px;
}

.iaflow-sticky-cta__btn {
    flex-shrink: 0;
    padding: 10px 16px;
    font-size: 0.9rem;
    font-weight: 600;
    color: white;
    background: var(--primary, #0ea5e9);
    border-radius: 10px;
    text-decoration: none;
    white-space: nowrap;
}

.iaflow-sticky-cta__close {
    background: none;
    border: none;
    color: var(--text-muted, #64748b);
    font-size: 1.2rem;
    cursor: pointer;
    padding: 4px 8px;
}

@media (max-width: 768px) {
    .iaflow-sticky-cta {
        display: block;
    }
    /* Espacio inferior para que el sticky CTA no tape contenido */
    body.has-sticky-cta {
        padding-bottom: 80px;
    }
}

/* -----------------------------------------------------------------------------
   3. EXIT INTENT POPUP
   -------------------------------------------------------------------------- */

.iaflow-exit-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.6);
    z-index: 9000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
    padding: 20px;
}

.iaflow-exit-overlay.visible {
    opacity: 1;
    pointer-events: auto;
}

.iaflow-exit-modal {
    background: var(--white, #ffffff);
    border-radius: 16px;
    max-width: 480px;
    width: 100%;
    padding: 32px;
    position: relative;
    transform: scale(0.95);
    transition: transform 0.25s ease;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.iaflow-exit-overlay.visible .iaflow-exit-modal {
    transform: scale(1);
}

[data-theme="dark"] .iaflow-exit-modal {
    background: var(--surface-2, #1e293b);
}

.iaflow-exit-close {
    position: absolute;
    top: 12px;
    right: 12px;
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--text-muted, #64748b);
    cursor: pointer;
    padding: 4px 10px;
    line-height: 1;
}

.iaflow-exit-emoji {
    font-size: 3rem;
    text-align: center;
    margin-bottom: 8px;
}

.iaflow-exit-modal h3 {
    font-family: var(--font-titles);
    font-size: 1.5rem;
    text-align: center;
    margin: 0 0 8px;
    letter-spacing: -0.02em;
}

.iaflow-exit-modal p {
    text-align: center;
    color: var(--text-muted, #64748b);
    margin: 0 0 20px;
}

/* -----------------------------------------------------------------------------
   4. SCROLL PROGRESS BAR (top de la página)
   -------------------------------------------------------------------------- */

.iaflow-scroll-progress {
    position: fixed;
    top: 0;
    left: 0;
    height: 3px;
    width: 0%;
    background: linear-gradient(90deg, var(--primary, #0ea5e9), var(--accent, #6366f1));
    z-index: 1000;
    transition: width 0.05s linear;
    pointer-events: none;
}

/* -----------------------------------------------------------------------------
   5. BOTÓN SCROLL-TO-TOP
   -------------------------------------------------------------------------- */

.iaflow-scroll-top {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--white, #ffffff);
    color: var(--primary, #0ea5e9);
    border: 1px solid var(--border, #e2e8f0);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease, transform 0.2s ease;
    z-index: 150;
}

.iaflow-scroll-top.visible {
    opacity: 1;
    pointer-events: auto;
}

.iaflow-scroll-top:hover {
    transform: translateY(-2px);
}

[data-theme="dark"] .iaflow-scroll-top {
    background: var(--surface-2, #1e293b);
    border-color: var(--border-dark, #334155);
}

/* En móvil con sticky CTA: subir scroll-to-top para que no se solapen */
@media (max-width: 768px) {
    body.has-sticky-cta .iaflow-scroll-top {
        bottom: 88px;
    }
}

/* -----------------------------------------------------------------------------
   6. AUTHOR CARD (final de artículos)
   -------------------------------------------------------------------------- */

.iaflow-author-card {
    background: var(--surface-2, #f8fafc);
    border: 1px solid var(--border, #e2e8f0);
    border-radius: 16px;
    padding: 28px;
    margin: 40px auto;
    max-width: 800px;
    display: flex;
    gap: 20px;
    align-items: flex-start;
}

[data-theme="dark"] .iaflow-author-card {
    background: var(--surface-2, #1e293b);
    border-color: var(--border-dark, #334155);
}

.iaflow-author-card__info {
    flex: 1;
}

.iaflow-author-card__label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted, #64748b);
    font-weight: 600;
    margin: 0 0 6px;
}

.iaflow-author-card__name {
    font-family: var(--font-titles);
    font-size: 1.25rem;
    font-weight: 700;
    margin: 0 0 8px;
    color: var(--text-main, #0f172a);
}

.iaflow-author-card__bio {
    font-size: 0.95rem;
    color: var(--text-muted, #64748b);
    line-height: 1.5;
    margin: 0 0 16px;
}

.iaflow-author-card__redes {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.iaflow-author-card__redes a {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border: 1px solid var(--border, #e2e8f0);
    border-radius: 8px;
    font-size: 0.85rem;
    color: var(--text-main, #0f172a);
    text-decoration: none;
    transition: background 0.15s ease, border-color 0.15s ease;
}

[data-theme="dark"] .iaflow-author-card__redes a {
    border-color: var(--border-dark, #334155);
    color: var(--text-main-dark, #e2e8f0);
}

.iaflow-author-card__redes a:hover {
    background: var(--primary, #0ea5e9);
    color: white;
    border-color: var(--primary, #0ea5e9);
}

.iaflow-author-card__redes svg {
    width: 14px;
    height: 14px;
}

@media (max-width: 580px) {
    .iaflow-author-card {
        padding: 20px;
    }
}

/* -----------------------------------------------------------------------------
   7. SHARE BUTTONS SVG (reemplazo de emojis)
   -------------------------------------------------------------------------- */

.iaflow-share {
    margin: 32px 0;
    padding: 20px;
    background: var(--surface-2, #f8fafc);
    border-radius: 12px;
}

[data-theme="dark"] .iaflow-share {
    background: var(--surface-2, #1e293b);
}

.iaflow-share h3 {
    font-size: 0.95rem;
    margin: 0 0 12px;
    color: var(--text-main, #0f172a);
    font-weight: 600;
}

.iaflow-share__btns {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.iaflow-share__btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    border-radius: 8px;
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 500;
    color: white;
    border: 1px solid transparent;
    transition: opacity 0.15s ease, transform 0.1s ease;
}

.iaflow-share__btn:hover {
    opacity: 0.92;
}

.iaflow-share__btn:active {
    transform: scale(0.97);
}

.iaflow-share__btn svg {
    width: 16px;
    height: 16px;
}

.iaflow-share__btn--x        { background: #000; }
.iaflow-share__btn--linkedin { background: #0a66c2; }
.iaflow-share__btn--facebook { background: #1877f2; }
.iaflow-share__btn--whatsapp { background: #25d366; }
.iaflow-share__btn--copy     { background: var(--text-muted, #64748b); }

/* -----------------------------------------------------------------------------
   8. PROBAR PROMPT EN ADSTUDIO (CTA dentro de bloques de código)
   -------------------------------------------------------------------------- */

.iaflow-try-prompt {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    background: var(--primary, #0ea5e9);
    color: white;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 600;
    text-decoration: none;
    margin-left: 8px;
    transition: background 0.15s ease;
}

.iaflow-try-prompt:hover {
    background: var(--primary-dark, #0284c7);
}

/* -----------------------------------------------------------------------------
   9. TOAST NOTIFICATIONS
   -------------------------------------------------------------------------- */

#iaflow-toast-container {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 10000;
    display: flex;
    flex-direction: column-reverse;
    gap: 8px;
    pointer-events: none;
}

.iaflow-toast {
    background: var(--text-main, #0f172a);
    color: white;
    padding: 12px 20px;
    border-radius: 10px;
    font-size: 0.9rem;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.25s ease, transform 0.25s ease;
    max-width: 90vw;
    pointer-events: auto;
}

.iaflow-toast.visible {
    opacity: 1;
    transform: translateY(0);
}

.iaflow-toast--success {
    background: #16a34a;
}

.iaflow-toast--error {
    background: #dc2626;
}

/* En móvil con sticky CTA: subir el toast para no taparlo */
@media (max-width: 768px) {
    body.has-sticky-cta #iaflow-toast-container {
        bottom: 88px;
    }
}

/* -----------------------------------------------------------------------------
   10. PÁGINA 404 CON BUSCADOR (mejora de la del bloque B)
   -------------------------------------------------------------------------- */

.iaflow-404-search {
    max-width: 480px;
    margin: 24px auto;
    display: flex;
    gap: 8px;
}

.iaflow-404-search input[type="search"] {
    flex: 1;
    padding: 12px 16px;
    font-size: 1rem;
    border: 1px solid var(--border, #cbd5e1);
    border-radius: 10px;
    background: var(--white, #ffffff);
    color: var(--text-main, #0f172a);
}

[data-theme="dark"] .iaflow-404-search input[type="search"] {
    background: var(--surface, #0f172a);
    border-color: var(--border-dark, #475569);
    color: var(--text-main-dark, #e2e8f0);
}

.iaflow-404-search button {
    padding: 12px 20px;
    background: var(--primary, #0ea5e9);
    color: white;
    border: none;
    border-radius: 10px;
    font-weight: 600;
    cursor: pointer;
}
