/**
 * Shaaf PWA و نوتیفیکیشن - بنر نصب، راهنمای آیفون، بنر عضویت در اعلان، نوتیفیکیشن داخل صفحه
 * مسیر فایل: wp-content/plugins/shaaf/assets/css/shaaf-pwa.css
 *
 * همه کارت ها داخل یک ستون (.shaaf-pwa-stack) قرار می گیرند:
 * - کامپیوتر: گوشه چپ صفحه؛ کارت بعدی زیر کارت قبلی می آید و روی هم نمی افتند.
 * - موبایل: تمام عرض پایین صفحه و روی منوی پایین (منو کامل پوشانده می شود)؛ کارت ها زیر هم.
 */
.shaaf-pwa-stack,
.shaaf-pwa-toast {
    direction: rtl;
    font-family: inherit;
    box-sizing: border-box;
}

.shaaf-pwa-stack *, .shaaf-pwa-toast * { box-sizing: border-box; }

/* ---------- ستون کارت ها ---------- */
.shaaf-pwa-stack {
    position: fixed;
    z-index: 100000;
    display: flex;
    flex-direction: column;
    gap: 12px;
    pointer-events: none;
}

.shaaf-pwa-stack:empty { display: none; }

.shaaf-pwa-stack.is-desktop {
    left: 20px;
    width: 380px;
    max-width: calc(100vw - 40px);
    max-height: calc(100vh - 40px);
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-width: none;
}

.shaaf-pwa-stack.is-desktop::-webkit-scrollbar { display: none; }
.shaaf-pwa-stack.is-desktop.is-top { top: 20px; }
.shaaf-pwa-stack.is-desktop.is-bottom { bottom: 20px; }
body.admin-bar .shaaf-pwa-stack.is-desktop.is-top { top: 52px; }

.shaaf-pwa-stack.is-mobile {
    right: 0;
    left: 0;
    width: 100%;
    max-height: 88vh;
    overflow-y: auto;
    overscroll-behavior: contain;
}

.shaaf-pwa-stack.is-mobile.is-bottom {
    bottom: 0;
    gap: 8px;
    padding: 0 0 env(safe-area-inset-bottom, 0);
    background: transparent;
}

.shaaf-pwa-stack.is-mobile.is-top { top: 0; padding: env(safe-area-inset-top, 0) 0 0; gap: 8px; }

/* ---------- کارت ---------- */
.shaaf-pwa-card {
    position: relative;
    width: 100%;
    padding: 18px;
    border: 1px solid #e3e9ee;
    border-radius: 22px;
    background: #fff;
    color: #172033;
    box-shadow: 0 24px 60px rgba(17, 38, 60, .22);
    pointer-events: auto;
    opacity: 0;
    transform: translateY(-10px);
    transition: opacity .25s ease, transform .25s ease;
}

.is-bottom > .shaaf-pwa-card { transform: translateY(14px); }
.shaaf-pwa-card.is-visible { opacity: 1; transform: none; }
.shaaf-pwa-card.is-leaving { opacity: 0; }

/* موبایل: کارت ها تمام عرض و چسبیده به پایین، با ارتفاع کافی برای پوشاندن کامل منوی پایین */
.shaaf-pwa-stack.is-mobile .shaaf-pwa-card {
    min-height: 112px;
    padding: 18px 16px 16px;
    border-right: 0;
    border-left: 0;
    border-radius: 22px 22px 0 0;
    box-shadow: 0 -12px 40px rgba(17, 38, 60, .2);
}

.shaaf-pwa-stack.is-mobile .shaaf-pwa-card + .shaaf-pwa-card { border-radius: 22px 22px 0 0; }
.shaaf-pwa-stack.is-mobile.is-bottom .shaaf-pwa-card:not(:last-child) { border-radius: 22px; margin: 0 8px; width: auto; box-shadow: 0 10px 30px rgba(17, 38, 60, .18); }
.shaaf-pwa-stack.is-mobile.is-top .shaaf-pwa-card { border-radius: 0 0 22px 22px; }

.shaaf-pwa-close {
    position: absolute;
    top: 10px;
    left: 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    padding: 0;
    border: 0;
    border-radius: 10px;
    background: transparent;
    color: #7a8696;
    cursor: pointer;
}

