/* «اپلیکیشن بازارباشه» card above the phone's bottom bar (partials/app_download_banner.html).
 * The bottom bar is a 64px strip on the screen's bottom edge; the card floats 10px
 * above it, 14px in from the sides. While it shows, html.has-app-banner
 * lifts the support button and gives the page room at its end. */

.app-banner[hidden],
.app-banner-sheet[hidden] {
    display: none !important;
}

.app-banner {
    --ab-bottom: calc(74px + env(safe-area-inset-bottom, 0px));
    position: fixed;
    right: 14px;
    left: 14px;
    bottom: var(--ab-bottom);
    z-index: 999;
    direction: rtl;
    font-family: 'Estedad', sans-serif;
    /* Swiped sideways to dismiss (app-download-banner.js moves this element). */
    touch-action: pan-y;
    user-select: none;
    -webkit-user-select: none;
}

@keyframes app-banner-in {
    from {
        opacity: 0;
        transform: translateY(18px) scale(0.98);
    }
    to {
        opacity: 1;
        transform: none;
    }
}

.app-banner-card {
    display: flex;
    align-items: center;
    gap: 12px;
    height: 64px;
    padding: 0 8px 0 18px;
    border-radius: 999px;
    background: #fff;
    color: #1f2430;
    text-decoration: none;
    box-shadow: 0 10px 30px rgba(31, 36, 48, 0.16), 0 1px 3px rgba(31, 36, 48, 0.08);
    -webkit-tap-highlight-color: transparent;
    -webkit-user-drag: none;
    animation: app-banner-in 0.42s cubic-bezier(0.2, 0.9, 0.3, 1.15) both;
}

.app-banner img {
    -webkit-user-drag: none;
    pointer-events: none;
}

.app-banner-card:active {
    transform: scale(0.99);
}

.app-banner-card:focus-visible {
    outline: 2px solid #e8251c;
    outline-offset: 2px;
}

.app-banner-icon {
    flex: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: #fdecec;
}

.app-banner-icon img {
    display: block;
    width: 30px;
    height: 30px;
    object-fit: contain;
    mix-blend-mode: multiply;
}

.app-banner-text {
    display: flex;
    flex-direction: column;
    gap: 3px;
    min-width: 0;
    flex: 1;
}

.app-banner-text strong {
    font-size: 15px;
    font-weight: 400;
    line-height: 1.4;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.app-banner-text small {
    font-size: 12.5px;
    font-weight: 400;
    line-height: 1.4;
    color: #8a909c;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.app-banner-cta {
    flex: none;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 14px;
    font-weight: 400;
    color: #1f2430;
}

.app-banner-cta svg,
.app-banner-sheet-x svg {
    width: 18px;
    height: 18px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2.2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* Wherever the bottom bar is hidden (pages with a back button), the card goes too. */
body.platform-route-back-active .app-banner {
    display: none;
}

/* Room for the card: the support button moves up, the page's end clears it. */
html.has-app-banner body:not(.platform-route-back-active) .live-support-trigger {
    bottom: calc(150px + env(safe-area-inset-bottom, 0px));
}

html.has-app-banner body:not(.platform-route-back-active) .live-support-nudge {
    bottom: calc(220px + env(safe-area-inset-bottom, 0px));
}

@media (max-width: 1023px) {
    html.has-app-banner #mainAppContainer:has(> .info-footer),
    html.has-app-banner .info-page-wrap:has(.info-footer) {
        padding-bottom: calc(160px + env(safe-area-inset-bottom, 0px)) !important;
    }
}

@media (min-width: 1024px) {
    .app-banner,
    .app-banner-sheet {
        display: none !important;
    }
}

/* ---------- store chooser sheet ---------- */
.app-banner-sheet {
    position: fixed;
    inset: 0;
    z-index: 2300;
    direction: rtl;
    font-family: 'Estedad', sans-serif;
}

.app-banner-sheet-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15, 17, 22, 0.45);
    animation: app-banner-fade 0.2s ease both;
}

@keyframes app-banner-fade {
    from { opacity: 0; }
}

.app-banner-sheet-panel {
    position: absolute;
    right: 0;
    left: 0;
    bottom: 0;
    padding: 18px 20px calc(24px + env(safe-area-inset-bottom, 0px));
    border-radius: 24px 24px 0 0;
    background: #fff;
    color: #1f2430;
    box-shadow: 0 -12px 40px rgba(15, 17, 22, 0.18);
    animation: app-banner-sheet-in 0.3s cubic-bezier(0.2, 0.9, 0.3, 1) both;
}

@keyframes app-banner-sheet-in {
    from { transform: translateY(100%); }
}

.app-banner-sheet-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.app-banner-sheet-head strong {
    font-size: 16px;
    font-weight: 800;
}

.app-banner-sheet-x {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: #f3f4f6;
    color: #5b6170;
    cursor: pointer;
}

.app-banner-sheet-panel p {
    margin: 6px 0 16px;
    font-size: 13px;
    color: #8a909c;
}

.app-banner-sheet-badges {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

.app-banner-sheet-badges a {
    display: inline-flex;
    border-radius: 8px;
}

.app-banner-sheet-badges img {
    display: block;
    width: auto;
    height: 52px;
}

html.app-banner-sheet-open,
html.app-banner-sheet-open body {
    overflow: hidden;
}

/* ---------- dark theme ---------- */
body.theme-dark .app-banner-card,
body.theme-dark .app-banner-sheet-panel {
    background: #1d1f26;
    color: #f1f2f5;
}

body.theme-dark .app-banner-cta {
    color: #f1f2f5;
}

body.theme-dark .app-banner-card {
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45), inset 0 0 0 1px rgba(255, 255, 255, 0.06);
}

body.theme-dark .app-banner-icon {
    background: #fff;
}

body.theme-dark .app-banner-sheet-x {
    background: rgba(255, 255, 255, 0.08);
    color: #d6d9e0;
}

@media (prefers-reduced-motion: reduce) {
    .app-banner-card,
    .app-banner-sheet-backdrop,
    .app-banner-sheet-panel {
        animation: none;
    }
}
