/* Módulo: PWA + toasts
   Parciales asociados:
   - resources/views/catalogo/partials/scripts.blade.php (banner #pwa-install-banner)
   - public/catalogo/js/productos.js (notificaciones inline usan slideInRight / slideOutRight)
   Responsabilidad:
   - @keyframes slideInRight, slideOutRight (toasts en productos.js: safe-area top/right inline)
   - .pwa-banner, controles instalación, safe-area inferior en home indicator
   Z-index banner 9999 (evitar solape con modales abiertos: el banner se oculta con .hidden)
*/
@keyframes slideInRight {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes slideOutRight {
    from {
        transform: translateX(0);
        opacity: 1;
    }
    to {
        transform: translateX(100%);
        opacity: 0;
    }
}

/* PWA Install Banner — bottom sheet flotante (iOS / Material) */
.pwa-banner {
    position: fixed;
    left: 50%;
    bottom: calc(12px + env(safe-area-inset-bottom, 0px));
    width: min(480px, calc(100% - 24px));
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    background: #ffffff;
    border: 1px solid #f1f5f9;
    border-radius: 28px;
    box-shadow:
        0 24px 48px rgba(15, 23, 42, 0.12),
        0 8px 20px rgba(15, 23, 42, 0.06),
        inset 0 1px 0 rgba(255, 255, 255, 0.85);
    z-index: 9999;
    transition: transform .38s cubic-bezier(.22, 1, .36, 1), opacity .28s ease;
    overflow: hidden;
}

.pwa-banner.hidden {
    opacity: 0;
    transform: translateX(-50%) translateY(calc(110% + 24px));
    pointer-events: none;
}

.pwa-banner-handle {
    flex-shrink: 0;
    width: 42px;
    height: 5px;
    margin: 10px auto 2px;
    border-radius: 999px;
    background: #e2e8f0;
}

.pwa-banner-close {
    position: absolute;
    top: 14px;
    right: 14px;
    z-index: 2;
    width: 28px;
    height: 28px;
    padding: 0;
    border: 0;
    border-radius: 999px;
    background: rgba(248, 250, 252, 0.9);
    color: #94a3b8;
    font-size: 14px;
    line-height: 1;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background .15s ease, color .15s ease;
}

.pwa-banner-close:hover {
    background: #f1f5f9;
    color: #64748b;
}

.pwa-banner-content {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 44px 18px 18px;
    min-height: 72px;
}

.pwa-logo {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    object-fit: cover;
    background: #f3f4f6;
    flex: 0 0 48px;
    box-shadow: 0 2px 8px rgba(15, 23, 42, 0.08);
}

.pwa-text-title {
    flex: 1;
    min-width: 0;
    font-size: 15px;
    font-weight: 600;
    color: #111827;
    letter-spacing: -0.01em;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

#pwa-install-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    flex-shrink: 0;
    margin-left: auto;
    background: #cd0220;
    color: #fff;
    border: none;
    padding: 10px 16px;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 600;
    line-height: 1;
    cursor: pointer;
    white-space: nowrap;
    box-shadow: 0 6px 16px rgba(205, 2, 32, 0.28);
    transition: background .15s ease, box-shadow .15s ease, transform .15s ease;
}

#pwa-install-btn:hover {
    background: #b8011c;
    box-shadow: 0 8px 20px rgba(205, 2, 32, 0.32);
}

#pwa-install-btn:active {
    transform: translateY(1px);
}

#pwa-install-btn i {
    font-size: 11px;
    opacity: 0.95;
}

@media (max-width: 380px) {
    .pwa-banner {
        width: calc(100% - 20px);
        bottom: calc(10px + env(safe-area-inset-bottom, 0px));
        border-radius: 24px;
    }

    .pwa-banner-content {
        gap: 10px;
        padding: 8px 40px 16px 14px;
    }

    .pwa-logo {
        width: 44px;
        height: 44px;
        flex-basis: 44px;
    }

    .pwa-text-title {
        font-size: 14px;
    }

    #pwa-install-btn {
        padding: 9px 12px;
        font-size: 12px;
    }
}

.update-toast {
    position: fixed;
    bottom: calc(20px + env(safe-area-inset-bottom, 0px));
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: #111827;
    color: #fff;
    padding: 12px 18px;
    border-radius: 12px;
    font-size: 14px;
    z-index: 9999;
    opacity: 0;
    pointer-events: none;
    transition: all 0.3s ease;
    box-shadow: 0 10px 25px rgba(0,0,0,0.2);
}

.update-toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}