.shaaf-pwa-close:hover, .shaaf-pwa-close:focus-visible { background: #f1f5f9; color: #172033; }

.shaaf-pwa-card-head { display: flex; align-items: center; gap: 12px; padding-left: 34px; margin-bottom: 10px; }
.shaaf-pwa-card-head > div { min-width: 0; }
.shaaf-pwa-card-head strong { display: block; font-size: 15px; font-weight: 900; line-height: 1.7; }
.shaaf-pwa-card-head small { display: block; color: #6b7789; font-size: 12px; line-height: 1.8; }
.shaaf-pwa-card-head small.is-body { color: #475569; font-size: 13px; line-height: 1.9; }

.shaaf-pwa-app-icon {
    display: inline-flex;
    flex: 0 0 52px;
    align-items: center;
    justify-content: center;
    width: 52px;
    height: 52px;
    overflow: hidden;
    border-radius: 15px;
    background: #e9f8ef;
    color: #00a651;
    box-shadow: 0 6px 16px rgba(17, 38, 60, .12);
}

.shaaf-pwa-app-icon img { width: 100%; height: 100%; object-fit: cover; }
.shaaf-pwa-app-icon.is-bell { background: #fff4e5; color: #d97706; }

.shaaf-pwa-banner-text { margin: 0 0 14px; color: #475569; font-size: 13px; line-height: 2; }

/* راهنمای آیفون */
.shaaf-pwa-steps { display: flex; flex-direction: column; gap: 8px; margin: 6px 0 4px !important; padding: 0 !important; list-style: none !important; }

.shaaf-pwa-steps li {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0 !important;
    padding: 10px 12px;
    border-radius: 14px;
    background: #f7f9fb;
    color: #334155;
    font-size: 13px;
    line-height: 1.9;
    list-style: none !important;
}

.shaaf-pwa-steps li > span {
    display: inline-flex;
    flex: 0 0 26px;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    border-radius: 9px;
    background: #00a651;
    color: #fff;
    font-weight: 900;
    font-size: 12px;
}

.shaaf-pwa-steps li > div { flex: 1 1 auto; min-width: 0; }

.shaaf-pwa-inline-icon {
    display: inline-flex;
    vertical-align: middle;
    padding: 2px 4px;
    border-radius: 6px;
    background: #e8f1ff;
    color: #2563eb;
}

/* دکمه ها */
.shaaf-pwa-actions { display: flex; gap: 8px; }

.shaaf-pwa-btn {
    display: inline-flex;
    flex: 1 1 auto;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 44px;
    padding: 8px 16px;
    border: 1px solid transparent;
    border-radius: 50px;
    font: inherit;
    font-size: 13.5px;
    font-weight: 800;
    line-height: 1.4;
    text-decoration: none !important;
    cursor: pointer;
}

.shaaf-pwa-btn.is-primary { background: linear-gradient(135deg, #00b85a 0%, #058a4b 100%); color: #fff !important; }
.shaaf-pwa-btn.is-primary:hover { filter: brightness(1.05); }
.shaaf-pwa-btn.is-ghost { flex: 0 0 auto; background: #fff; border-color: #e3e9ee; color: #475569; }
.shaaf-pwa-btn.is-block { display: flex; width: 100%; margin-top: 12px; }
.shaaf-pwa-btn:focus-visible { outline: 3px solid rgba(0, 166, 81, .45); outline-offset: 2px; }

/* ---------- نوتیفیکیشن اختصاصی داخل صفحه ---------- */
.shaaf-pwa-card.is-notify {
    overflow: hidden;
    border-color: #cdeedb;
    box-shadow: 0 24px 60px rgba(0, 110, 55, .22);
}

.shaaf-pwa-card.is-notify::before {
    content: "";
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    width: 4px;
    background: linear-gradient(180deg, #00b85a, #058a4b);
}

.shaaf-pwa-card.is-notify.is-visible .shaaf-pwa-app-icon { animation: shaafPwaRing .9s ease 1; }
.shaaf-pwa-card.is-notify .shaaf-pwa-btn.is-block { margin-top: 10px; }

.shaaf-pwa-notify-image {
    display: block;
    width: 100%;
    max-height: 190px;
    margin-top: 4px;
    border-radius: 14px;
    object-fit: cover;
}

.shaaf-pwa-notify-timer {
    position: absolute;
    right: 0;
    bottom: 0;
    left: 0;
    height: 3px;
    background: #00a651;
    transform-origin: right;
    transform: scaleX(0);
    opacity: .35;
}

.shaaf-pwa-card.is-notify.is-timing .shaaf-pwa-notify-timer { animation: shaafPwaTimer 12s linear forwards; }

/* ---------- پیام آفلاین ---------- */
.shaaf-pwa-toast {
    position: fixed;
    top: 16px;
    left: 50%;
    z-index: 100002;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 18px;
    border-radius: 50px;
    background: #172033;
    color: #fff;
    font-size: 13px;
    font-weight: 700;
    box-shadow: 0 12px 30px rgba(15, 23, 42, .3);
    opacity: 0;
    transform: translate(-50%, -12px);
    transition: opacity .25s ease, transform .25s ease;
}

.shaaf-pwa-toast.is-visible { opacity: 1; transform: translate(-50%, 0); }

@keyframes shaafPwaRing {
    0%, 100% { transform: rotate(0); }
    20% { transform: rotate(-10deg); }
    40% { transform: rotate(8deg); }
    60% { transform: rotate(-5deg); }
    80% { transform: rotate(3deg); }
}

@keyframes shaafPwaTimer { from { transform: scaleX(1); } to { transform: scaleX(0); } }

@media (prefers-reduced-motion: reduce) {
    .shaaf-pwa-card, .shaaf-pwa-toast { transition: none; }
    .shaaf-pwa-card.is-notify.is-visible .shaaf-pwa-app-icon { animation: none; }
}

@media print {
    .shaaf-pwa-stack, .shaaf-pwa-toast { display: none !important; }
}
