/* ================================================================
   pwa-install.css — Botão flutuante de instalação PWA + Barra de
   progresso + Modal de instruções iOS
   Integrado ao sistema de temas via variáveis CSS do tema ativo.
   ================================================================ */

/* ----------------------------------------------------------------
   Botão Flutuante de Instalação
   ---------------------------------------------------------------- */
#pwa-install-btn {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 8500;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 13px 20px;
    background: var(--accent, #c9a227);
    color: var(--btn-text, #000);
    border: none;
    border-radius: 50px;
    font-family: var(--font-main, 'Montserrat', sans-serif);
    font-size: 0.88rem;
    font-weight: 700;
    cursor: pointer;
    letter-spacing: 0.3px;
    white-space: nowrap;
    max-width: calc(100vw - 48px);

    /* Estado inicial: invisível e deslocado para baixo */
    opacity: 0;
    pointer-events: none;
    transform: translateY(20px);

    /* Sombra dupla para profundidade */
    box-shadow:
        0 4px 20px rgba(0, 0, 0, 0.4),
        0 2px 8px rgba(0, 0, 0, 0.25);

    /* Transições de entrada e hover */
    transition:
        opacity 0.4s ease,
        transform 0.4s ease,
        box-shadow 0.25s ease;

    will-change: transform, opacity;
}

/* Estado visível — adicionado via JS após evento beforeinstallprompt / iOS */
#pwa-install-btn.pwa-visible {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
}

#pwa-install-btn:hover {
    transform: translateY(-3px);
    box-shadow:
        0 8px 28px rgba(0, 0, 0, 0.45),
        0 4px 12px rgba(0, 0, 0, 0.3);
}

#pwa-install-btn:active {
    transform: translateY(0) scale(0.96);
    box-shadow:
        0 2px 10px rgba(0, 0, 0, 0.3),
        0 1px 4px rgba(0, 0, 0, 0.2);
}

/* Ícone SVG dentro do botão */
#pwa-install-btn .pwa-btn-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 20px;
    height: 20px;
}

#pwa-install-btn .pwa-btn-icon svg {
    width: 20px;
    height: 20px;
    fill: currentColor;
}

/* Animação de pulso para chamar atenção (executa 3× após aparecer) */
@keyframes pwa-btn-pulse {
    0%, 100% {
        box-shadow:
            0 4px 20px rgba(0, 0, 0, 0.4),
            0 0 0 0 color-mix(in srgb, var(--accent, #c9a227) 55%, transparent);
    }
    50% {
        box-shadow:
            0 4px 20px rgba(0, 0, 0, 0.4),
            0 0 0 12px transparent;
    }
}

#pwa-install-btn.pwa-visible {
    animation: pwa-btn-pulse 2.8s ease-in-out 1.2s 3;
}

/* ----------------------------------------------------------------
   Overlay de Progresso de Instalação
   ---------------------------------------------------------------- */
#pwa-progress-overlay {
    position: fixed;
    inset: 0;
    z-index: 99990;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;

    background: rgba(0, 0, 0, 0.82);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);

    opacity: 0;
    pointer-events: none;
    transition: opacity 0.35s ease;
}

#pwa-progress-overlay.pwa-active {
    opacity: 1;
    pointer-events: auto;
}

/* Card central do progresso */
.pwa-progress-card {
    background: var(--bg-card, #1e1e1e);
    border-radius: 22px;
    padding: 2.5rem 2rem 2rem;
    width: min(380px, 100%);
    text-align: center;
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.55);
    transform: scale(0.88);
    transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}

#pwa-progress-overlay.pwa-active .pwa-progress-card {
    transform: scale(1);
}

/* Ícone do app dentro do card */
.pwa-progress-logo {
    width: 76px;
    height: 76px;
    border-radius: 18px;
    margin: 0 auto 1.25rem;
    display: block;
    transition: opacity 0.3s;
}

