/**
 * PWA Install — stili per:
 *   - Floating button bottom-right (sempre visibile, dismissibile)
 *   - Card sul profilo cliente
 *   - Modal istruzioni iOS (e fallback per Chrome desktop)
 *
 * Brand-aware tramite var --pwa-brand (settata da inline style nel partial).
 */

/* ─────────────────────────────────────────
   Floating button bottom-right
   ───────────────────────────────────────── */

#pwaFloatBtn {
    position: fixed;
    right: 14px;
    bottom: 14px;
    z-index: 9000;
    display: flex;
    align-items: center;
    gap: 0;
    background: var(--pwa-brand, #7c3aed);
    color: #fff;
    border-radius: 999px;
    box-shadow: 0 8px 24px rgba(124, 58, 237, 0.45);
    overflow: hidden;
    font-family: inherit;
    font-size: 14px;
    font-weight: 700;
    line-height: 1;
    animation: pwaFloatIn 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}

#pwaFloatBtn[hidden] { display: none !important; }

#pwaFloatBtn .pwa-float-main {
    background: transparent;
    color: inherit;
    border: 0;
    padding: 12px 18px 12px 14px;
    font: inherit;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
}

#pwaFloatBtn .pwa-float-main:hover {
    background: rgba(255, 255, 255, 0.1);
}

#pwaFloatBtn .pwa-float-icon {
    font-size: 18px;
    line-height: 1;
}

#pwaFloatBtn .pwa-float-close {
    background: rgba(0, 0, 0, 0.18);
    color: #fff;
    border: 0;
    width: 36px;
    height: 100%;
    min-height: 42px;
    cursor: pointer;
    font-size: 18px;
    font-weight: 400;
    line-height: 1;
    transition: background 0.15s ease;
}

#pwaFloatBtn .pwa-float-close:hover {
    background: rgba(0, 0, 0, 0.32);
}

@keyframes pwaFloatIn {
    from { opacity: 0; transform: translateY(20px) scale(0.85); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* Su mobile il floating button NON deve coprire il bottom bar di chat,
   call, etc. (gestito a livello di path-gating PHP — qui è solo difesa
   in profondità). */
@media (max-width: 480px) {
    #pwaFloatBtn {
        right: 10px;
        bottom: 10px;
        font-size: 13px;
    }
    #pwaFloatBtn .pwa-float-main {
        padding: 10px 14px 10px 12px;
    }
}

/* ─────────────────────────────────────────
   Card "Installa app" sul profilo cliente
   ───────────────────────────────────────── */

.pwa-card {
    margin: 16px 0;
    padding: 18px 20px;
    background: linear-gradient(135deg, var(--pwa-brand, #7c3aed) 0%, color-mix(in srgb, var(--pwa-brand, #7c3aed) 70%, #000 30%) 100%);
    color: #fff;
    border-radius: 14px;
    box-shadow: 0 6px 20px rgba(124, 58, 237, 0.25);
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}

.pwa-card[hidden] { display: none !important; }

.pwa-card-icon {
    font-size: 36px;
    line-height: 1;
    flex-shrink: 0;
}

.pwa-card-body {
    flex: 1;
    min-width: 200px;
}

.pwa-card-title {
    margin: 0 0 4px;
    font-size: 16px;
    font-weight: 800;
    line-height: 1.3;
}

.pwa-card-sub {
    margin: 0;
    font-size: 13px;
    line-height: 1.45;
    opacity: 0.94;
}

.pwa-card-btn {
    background: #fff;
    color: var(--pwa-brand, #7c3aed);
    border: 0;
    padding: 11px 22px;
    border-radius: 10px;
    font-family: inherit;
    font-size: 14px;
    font-weight: 800;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
    white-space: nowrap;
}

.pwa-card-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.22);
}

.pwa-card-btn:active {
    transform: translateY(0);
}

/* ─────────────────────────────────────────
   Modal istruzioni iOS
   ───────────────────────────────────────── */

.pwa-modal {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    animation: pwaModalIn 0.25s ease-out;
}

.pwa-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15, 12, 28, 0.72);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
}

.pwa-modal-card {
    position: relative;
    background: #fff;
    color: #1f1235;
    border-radius: 18px;
    padding: 24px 22px 22px;
    max-width: 420px;
    width: 100%;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    animation: pwaCardIn 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

.pwa-modal-close {
    position: absolute;
    top: 10px;
    right: 12px;
    background: transparent;
    border: 0;
    font-size: 26px;
    line-height: 1;
    color: #6b7280;
    cursor: pointer;
    width: 36px;
    height: 36px;
    border-radius: 8px;
}

.pwa-modal-close:hover {
    background: #f3f4f6;
    color: #111;
}

.pwa-modal-title {
    margin: 0 32px 4px 0;
    font-size: 18px;
    font-weight: 800;
    line-height: 1.3;
    color: var(--pwa-brand, #7c3aed);
}

.pwa-modal-sub {
    margin: 0 0 16px;
    font-size: 14px;
    color: #6b7280;
}

.pwa-modal-steps {
    list-style: none;
    margin: 0 0 14px;
    padding: 0;
}

.pwa-modal-steps li {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    padding: 10px 0;
    border-bottom: 1px solid #f3f4f6;
    font-size: 14.5px;
    line-height: 1.5;
}

.pwa-modal-steps li:last-child {
    border-bottom: 0;
}

.pwa-step-num {
    flex-shrink: 0;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--pwa-brand, #7c3aed);
    color: #fff;
    font-weight: 800;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* SVG iOS share icon inline (square with arrow up) */
.pwa-share-icon {
    display: inline-block;
    width: 18px;
    height: 22px;
    background: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 28' fill='none' stroke='%231f1235' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><path d='M12 16V4M8 8l4-4 4 4'/><path d='M5 13v9a2 2 0 002 2h10a2 2 0 002-2v-9'/></svg>") no-repeat center / contain;
    vertical-align: -5px;
    margin: 0 1px;
}

.pwa-modal-foot {
    margin: 14px 0 0;
    padding: 12px 14px;
    background: #f5f3ff;
    border-radius: 10px;
    font-size: 13px;
    color: #5b21b6;
    line-height: 1.45;
}

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

@keyframes pwaCardIn {
    from { opacity: 0; transform: translateY(30px) scale(0.95); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* ─────────────────────────────────────────
   Toast "✓ App installata"
   ───────────────────────────────────────── */

.pwa-toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    z-index: 10000;
    background: #16a34a;
    color: #fff;
    padding: 12px 18px;
    border-radius: 10px;
    font-weight: 700;
    font-size: 14px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
    opacity: 0;
    transition: opacity 0.3s ease, transform 0.3s ease;
}

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