/* ============================================================
   FLOW UI — componentes compartidos
   Drawer del carrito, toast, wizard, modales y formularios.
   Paleta: azul noche #050914 / tarjetas #0d142e / acento #2563EB
   ============================================================ */

:root {
    --flow-bg: #050914;
    --flow-surface: #0d142e;
    --flow-surface-2: #121b3a;
    --flow-border: rgba(255, 255, 255, 0.08);
    --flow-border-strong: rgba(255, 255, 255, 0.14);
    --flow-text: #ffffff;
    --flow-muted: #9aa4bf;
    --flow-muted-2: #6b7794;
    --flow-accent: #2563eb;
    --flow-accent-hover: #1d4ed8;
    --flow-accent-light: #60a5fa;
    --flow-accent-soft: rgba(37, 99, 235, 0.14);
    --flow-radius: 16px;
    --flow-radius-sm: 10px;
    --flow-danger: #f87171;
    --flow-ok: #34d399;
    --flow-font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --flow-shadow: 0 30px 60px -30px rgba(0, 0, 0, 0.95);
    --cart-bar-h: 0px;

    /* ============================================================
       ACENTOS BANDERA (Colombia) — un solo lugar para tocarlos.
       Se usan SIEMPRE en detalles de 1-2px, glows o degradados:
       nunca como fondo de bloques grandes.
       ============================================================ */
    --flow-flag-yellow: #fcd116;
    --flow-flag-blue: #2563eb;   /* el azul eléctrico de la marca */
    --flow-flag-red: #ce1126;
    --flow-tricolor: linear-gradient(90deg,
            var(--flow-flag-yellow) 0%,
            var(--flow-flag-blue) 50%,
            var(--flow-flag-red) 100%);
    --flow-glow-yellow: rgba(252, 209, 22, 0.55);
    --flow-glow-red: rgba(206, 17, 38, 0.45);
}

body.flow-lock { overflow: hidden; }

/* ---------------- Botones ---------------- */
.flow-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 13px 22px;
    border-radius: 12px;
    border: 1px solid transparent;
    background: transparent;
    color: var(--flow-text);
    font: 600 0.92rem/1.2 var(--flow-font);
    text-decoration: none;
    cursor: pointer;
    transition: background 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease, transform 0.15s ease;
}

.flow-btn--primary {
    position: relative;
    background: var(--flow-accent);
    border-color: var(--flow-accent);
    color: #fff;
    box-shadow: 0 14px 30px -16px rgba(37, 99, 235, 0.9);
}

/* Acento tricolor del botón de compra: borde de 1px con degradado
   amarillo→azul→rojo, dibujado con máscara (sin imágenes extra).
   El ojo va al botón porque es el único elemento con los tres colores. */
.flow-btn--primary::after {
    content: "";
    position: absolute;
    inset: 0;
    padding: 1px;
    border-radius: inherit;
    background: linear-gradient(90deg,
            var(--flow-flag-yellow),
            var(--flow-flag-blue),
            var(--flow-flag-red),
            var(--flow-flag-yellow));
    background-size: 300% 100%;
    -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
    -webkit-mask-composite: xor;
    mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
    mask-composite: exclude;
    opacity: 0;
    transition: opacity 0.25s ease;
    pointer-events: none;
    /* Si el navegador no entiende la máscara, este borde no se pinta:
       sin ella se vería un degradado sólido tapando el texto del botón. */
    display: none;
}

@supports ((mask-composite: exclude) or (-webkit-mask-composite: xor)) {
    .flow-btn--primary::after { display: block; }
}

.flow-btn--primary:hover {
    background: var(--flow-accent-hover);
    border-color: var(--flow-accent-hover);
    transform: translateY(-1px);
    box-shadow: 0 16px 34px -18px rgba(37, 99, 235, 0.95),
                0 10px 26px -18px var(--flow-glow-red);
}

/* El "rayo" recorre el contorno solo donde hay puntero real */
@media (hover: hover) and (pointer: fine) {
    .flow-btn--primary:hover::after {
        opacity: 1;
        animation: flowLaser 2.6s linear infinite;
    }
}

/* En táctil el acento salta al toque, no al hover */
.flow-btn--primary:active::after { opacity: 1; }
.flow-btn--primary:active { transform: scale(0.985); }

@keyframes flowLaser {
    from { background-position: 0% 50%; }
    to   { background-position: 300% 50%; }
}

.flow-btn--ghost {
    background: rgba(255, 255, 255, 0.03);
    border-color: var(--flow-border-strong);
}

.flow-btn--ghost:hover {
    border-color: rgba(37, 99, 235, 0.6);
    background: var(--flow-accent-soft);
}

.flow-btn--block { width: 100%; }
.flow-btn--sm { padding: 9px 14px; font-size: 0.8rem; border-radius: 9px; }

.flow-btn:disabled {
    opacity: 0.55;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.flow-link {
    border: 0;
    background: none;
    padding: 0;
    color: var(--flow-muted);
    font: 500 0.76rem/1.4 var(--flow-font);
    text-decoration: underline;
    text-underline-offset: 2px;
    cursor: pointer;
}

.flow-link:hover { color: var(--flow-text); }

/* ---------------- Formularios ---------------- */
.flow-field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }

.flow-label {
    font-size: 0.78rem;
    font-weight: 600;
    color: #c7d2fe;
}

.flow-label span { color: var(--flow-muted-2); font-weight: 400; }