/* Ícone de sucesso (checkmark) — oculto até estado "done" */
.pwa-success-icon {
    display: none;
    width: 72px;
    height: 72px;
    background: var(--accent, #c9a227);
    border-radius: 50%;
    margin: 0 auto 1.25rem;
    align-items: center;
    justify-content: center;

    /* Animação de escala ao aparecer */
    transform: scale(0);
    transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.pwa-success-icon svg {
    fill: var(--btn-text, #000);
    width: 36px;
    height: 36px;
}

/* Estado de conclusão */
.pwa-progress-card.pwa-done .pwa-progress-logo {
    display: none;
}

.pwa-progress-card.pwa-done .pwa-success-icon {
    display: flex;
    transform: scale(1);
}

.pwa-progress-card h3 {
    color: var(--text, #fff);
    font-family: var(--font-main, 'Montserrat', sans-serif);
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: 0.4rem;
}

/* Mensagem de status — transiciona suavemente ao trocar */
.pwa-progress-msg {
    color: var(--text-secondary, #999);
    font-family: var(--font-main, 'Montserrat', sans-serif);
    font-size: 0.85rem;
    margin-bottom: 1.5rem;
    min-height: 1.2em;
    transition: opacity 0.2s ease;
    line-height: 1.4;
}

/* Trilha da barra de progresso */
.pwa-progress-track {
    width: 100%;
    height: 9px;
    border-radius: 99px;
    overflow: hidden;
    margin-bottom: 0.65rem;
    background: color-mix(in srgb, var(--accent, #c9a227) 18%, var(--bg-card, #1e1e1e));
}

/* Preenchimento da barra de progresso */
.pwa-progress-fill {
    height: 100%;
    width: 0%;
    background: var(--accent, #c9a227);
    border-radius: 99px;
    transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Percentual numérico */
.pwa-progress-pct {
    color: var(--accent, #c9a227);
    font-family: var(--font-main, 'Montserrat', sans-serif);
    font-size: 0.9rem;
    font-weight: 700;
}

/* ----------------------------------------------------------------
   Modal de Instruções para iOS (Safari)
   ---------------------------------------------------------------- */
#pwa-ios-modal {
    position: fixed;
    inset: 0;
    z-index: 99990;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    padding: 0 12px 12px;

    background: rgba(0, 0, 0, 0.78);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);

    opacity: 0;
    pointer-events: none;
    transition: opacity 0.35s ease;
}

#pwa-ios-modal.pwa-active {
    opacity: 1;
    pointer-events: auto;
}

/* Card que sobe a partir do fundo (sheet-style) */
.pwa-ios-card {
    background: var(--bg-card, #1e1e1e);
    border-radius: 20px;
    padding: 1.5rem 1.5rem 2rem;
    width: 100%;
    max-width: 440px;
    position: relative;
    transform: translateY(28px);
    transition: transform 0.4s cubic-bezier(0.34, 1.3, 0.64, 1);
}

#pwa-ios-modal.pwa-active .pwa-ios-card {
    transform: translateY(0);
}

/* Handle visual no topo do sheet */
.pwa-ios-handle {
    width: 40px;
    height: 5px;
    border-radius: 3px;
    background: rgba(255, 255, 255, 0.18);
    margin: 0 auto 1.25rem;
}

/* Botão de fechar */
.pwa-ios-close {
    position: absolute;
    top: 14px;
    right: 14px;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: var(--text, #fff);
    width: 30px;
    height: 30px;
    border-radius: 50%;
    font-size: 1.1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    transition: background 0.2s;
}

.pwa-ios-close:hover {
    background: rgba(255, 255, 255, 0.18);
}

.pwa-ios-card h3 {
    color: var(--text, #fff);
    font-family: var(--font-main, 'Montserrat', sans-serif);
    font-size: 1.05rem;
    font-weight: 700;
    margin-bottom: 1.25rem;
    padding-right: 2.5rem;
    line-height: 1.3;
}

/* Lista de passos */
.pwa-ios-steps {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.pwa-ios-step {
    display: flex;
    align-items: flex-start;
    gap: 12px;
}

/* Número do passo */
.pwa-ios-step-num {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: var(--accent, #c9a227);
    color: var(--btn-text, #000);
    font-family: var(--font-main, 'Montserrat', sans-serif);
    font-weight: 700;
    font-size: 0.82rem;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    margin-top: 1px;
}

/* Texto do passo */
.pwa-ios-step-text {
    color: var(--text, #fff);
    font-family: var(--font-main, 'Montserrat', sans-serif);
    font-size: 0.88rem;
    line-height: 1.45;
}

.pwa-ios-step-text strong {
    color: var(--accent, #c9a227);
    font-weight: 700;
}

/* Ícone inline dentro da instrução */
.pwa-ios-inline-icon {
    display: inline-flex;
    align-items: center;
    vertical-align: middle;
    margin: 0 2px;
    opacity: 0.9;
}

.pwa-ios-inline-icon svg {
    width: 18px;
    height: 18px;
    fill: currentColor;
}

/* ----------------------------------------------------------------
   Responsividade
   ---------------------------------------------------------------- */
@media (max-width: 480px) {
    #pwa-install-btn {
        bottom: 16px;
        right: 16px;
        padding: 11px 16px;
        font-size: 0.83rem;
        gap: 8px;
    }

    .pwa-progress-card {
        padding: 2rem 1.5rem 1.75rem;
        border-radius: 18px;
    }

    .pwa-ios-card {
        padding: 1.25rem 1.25rem 1.75rem;
    }
}

/* Garante que o botão não sobrepõe barras de navegação em iOS */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
    #pwa-install-btn {
        bottom: calc(24px + env(safe-area-inset-bottom));
    }

    @media (max-width: 480px) {
        #pwa-install-btn {
            bottom: calc(16px + env(safe-area-inset-bottom));
        }
    }
}
