/* ============================================================
   PWA Install — v13 (theme-aware)
   ============================================================
   Install button: floating circle with mobile icon (📱).
   Position is set via .pwa-install-cluster-left or -right
   based on ASE widget presence (handled in pwa.php).

   Theme integration:
   - Background: var(--gr-primary, #9f340b) Frankie's brown accent
   - Border:     var(--gr-primary-dark, #521700)
   - Icon color: var(--gr-text-on-primary, #F4ECD8) cream
   ============================================================ */

/* ------------------------------------------------------------
   Install Button (floating circle)
   ------------------------------------------------------------ */
.pwa-install-btn {
    position: fixed;
    bottom: 80px;
    width: 55px;
    height: 55px;
    border-radius: 50%;
    border: none;
    background: var(--gr-primary, #9f340b);
    color: var(--gr-text-on-primary, #F4ECD8);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
    z-index: 998;        /* WhatsApp 999, ASE genelde 9999 */
    cursor: pointer;
    display: none;        /* JS gösterir */
    align-items: center;
    justify-content: center;
    padding: 0;
    transition: transform 0.2s, box-shadow 0.2s;
    animation: pwa-pulse 3s ease-in-out infinite;
}

.pwa-install-btn:hover,
.pwa-install-btn:focus {
    transform: scale(1.08);
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35);
    color: var(--gr-text-on-primary, #F4ECD8);
    outline: none;
}

.pwa-install-btn:active {
    transform: scale(0.95);
}

/* Mini "download arrow" badge bottom-right of button */
.pwa-install-btn-badge {
    position: absolute;
    bottom: -2px;
    right: -2px;
    width: 20px;
    height: 20px;
    background: var(--gr-accent, #E8C766);
    color: #0A0A0A;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7em;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
    border: 2px solid var(--gr-primary, #9f340b);
}

/* Pulse animation — softer than WhatsApp's */
@keyframes pwa-pulse {
    0%   { box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25), 0 0 0 0 rgba(159, 52, 11, 0.5); }
    50%  { box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25), 0 0 0 12px rgba(159, 52, 11, 0); }
    100% { box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25), 0 0 0 0 rgba(159, 52, 11, 0); }
}

/* ------------------------------------------------------------
   Position Variants
   ------------------------------------------------------------
   ASE active   → WA solda, Install butonu WA'nın hemen sağında
                  (sol cluster: [WA] [Install]   ...   [ASE])
   ASE inactive → WA sağda, Install butonu WA'nın hemen solunda
                  (sağ cluster: ...   [Install] [WA])
   ------------------------------------------------------------ */

/* ASE inactive — Install button left of WhatsApp (right side cluster) */
.pwa-install-cluster-right {
    right: 87px;          /* WA = 20px right + 55px width + 12px gap */
}

/* ASE active — Install button right of WhatsApp (left side cluster) */
.pwa-install-cluster-left {
    left: 87px;           /* WA = 20px left + 55px width + 12px gap */
}

/* Mobile: same positions, slightly compressed */
@media (max-width: 575.98px) {
    .pwa-install-btn {
        bottom: 90px;
        width: 50px;
        height: 50px;
    }
    .pwa-install-cluster-right {
        right: 76px;       /* 16px + 50px + 10px */
    }
    .pwa-install-cluster-left {
        left: 76px;
    }
    .pwa-install-btn-badge {
        width: 18px;
        height: 18px;
        bottom: -2px;
        right: -2px;
    }
}

/* ------------------------------------------------------------
   iOS Fullscreen Modal
   ------------------------------------------------------------ */
.pwa-ios-modal {
    position: fixed;
    inset: 0;
    z-index: 10000;
    display: none;
    opacity: 0;
    transition: opacity 0.25s ease;
}
.pwa-ios-modal.show {
    display: block;
    opacity: 1;
}

.pwa-ios-modal-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.65);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

.pwa-ios-modal-content {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: calc(100% - 32px);
    max-width: 420px;
    max-height: calc(100vh - 64px);
    overflow-y: auto;
    background: #1a1a1a;
    color: #F4ECD8;
    border-radius: 20px;
    padding: 32px 24px 24px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(159, 52, 11, 0.3);
    text-align: center;
}