.flow-input,
.flow-select,
.flow-textarea {
    width: 100%;
    padding: 12px 13px;
    border-radius: var(--flow-radius-sm);
    border: 1px solid var(--flow-border-strong);
    background: rgba(255, 255, 255, 0.04);
    color: var(--flow-text);
    font: 400 0.9rem/1.4 var(--flow-font);
    outline: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.flow-textarea { resize: vertical; min-height: 76px; }

.flow-select {
    appearance: none;
    background-image: linear-gradient(45deg, transparent 50%, #7c88a6 50%), linear-gradient(135deg, #7c88a6 50%, transparent 50%);
    background-position: calc(100% - 18px) 19px, calc(100% - 13px) 19px;
    background-size: 5px 5px, 5px 5px;
    background-repeat: no-repeat;
    padding-right: 34px;
}

.flow-input::placeholder,
.flow-textarea::placeholder { color: var(--flow-muted-2); }

.flow-input:focus,
.flow-select:focus,
.flow-textarea:focus {
    border-color: rgba(37, 99, 235, 0.7);
    background: rgba(255, 255, 255, 0.06);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.flow-input[aria-invalid="true"],
.flow-select[aria-invalid="true"],
.flow-textarea[aria-invalid="true"] { border-color: rgba(248, 113, 113, 0.7); }

.flow-error {
    display: none;
    font-size: 0.74rem;
    color: var(--flow-danger);
}

.flow-error.is-visible { display: block; }

.flow-hint { font-size: 0.72rem; color: var(--flow-muted-2); }

/* ---------------- Toast ---------------- */
.flow-toast-wrap {
    position: fixed;
    z-index: 3000;
    left: 16px;
    right: 16px;
    bottom: calc(var(--cart-bar-h, 0px) + 16px);
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
}

@media (min-width: 720px) {
    .flow-toast-wrap {
        left: auto;
        right: 20px;
        width: 380px;
        bottom: calc(var(--cart-bar-h, 0px) + 20px);
    }
}

.flow-toast {
    pointer-events: auto;
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 12px;
    border: 1px solid rgba(37, 99, 235, 0.4);
    border-radius: 14px;
    background: rgba(13, 20, 46, 0.98);
    -webkit-backdrop-filter: blur(14px);
    backdrop-filter: blur(14px);
    box-shadow: var(--flow-shadow);
    animation: flowToastIn 0.24s ease;
}

.flow-toast.is-hiding { animation: flowToastOut 0.2s ease forwards; }

.flow-toast__top {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.flow-toast__img {
    width: 44px;
    height: 44px;
    flex: none;
    border-radius: 9px;
    object-fit: cover;
    background: #0b1226;
}

.flow-toast__icon {
    width: 28px;
    height: 28px;
    flex: none;
    display: grid;
    place-items: center;
    border-radius: 50%;
    background: var(--flow-accent-soft);
    color: var(--flow-accent-light);
    font-size: 0.9rem;
    font-weight: 700;
}

.flow-toast__body { flex: 1; min-width: 0; }

.flow-toast__title {
    display: block;
    font-size: 0.88rem;
    font-weight: 700;
    color: var(--flow-text);
}

.flow-toast__message {
    display: block;
    font-size: 0.76rem;
    color: var(--flow-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.flow-toast__close {
    flex: none;
    border: 0;
    background: transparent;
    color: var(--flow-muted-2);
    font-size: 1rem;
    line-height: 1;
    padding: 4px;
    cursor: pointer;
}

.flow-toast__close:hover { color: var(--flow-text); }

.flow-toast__actions { display: flex; gap: 8px; }
.flow-toast__actions .flow-btn { flex: 1; }

/* ---------------- Drawer del carrito ---------------- */
.flow-drawer { position: fixed; inset: 0; z-index: 2500; display: none; }
.flow-drawer.is-open { display: block; }

.flow-drawer__overlay {
    position: absolute;
    inset: 0;
    background: rgba(2, 5, 15, 0.62);
    -webkit-backdrop-filter: blur(4px);
    backdrop-filter: blur(4px);
    animation: flowFade 0.2s ease;
}

.flow-drawer__panel {
    position: absolute;
    top: 0;
    right: 0;
    height: 100%;
    width: min(430px, 100%);
    display: flex;
    flex-direction: column;
    background: #0a0f24;
    border-left: 1px solid var(--flow-border-strong);
    box-shadow: -24px 0 60px -30px rgba(0, 0, 0, 0.95);
    animation: flowSlideIn 0.28s ease;
}

.flow-drawer__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 18px 20px;
    border-bottom: 1px solid var(--flow-border);
}

.flow-drawer__head h2 {
    margin: 0;
    font-size: 1.05rem;
    font-weight: 700;
    letter-spacing: -0.01em;
}

.flow-drawer__head h2 span { color: var(--flow-muted); font-weight: 500; }

.flow-drawer__close {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    border: 1px solid var(--flow-border);
    background: rgba(255, 255, 255, 0.03);
    color: var(--flow-muted);
    font-size: 0.95rem;
    cursor: pointer;
    display: grid;
    place-items: center;
}

.flow-drawer__close:hover { color: #fff; border-color: rgba(37, 99, 235, 0.6); }

.flow-drawer__items {
    flex: 1;
    overflow-y: auto;
    padding: 0 20px;
}

.flow-drawer__empty {
    padding: 48px 10px;
    text-align: center;
    color: var(--flow-muted);
    font-size: 0.88rem;
}

.flow-drawer__foot {
    padding: 16px 20px calc(16px + env(safe-area-inset-bottom, 0px));
    border-top: 1px solid var(--flow-border);
    background: rgba(13, 20, 46, 0.9);
}

.flow-drawer__row {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 10px;
    font-size: 0.84rem;
    color: var(--flow-muted);
    margin-bottom: 6px;
}

.flow-drawer__row strong { color: var(--flow-text); font-weight: 600; }

.flow-drawer__row--total {
    margin: 10px 0 6px;
    font-size: 1rem;
    color: var(--flow-text);
}

.flow-drawer__row--total strong {
    font-size: 1.3rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    color: var(--flow-accent-light);
}

.flow-drawer__note {
    margin: 0 0 12px;
    font-size: 0.74rem;
    line-height: 1.45;
    color: var(--flow-muted-2);
}

/* ---------------- Línea de producto (drawer y carrito) ---------------- */
.flow-line {
    display: grid;
    grid-template-columns: 72px minmax(0, 1fr);
    gap: 12px;
    padding: 16px 0;
    border-bottom: 1px solid var(--flow-border);
}

.flow-line:last-child { border-bottom: 0; }

.flow-line__img {
    width: 72px;
    height: 72px;
    border-radius: 10px;
    object-fit: cover;
    background: #0b1226;
    border: 1px solid var(--flow-border);
}

.flow-line__name {
    font-size: 0.88rem;
    font-weight: 600;
    line-height: 1.35;
    color: var(--flow-text);
    display: block;
}

a.flow-line__name:hover { color: var(--flow-accent-light); }

.flow-line__variant {
    margin: 3px 0 0;
    font-size: 0.74rem;
    color: var(--flow-muted);
}

.flow-line__meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-top: 8px;
    flex-wrap: wrap;
}

.flow-line__price {
    font-size: 0.82rem;
    color: var(--flow-muted);
    white-space: nowrap;
}

.flow-line__price strong {
    color: var(--flow-text);
    font-size: 0.92rem;
    font-weight: 700;
}

.flow-qty {
    display: inline-flex;
    align-items: center;
    border: 1px solid var(--flow-border-strong);
    border-radius: 9px;
    overflow: hidden;
}

.flow-qty button {
    width: 30px;
    height: 30px;
    border: 0;
    background: transparent;
    color: var(--flow-text);
    font-size: 0.95rem;
    cursor: pointer;
    transition: background 0.15s ease;
}

.flow-qty button:hover { background: var(--flow-accent-soft); }
.flow-qty button:disabled { color: var(--flow-muted-2); cursor: not-allowed; }

.flow-qty span {
    min-width: 30px;
    text-align: center;
    font-size: 0.82rem;
    font-weight: 600;
}

.flow-line__actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-top: 8px;
}

/* ---------------- Wizard (checkout) ---------------- */
.flow-steps {
    display: flex;
    gap: 6px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.flow-step {
    flex: 1;
    text-align: center;
    font-size: 0.68rem;
    line-height: 1.25;
    color: var(--flow-muted-2);
    transition: color 0.2s ease;
}

.flow-step__num {
    display: grid;
    place-items: center;
    width: 28px;
    height: 28px;
    margin: 0 auto 5px;
    border-radius: 50%;
    border: 1px solid var(--flow-border-strong);
    background: rgba(255, 255, 255, 0.03);
    font-size: 0.76rem;
    font-weight: 700;
    transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

.flow-step.is-active { color: var(--flow-text); }

/* Paso actual: punto de luz amarillo (foco de atención) */
.flow-step.is-active .flow-step__num {
    background: var(--flow-accent);
    border-color: var(--flow-accent);
    color: #fff;
    box-shadow: 0 0 0 4px rgba(252, 209, 22, 0.14),
                0 0 16px -2px var(--flow-glow-yellow);
}

.flow-step.is-done { color: #bfdbfe; }

/* Pasos completados: check rojo sutil en lugar del número */
.flow-step.is-done .flow-step__num {
    position: relative;
    background: rgba(206, 17, 38, 0.16);
    border-color: rgba(206, 17, 38, 0.6);
    color: transparent;
}

.flow-step.is-done .flow-step__num::after {
    content: "✓";
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    color: #fb7185;
    font-size: 0.82rem;
    font-weight: 800;
}

.flow-panel[hidden] { display: none; }

.flow-panel { animation: flowFade 0.2s ease; }

/* ---------------- Modal ---------------- */
.flow-modal {
    position: fixed;
    inset: 0;
    z-index: 2600;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: rgba(2, 5, 15, 0.7);
    -webkit-backdrop-filter: blur(6px);
    backdrop-filter: blur(6px);
}

.flow-modal.is-open { display: flex; }

.flow-modal__card {
    width: min(420px, 100%);
    padding: 26px;
    border: 1px solid var(--flow-border-strong);
    border-radius: var(--flow-radius);
    background: var(--flow-surface);
    box-shadow: var(--flow-shadow);
    text-align: center;
    animation: flowToastIn 0.22s ease;
}

.flow-modal__card h2 {
    margin: 0 0 8px;
    font-size: 1.15rem;
    letter-spacing: -0.01em;
}

.flow-modal__card p {
    margin: 0 0 18px;
    color: var(--flow-muted);
    font-size: 0.86rem;
    line-height: 1.55;
}

.flow-modal__actions { display: flex; flex-direction: column; gap: 8px; }

/* ---------------- Lightbox ---------------- */
.flow-lightbox {
    position: fixed;
    inset: 0;
    z-index: 2700;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: rgba(2, 5, 15, 0.94);
    -webkit-backdrop-filter: blur(6px);
    backdrop-filter: blur(6px);
}

.flow-lightbox.is-open { display: flex; }

.flow-lightbox__img {
    max-width: min(1100px, 92vw);
    max-height: 84vh;
    border-radius: 14px;
    border: 1px solid var(--flow-border-strong);
    object-fit: contain;
    background: #0b1226;
}

.flow-lightbox__close,
.flow-lightbox__nav {
    position: fixed;
    z-index: 2701;
    width: 42px;
    height: 42px;
    border-radius: 50%;
    border: 1px solid var(--flow-border-strong);
    background: rgba(13, 20, 46, 0.92);
    color: var(--flow-text);
    font-size: 1rem;
    cursor: pointer;
    display: grid;
    place-items: center;
}

.flow-lightbox__close { top: 16px; right: 16px; }
.flow-lightbox__nav--prev { left: 16px; top: 50%; transform: translateY(-50%); }
.flow-lightbox__nav--next { right: 16px; top: 50%; transform: translateY(-50%); }
.flow-lightbox__close:hover,
.flow-lightbox__nav:hover { border-color: rgba(37, 99, 235, 0.7); background: rgba(37, 99, 235, 0.2); }

/* ---------------- Utilidades ---------------- */
.flow-sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.flow-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 999px;
    border: 1px solid var(--flow-border-strong);
    background: rgba(255, 255, 255, 0.03);
    color: var(--flow-muted);
    font-size: 0.7rem;
    font-weight: 600;
}

.flow-badge--ok {
    border-color: rgba(52, 211, 153, 0.4);
    background: rgba(52, 211, 153, 0.1);
    color: #6ee7b7;
}

.flow-badge--off {
    border-color: rgba(248, 113, 113, 0.4);
    background: rgba(248, 113, 113, 0.1);
    color: #fca5a5;
}

/* ---------------- Animaciones ---------------- */
@keyframes flowToastIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes flowToastOut {
    from { opacity: 1; transform: translateY(0); }
    to { opacity: 0; transform: translateY(10px); }
}

@keyframes flowSlideIn {
    from { transform: translateX(100%); }
    to { transform: translateX(0); }
}

@keyframes flowFade {
    from { opacity: 0; }
    to { opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
    .flow-toast,
    .flow-drawer__panel,
    .flow-drawer__overlay,
    .flow-modal__card,
    .flow-panel {
        animation-duration: 0.001ms !important;
    }
}

/* ============================================================
   ASISTENTE DE COMPRAS (IA)
   ============================================================ */
/* ============================================================
   ESFERA DE TINA (asistente IA) · la luz es el botón
   ------------------------------------------------------------
   Cero imágenes: tres capas apiladas dentro del mismo <button>
   que ya crea flow-assistant.js (su HTML no se toca).

     1. ARO TRICOLOR   → el fondo del propio botón (conic-gradient)
     2. HALO EXTERIOR  → ::before, radial-gradient + filter: blur()
     3. ESFERA         → ::after, radial-gradient + luces interiores

   El "F" y el punto de estado flotan por encima con z-index.
   ============================================================ */
.flow-ai-fab {
    position: fixed;
    right: 20px;
    bottom: 20px;
    z-index: 960;
    width: 56px;
    height: 56px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    color: #fff;
    cursor: pointer;
    display: grid;
    place-items: center;
    font: 800 1.3rem/1 var(--flow-font);
    /* 1. ARO TRICOLOR: la esfera se dibuja a inset:2px, así que del fondo
       del botón solo asoma el filo de 2px. Acento de bandera donde toca:
       un detalle fino, nunca un bloque de color. */
    background: conic-gradient(from 205deg,
            var(--flow-flag-yellow) 0deg,
            var(--flow-accent) 150deg,
            var(--flow-flag-red) 285deg,
            var(--flow-flag-yellow) 360deg);
    /* Contexto de apilado propio para que los pseudos no se escapen */
    isolation: isolate;
    -webkit-tap-highlight-color: transparent;
    transition: transform 0.25s ease, bottom 0.25s ease;
}

/* 2. HALO: la luz que se escapa de la esfera. El blur real va aquí. */
.flow-ai-fab::before {
    content: "";
    position: absolute;
    inset: -17px;
    z-index: 0;
    border-radius: 50%;
    background: radial-gradient(circle at 50% 50%,
            rgba(96, 165, 250, 0.62) 0%,
            rgba(99, 102, 241, 0.4) 34%,
            rgba(139, 92, 246, 0.26) 56%,
            rgba(139, 92, 246, 0) 72%);
    filter: blur(9px);
    animation: flowSphereHalo 5.6s ease-in-out infinite;
    pointer-events: none;
}

/* 3. ESFERA: el núcleo de energía, con la luz entrando por arriba a la izquierda. */
.flow-ai-fab::after {
    content: "";
    position: absolute;
    inset: 2px;
    z-index: 1;
    border-radius: 50%;
    background: radial-gradient(circle at 33% 27%,
            #e0efff 0%,
            #60a5fa 20%,
            #3b82f6 42%,
            #1d4ed8 70%,
            #312e81 100%);
    box-shadow:
        inset 0 -9px 18px rgba(12, 8, 48, 0.6),
        inset 0 7px 14px rgba(255, 255, 255, 0.32),
        0 14px 30px -12px rgba(37, 99, 235, 0.95);
    animation: flowSphereCore 5.6s ease-in-out infinite;
    pointer-events: none;
    transition: background 0.4s ease;
}

/* El "F" (primer span del botón) vive sobre la luz, no dentro de ella */
.flow-ai-fab > span:first-child {
    position: relative;
    z-index: 2;
    text-shadow: 0 0 10px rgba(224, 239, 255, 0.95),
                 0 0 24px rgba(96, 165, 250, 0.75);
}

.flow-ai-fab:hover { transform: translateY(-2px) scale(1.03); }

/* La barra flotante del carrito ocupa la franja inferior: el botón del
   asistente sube por encima con la altura real que inyecta flow-cart.js. */
body.has-cart-bar .flow-ai-fab { bottom: calc(var(--cart-bar-h, 0px) + 14px); }

.flow-ai-fab__dot {
    position: absolute;
    top: 5px;
    right: 5px;
    z-index: 2;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--flow-ok);
    border: 2px solid #050914;
}

/* ---- Estado 1: chat abierto → la esfera se enciende en violeta ---- */
.flow-ai-fab[aria-expanded="true"]::before {
    animation-duration: 2.4s;
    background: radial-gradient(circle at 50% 50%,
            rgba(196, 181, 253, 0.62) 0%,
            rgba(139, 92, 246, 0.46) 38%,
            rgba(139, 92, 246, 0) 72%);
}

.flow-ai-fab[aria-expanded="true"]::after {
    animation-duration: 2.4s;
}

/* ---- Estado 2: Tina escribe → pulso rápido y núcleo blanco-violeta ----
   `:has()` permite reaccionar al DOM del chat SIN tocar su lógica: la
   burbuja .flow-ai-typing la pinta flow-assistant.js y aquí solo se mira. */
body:has(.flow-ai-typing) .flow-ai-fab { transform: scale(1.05); }

body:has(.flow-ai-typing) .flow-ai-fab::before {
    animation-duration: 0.9s;
    inset: -22px;
    background: radial-gradient(circle at 50% 50%,
            rgba(233, 213, 255, 0.8) 0%,
            rgba(167, 139, 250, 0.5) 40%,
            rgba(139, 92, 246, 0) 74%);
}

body:has(.flow-ai-typing) .flow-ai-fab::after {
    animation-duration: 0.9s;
    background: radial-gradient(circle at 34% 28%,
            #f5f3ff 0%,
            #c4b5fd 20%,
            #8b5cf6 48%,
            #4c1d95 80%,
            #2e1065 100%);
}

/* Respiración: escala y opacidad del halo suben y bajan a la vez. Es lo que
   hace que la esfera parezca "viva" y no un adorno quieto. */
@keyframes flowSphereHalo {
    0%, 100% { transform: scale(0.9); opacity: 0.55; }
    50%      { transform: scale(1.08); opacity: 0.95; }
}

/* Pulso del núcleo: la luz interior late desfasada del halo (mismo periodo,
   distinta fase) para que el movimiento no se lea mecánico. */
@keyframes flowSphereCore {
    0%, 100% {
        box-shadow:
            inset 0 -9px 18px rgba(12, 8, 48, 0.6),
            inset 0 7px 14px rgba(255, 255, 255, 0.3),
            0 14px 30px -12px rgba(37, 99, 235, 0.9);
    }
    50% {
        box-shadow:
            inset 0 -9px 18px rgba(12, 8, 48, 0.5),
            inset 0 8px 16px rgba(255, 255, 255, 0.46),
            0 20px 42px -14px rgba(99, 102, 241, 1);
    }
}

.flow-ai-panel {
    position: fixed;
    right: 20px;
    bottom: 88px;
    z-index: 2800;
    width: 380px;
    max-width: calc(100vw - 32px);
    /* 100dvh = altura dinámica real (se adapta a la barra del navegador).
       La primera línea es el respaldo para navegadores sin soporte dvh. */
    height: min(560px, calc(100vh - 120px));
    height: min(560px, calc(100dvh - 120px));
    display: flex;
    flex-direction: column;
    background: #0a0f24;
    border: 1px solid var(--flow-border-strong);
    border-radius: 18px;
    box-shadow: 0 40px 80px -40px rgba(0, 0, 0, 0.95);
    overflow: hidden;
    animation: flowAiIn 0.24s ease;
}

.flow-ai-panel[hidden] { display: none; }

.flow-ai-head {
    /* La cabecera nunca se va con el scroll de la conversación. */
    position: sticky;
    top: 0;
    z-index: 2;
    flex: none;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 13px 14px;
    border-bottom: 1px solid var(--flow-border);
    background: linear-gradient(180deg, rgba(37, 99, 235, 0.16) 0%, rgba(37, 99, 235, 0) 100%), #0a0f24;
}

.flow-ai-head__mark {
    width: 34px;
    height: 34px;
    flex: none;
    border-radius: 10px;
    display: grid;
    place-items: center;
    background: linear-gradient(140deg, #2563eb, #60a5fa);
    color: #fff;
    font-weight: 900;
    font-size: 0.85rem;
}

.flow-ai-head__text { flex: 1; min-width: 0; }
.flow-ai-head__text strong { display: block; font-size: 0.86rem; letter-spacing: -0.01em; }

.flow-ai-head__status {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 0.68rem;
    color: var(--flow-muted);
}

.flow-ai-head__status i {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--flow-ok);
    box-shadow: 0 0 8px rgba(52, 211, 153, 0.8);
}

.flow-ai-close {
    width: 32px;
    height: 32px;
    flex: none;
    border-radius: 50%;
    border: 1px solid var(--flow-border);
    background: transparent;
    color: var(--flow-muted);
    font-size: 0.9rem;
    cursor: pointer;
    display: grid;
    place-items: center;
}

.flow-ai-close:hover { color: #fff; border-color: rgba(37, 99, 235, 0.6); }

.flow-ai-body {
    flex: 1;
    /* min-height:0 permite que el contenedor se encoja cuando aparece el
       teclado; sin esto el body desborda y empuja la cabecera. */
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    scrollbar-width: thin;
}

.flow-ai-msg { display: flex; }
.flow-ai-msg--user { justify-content: flex-end; }

.flow-ai-bubble {
    max-width: 84%;
    padding: 10px 13px;
    border-radius: 14px;
    font-size: 0.85rem;
    line-height: 1.5;
    white-space: pre-line;
    word-break: break-word;
}

.flow-ai-msg--bot .flow-ai-bubble {
    background: var(--flow-surface-2);
    border: 1px solid var(--flow-border);
    color: #e2e8f0;
    border-bottom-left-radius: 5px;
}

.flow-ai-msg--user .flow-ai-bubble {
    background: var(--flow-accent);
    color: #fff;
    border-bottom-right-radius: 5px;
}

.flow-ai-chips { display: flex; flex-wrap: wrap; gap: 6px; }

.flow-ai-chip {
    padding: 7px 11px;
    border-radius: 999px;
    border: 1px solid rgba(37, 99, 235, 0.45);
    background: rgba(37, 99, 235, 0.1);
    color: #c7d2fe;
    font: 600 0.74rem/1.2 var(--flow-font);
    cursor: pointer;
    transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

.flow-ai-chip:hover { background: rgba(37, 99, 235, 0.22); color: #fff; border-color: rgba(37, 99, 235, 0.7); }

.flow-ai-products { display: grid; gap: 8px; }

/* Tarjeta del producto recomendado: ficha clicable arriba + acciones abajo */
.flow-ai-product {
    display: grid;
    gap: 8px;
    padding: 8px;
    border: 1px solid var(--flow-border);
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.03);
    transition: border-color 0.2s ease, background 0.2s ease;
}

.flow-ai-product:hover { border-color: rgba(37, 99, 235, 0.55); background: rgba(37, 99, 235, 0.08); }

.flow-ai-product__main {
    display: grid;
    grid-template-columns: 52px minmax(0, 1fr);
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: inherit;
}

.flow-ai-product__img,
.flow-ai-product__ph {
    width: 52px;
    height: 52px;
    border-radius: 9px;
    object-fit: cover;
    background: #0b1226;
    border: 1px solid var(--flow-border);
}

.flow-ai-product__ph {
    display: grid;
    place-items: center;
    color: var(--flow-accent-light);
    font-weight: 900;
}

.flow-ai-product__body { display: block; min-width: 0; }

.flow-ai-product__name {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    font-size: 0.8rem;
    font-weight: 600;
    color: #fff;
    line-height: 1.3;
}

.flow-ai-product__price {
    display: block;
    margin-top: 2px;
    font-size: 0.76rem;
    font-weight: 700;
    color: var(--flow-accent-light);
}

.flow-ai-product__cta {
    display: block;
    margin-top: 2px;
    font-size: 0.68rem;
    color: var(--flow-muted);
}

/* Acciones de la tarjeta: comprar sin salir del chat + ver la ficha */
.flow-ai-product__actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.flow-ai-product__actions .flow-ai-product__cta {
    margin: 0;
    white-space: nowrap;
    font-weight: 600;
}

.flow-ai-add {
    flex: 1;
    padding: 8px 12px;
    border-radius: 9px;
    border: 1px solid var(--flow-accent);
    background: var(--flow-accent);
    color: #fff;
    font: 700 0.74rem/1.2 var(--flow-font);
    cursor: pointer;
    transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

.flow-ai-add:hover { background: var(--flow-accent-hover); border-color: var(--flow-accent-hover); }

/* Confirmación en el propio botón, sin ventanas emergentes */
.flow-ai-add.is-added {
    background: rgba(52, 211, 153, 0.18);
    border-color: rgba(52, 211, 153, 0.6);
    color: #6ee7b7;
}

.flow-ai-form {
    /* La barra de escritura queda siempre pegada abajo, encima del teclado. */
    position: sticky;
    bottom: 0;
    z-index: 2;
    flex: none;
    display: flex;
    gap: 8px;
    padding: 11px 12px;
    border-top: 1px solid var(--flow-border);
    background: rgba(13, 20, 46, 0.98);
}

.flow-ai-input {
    flex: 1;
    min-width: 0;
    padding: 11px 12px;
    border-radius: 10px;
    border: 1px solid var(--flow-border-strong);
    background: rgba(255, 255, 255, 0.04);
    color: var(--flow-text);
    font: 400 0.86rem/1.4 var(--flow-font);
    outline: none;
}

.flow-ai-input::placeholder { color: var(--flow-muted-2); }
.flow-ai-input:focus { border-color: rgba(37, 99, 235, 0.7); box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15); }

.flow-ai-send {
    width: 42px;
    height: 42px;
    flex: none;
    border: 0;
    border-radius: 10px;
    background: var(--flow-accent);
    color: #fff;
    font-size: 1rem;
    cursor: pointer;
    display: grid;
    place-items: center;
}

.flow-ai-send:hover { background: var(--flow-accent-hover); }
.flow-ai-send:disabled { opacity: 0.55; cursor: not-allowed; }

.flow-ai-foot {
    padding: 0 12px 10px;
    text-align: center;
    font-size: 0.64rem;
    color: var(--flow-muted-2);
    background: rgba(13, 20, 46, 0.92);
}

/* Acción destacada dentro del chat (por ejemplo "Ir a Flow Track").
   Botón grande, azul eléctrico, con el peso visual de una acción principal. */
.flow-ai-track {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 14px 18px;
    border-radius: 12px;
    border: 1px solid var(--flow-accent);
    background: linear-gradient(135deg, var(--flow-accent) 0%, #3b82f6 100%);
    color: #fff;
    font: 700 0.88rem/1.2 var(--flow-font);
    text-decoration: none;
    box-shadow: 0 16px 32px -18px rgba(37, 99, 235, 0.95);
    transition: background 0.2s ease, transform 0.15s ease, box-shadow 0.2s ease;
}

.flow-ai-track:hover {
    background: linear-gradient(135deg, var(--flow-accent-hover) 0%, var(--flow-accent) 100%);
    transform: translateY(-1px);
    box-shadow: 0 20px 36px -18px rgba(37, 99, 235, 1);
}

.flow-ai-track:focus-visible {
    outline: 2px solid var(--flow-accent-light);
    outline-offset: 2px;
}

.flow-ai-typing { display: inline-flex; align-items: center; gap: 4px; }

.flow-ai-typing i {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--flow-accent-light);
    opacity: 0.35;
    animation: flowAiTyping 1.2s infinite;
}

/* Los tres puntos de "escribiendo" parpadean en amarillo, azul y rojo */
.flow-ai-typing i:nth-child(1) { background: var(--flow-flag-yellow); animation-delay: 0s; }
.flow-ai-typing i:nth-child(2) { background: var(--flow-flag-blue); animation-delay: 0.15s; }
.flow-ai-typing i:nth-child(3) { background: var(--flow-flag-red); animation-delay: 0.3s; }

@keyframes flowAiTyping {
    0%, 60%, 100% { opacity: 0.3; transform: translateY(0); }
    30% { opacity: 1; transform: translateY(-3px); }
}

@keyframes flowAiIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: none; }
}

/* ============================================================
   CHAT EN MÓVIL: pantalla completa (estilo WhatsApp/Instagram)
   El corte es 768px: por debajo, el chat deja de ser una ventana
   flotante y ocupa toda la pantalla visible.
   ============================================================ */
@media (max-width: 767px) {
    .flow-ai-fab {
        right: 14px;
        bottom: 14px;
        width: 52px;
        height: 52px;
        font-size: 1.15rem;
    }

    body.has-cart-bar .flow-ai-fab { bottom: calc(var(--cart-bar-h) + 12px); }

    .flow-ai-panel {
        inset: 0;
        width: 100%;
        max-width: none;
        height: 100vh;          /* respaldo */
        height: 100dvh;         /* altura real del viewport */
        max-height: 100vh;
        max-height: 100dvh;
        border: 0;
        border-radius: 0;
    }

    /* iOS hace zoom automático al enfocar un input de menos de 16px,
       y ese zoom es lo que "descoloca" el chat. */
    .flow-ai-input { font-size: 16px; }

    .flow-ai-body { padding: 14px; }

    .flow-ai-bubble { max-width: 88%; }
}

@media (prefers-reduced-motion: reduce) {
    /* La esfera se queda quieta pero igual de brillante: quien tiene
       vértigo no pierde el halo, solo el movimiento. */
    .flow-ai-fab,
    .flow-ai-fab::before,
    .flow-ai-fab::after { animation: none; }
    .flow-ai-fab::before { opacity: 0.9; transform: none; }
    .flow-ai-fab:hover,
    body:has(.flow-ai-typing) .flow-ai-fab { transform: none; }
    .flow-ai-panel { animation-duration: 0.001ms !important; }
}

/* ============================================================
   FOOTER PÚBLICO
   Compartido por index, producto-detalle, carrito y seguimiento
   (fragmento: fragments/public-footer.html).
   Usa tokens --flow-* para verse idéntico en todas las vistas.
   ============================================================ */
.site-footer {
    margin-top: 44px;
    background: var(--flow-bg, #050914);
    border-top: 1px solid var(--flow-border, rgba(255, 255, 255, 0.08));
    color: var(--flow-text, #fff);
}

/* ---------------- Identidad + columnas ---------------- */
.footer-inner {
    display: grid;
    grid-template-columns: 1fr;
    gap: 26px;
    width: 100%;
    max-width: 1160px;
    margin: 0 auto;
    padding: 34px 18px 26px;
}

@media (min-width: 720px) {
    .footer-inner {
        grid-template-columns: 1.5fr 1fr 1fr;
        gap: 32px;
        padding: 46px 24px 30px;
    }
}

.footer-brand__link {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
}

.footer-brand__mark {
    width: 34px;
    height: 34px;
    flex: none;
    display: grid;
    place-items: center;
    border-radius: 10px;
    background: linear-gradient(140deg, #2563eb 0%, #3b82f6 55%, #60a5fa 100%);
    color: #fff;
    font-size: 0.9rem;
    font-weight: 900;
    box-shadow: 0 10px 24px -14px rgba(37, 99, 235, 0.95);
}

.footer-brand__name {
    font-size: 0.9rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    color: #fff;
}

.footer-brand p {
    margin-top: 12px;
    max-width: 34ch;
    color: var(--flow-muted, #9aa4bf);
    font-size: 0.84rem;
    line-height: 1.6;
}

.footer-col h4 {
    margin-bottom: 12px;
    color: var(--flow-muted-2, #6b7794);
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.14em;
    text-transform: uppercase;
}

.footer-links {
    display: grid;
    gap: 9px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.footer-links a {
    color: var(--flow-muted, #9aa4bf);
    font-size: 0.86rem;
    text-decoration: none;
    transition: color 0.2s ease;
}

.footer-links a:hover { color: #fff; }

/* ---------------- Redes sociales ---------------- */
.footer-social-section {
    position: relative;
    width: 100%;
    max-width: 1160px;
    margin: 0 auto;
    padding: 26px 18px 30px;
    border-top: 0;
}

/* Línea de 1px con los tres colores de la bandera (antes azul plano) */
.footer-social-section::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: var(--flow-tricolor);
    opacity: 0.85;
    pointer-events: none;
}

@media (min-width: 720px) {
    .footer-social-section { padding: 30px 24px 34px; }
}

.footer-social-title {
    font-size: clamp(1.35rem, 4.4vw, 1.85rem);
    font-weight: 800;
    letter-spacing: -0.02em;
    line-height: 1.15;
    color: #fff;
}

.footer-social-sub {
    margin-top: 8px;
    color: var(--flow-muted, #9aa4bf);
    font-size: 0.88rem;
}

.footer-social-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 20px;
}

.social-pill {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    border-radius: 999px;
    border: 1px solid rgba(37, 99, 235, 0.45);
    background: transparent;
    color: #dbe4ff;
    font: 600 0.82rem/1.2 var(--flow-font, system-ui, sans-serif);
    text-decoration: none;
    white-space: nowrap;
    transition: border-color 0.22s ease, color 0.22s ease, box-shadow 0.22s ease,
                background 0.22s ease, transform 0.12s ease;
}

.social-pill svg { width: 17px; height: 17px; flex: none; }

/* Brillo solo donde hay puntero real (escritorio) */
@media (hover: hover) and (pointer: fine) {
    .social-pill:hover {
        color: #fff;
        border-color: #2563eb;
        box-shadow: 0 0 0 1px rgba(37, 99, 235, 0.4), 0 12px 28px -16px rgba(37, 99, 235, 0.95);
        transform: translateY(-1px);
    }
}

/* Respuesta inmediata al toque (móvil) */
.social-pill:active {
    transform: scale(0.97);
    background: rgba(37, 99, 235, 0.16);
    border-color: rgba(37, 99, 235, 0.85);
}

.social-pill:focus-visible {
    outline: 2px solid var(--flow-accent-light, #60a5fa);
    outline-offset: 2px;
}

.footer-social-invite {
    margin-top: 16px;
    color: var(--flow-muted-2, #6b7794);
    font-size: 0.76rem;
}

/* Móvil: las tres píldoras en una fila que no se desborda */
@media (max-width: 560px) {
    .footer-social-pills {
        display: grid;
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 8px;
    }

    .social-pill {
        justify-content: center;
        gap: 6px;
        padding: 11px 6px;
        font-size: 0.74rem;
    }

    .social-pill svg { width: 15px; height: 15px; }
}

/* Pantallas muy estrechas: apiladas a lo ancho */
@media (max-width: 352px) {
    .footer-social-pills { grid-template-columns: 1fr; }

    .social-pill {
        gap: 8px;
        padding: 12px 14px;
        font-size: 0.82rem;
    }
}

/* ---------------- Barra inferior ---------------- */
.footer-bottom {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    width: 100%;
    max-width: 1160px;
    margin: 0 auto;
    padding: 16px 18px 24px;
    border-top: 1px solid var(--flow-border, rgba(255, 255, 255, 0.08));
    color: var(--flow-muted-2, #6b7794);
    font-size: 0.76rem;
}

@media (min-width: 720px) {
    .footer-bottom { padding: 18px 24px 26px; }
}

.footer-legal { line-height: 1.5; }

.footer-wa {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 7px 13px;
    border-radius: 999px;
    border: 1px solid var(--flow-border-strong, rgba(255, 255, 255, 0.14));
    color: var(--flow-muted, #9aa4bf);
    font: 600 0.76rem/1.2 var(--flow-font, system-ui, sans-serif);
    text-decoration: none;
    transition: color 0.2s ease, border-color 0.2s ease, background 0.2s ease;
}

.footer-wa svg { width: 15px; height: 15px; flex: none; }

.footer-wa:hover {
    color: #fff;
    border-color: rgba(37, 99, 235, 0.6);
    background: rgba(37, 99, 235, 0.12);
}
/* ============================================================
   ACCESIBILIDAD: quien pide menos movimiento no ve el rayo
   ============================================================ */
@media (prefers-reduced-motion: reduce) {
    .flow-btn--primary::after { animation: none !important; }
    .flow-btn--primary:hover { transform: none; }
    .flow-ai-typing i { animation-duration: 2.4s; }
}

/* ============================================================
   CAPA DE EXPERIENCIA · VIEW TRANSITIONS (sitio multipágina)
   ------------------------------------------------------------
   La tienda es multipágina (Thymeleaf), así que la transición
   correcta es la "cross-document": el navegador toma una foto de
   la página que se va, navega y funde esa foto con la nueva. Se
   activa con esta única declaración; no hay que interceptar
   clics ni reescribir la navegación (Chrome 126+, Safari 18.2+).

   Donde no se soporte, el navegador descarta la regla sin error
   y la navegación ocurre exactamente igual que antes: ese es el
   respaldo, no hay nada que desactivar.
   ============================================================ */
@view-transition {
    navigation: auto;
}

/* 220/260 ms: por debajo de 200 ms se percibe como un parpadeo y por
   encima de 400 la web empieza a sentirse lenta. */
@media (prefers-reduced-motion: no-preference) {
    ::view-transition-old(root) {
        animation: flowVtOut 220ms cubic-bezier(0.4, 0, 0.2, 1) both;
    }

    ::view-transition-new(root) {
        animation: flowVtIn 260ms cubic-bezier(0.4, 0, 0.2, 1) both;
    }
}

@keyframes flowVtOut {
    from { opacity: 1; transform: none; }
    to   { opacity: 0; transform: scale(0.995); }
}

@keyframes flowVtIn {
    from { opacity: 0; transform: scale(1.005); }
    to   { opacity: 1; transform: none; }
}

/* Respaldo para navegadores sin View Transitions: un fundido de salida de
   180 ms que flow-ui.js aplica SOLO cuando document.startViewTransition no
   existe (junto a la transición nativa se verían dos fundidos superpuestos).
   Sin JavaScript, esta clase nunca aparece. */
html.flow-leaving body {
    opacity: 0.35;
    transition: opacity 180ms ease-out;
}