/* Light mode */
body:not(.theme-dark) .pwa-ios-modal-content {
    background: #fff;
    color: #2a2a2a;
    border-color: rgba(159, 52, 11, 0.2);
}

.pwa-ios-close {
    position: absolute;
    top: 8px;
    right: 12px;
    background: transparent;
    border: none;
    color: inherit;
    font-size: 32px;
    line-height: 1;
    cursor: pointer;
    padding: 6px 12px;
    opacity: 0.6;
    transition: opacity 0.2s;
}
.pwa-ios-close:hover {
    opacity: 1;
}

.pwa-ios-icon {
    margin-bottom: 16px;
}
.pwa-ios-icon img {
    width: 72px;
    height: 72px;
    border-radius: 16px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
}

.pwa-ios-title {
    font-size: 1.5em;
    font-weight: 700;
    margin: 0 0 8px;
    color: var(--gr-accent, #E8C766);
}
body:not(.theme-dark) .pwa-ios-title {
    color: var(--gr-primary-dark, #521700);
}

.pwa-ios-subtitle {
    font-size: 0.95em;
    margin: 0 0 24px;
    opacity: 0.85;
    line-height: 1.4;
}

.pwa-ios-steps {
    text-align: left;
    margin-bottom: 20px;
}

.pwa-ios-step {
    display: flex;
    gap: 14px;
    align-items: flex-start;
    margin-bottom: 18px;
    padding: 14px;
    background: rgba(159, 52, 11, 0.08);
    border-radius: 12px;
    border-left: 3px solid var(--gr-primary, #9f340b);
}

body:not(.theme-dark) .pwa-ios-step {
    background: rgba(159, 52, 11, 0.05);
}

.pwa-ios-step-num {
    flex-shrink: 0;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--gr-primary, #9f340b);
    color: var(--gr-text-on-primary, #F4ECD8);
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9em;
}

.pwa-ios-step-text {
    flex: 1;
    font-size: 0.95em;
    line-height: 1.5;
}

.pwa-ios-step-text strong {
    color: var(--gr-accent, #E8C766);
}
body:not(.theme-dark) .pwa-ios-step-text strong {
    color: var(--gr-primary-dark, #521700);
}

/* Inline icons (Share, Add) */
.pwa-ios-share-icon,
.pwa-ios-add-icon {
    display: inline-flex;
    align-items: center;
    vertical-align: middle;
    padding: 2px 6px;
    margin: 0 2px;
    background: rgba(159, 52, 11, 0.15);
    border-radius: 6px;
    color: var(--gr-accent, #E8C766);
}
body:not(.theme-dark) .pwa-ios-share-icon,
body:not(.theme-dark) .pwa-ios-add-icon {
    color: var(--gr-primary-dark, #521700);
    background: rgba(159, 52, 11, 0.1);
}

.pwa-ios-footer {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px dashed rgba(159, 52, 11, 0.25);
    opacity: 0.7;
    font-size: 0.85em;
}

/* Lock body scroll when modal open */
body.pwa-modal-open {
    overflow: hidden;
}

/* ------------------------------------------------------------
   Toast (generic feedback)
   ------------------------------------------------------------ */
.pwa-status-toast {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: #1a1a1a;
    color: #F4ECD8;
    padding: 12px 20px;
    border-radius: 999px;
    font-size: 0.9em;
    z-index: 10001;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(159, 52, 11, 0.3);
    opacity: 0;
    transition: transform 0.3s ease, opacity 0.3s ease;
    pointer-events: none;
    max-width: 90%;
    text-align: center;
}
.pwa-status-toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.pwa-toast-success { border-color: #25D366; color: #25D366; }
.pwa-toast-error   { border-color: #dc3545; color: #ff6b6b; }
.pwa-toast-progress { border-color: var(--gr-primary, #9f340b); color: var(--gr-accent, #E8C766); }

body:not(.theme-dark) .pwa-status-toast {
    background: #fff;
    color: #2a2a2a;
    border-color: rgba(159, 52, 11, 0.25);
}

/* ------------------------------------------------------------
   Reduced motion accessibility
   ------------------------------------------------------------ */
@media (prefers-reduced-motion: reduce) {
    .pwa-install-btn { animation: none; }
    .pwa-install-btn:hover { transform: none; }
}
