/* ==========================================================================
   YadakTeb.ir — patches.css
   ==========================================================================
   فیکس‌های نهایی روی topbar موبایل + آکاردئون زیردسته‌ها +
   Skeleton Loader + Recent Viewed
   ==========================================================================
   این فایل بعد از theme_style_tag لود می‌شود و از !important استفاده
   می‌کند تا بر تمام CSS های قبلی غالب شود.
   ========================================================================== */

/* ═════════════════════════════════════════════════════════════════
   1) [FIX] Topbar در موبایل — نمایش کامل بدون بریدگی
   ═════════════════════════════════════════════════════════════════ */
@media (max-width: 768px) {
    .nk-topbar {
        min-height: auto !important;
        padding-block: 8px !important;
    }
    .nk-topbar-inner {
        flex-direction: column !important;
        align-items: stretch !important;
        justify-content: center !important;
        gap: 8px !important;
        min-height: auto !important;
    }
    .nk-topbar-msg {
        justify-content: center !important;
        text-align: center !important;
        width: 100% !important;
    }
    .nk-topbar-msg span {
        white-space: normal !important;
        overflow: visible !important;
        text-overflow: clip !important;
        max-width: 100% !important;
        font-size: 11.5px !important;
        line-height: 1.55 !important;
        display: block !important;
    }
    .nk-topbar-links {
        justify-content: center !important;
        flex-wrap: wrap !important;
        gap: 12px !important;
        width: 100% !important;
    }
    .nk-topbar-links a {
        font-size: 11.5px !important;
        padding: 2px 4px !important;
        opacity: .9 !important;
    }
    .nk-topbar-links a span { display: inline !important; }
    .nk-topbar-links a svg { width: 12px !important; height: 12px !important; }
    .nk-topbar-links .nk-divider {
        display: inline-block !important;
        height: 10px !important;
    }
}

@media (max-width: 480px) {
    .nk-topbar-msg span { font-size: 11px !important; }
    .nk-topbar-links { gap: 8px !important; }
    .nk-topbar-links a { font-size: 11px !important; }
    .nk-topbar-links a span {
        display: inline !important;
        max-width: 90px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
}

/* ═════════════════════════════════════════════════════════════════
   2) Mobile Nav — Categories Accordion
   ═════════════════════════════════════════════════════════════════ */
.nk-mobile-nav-cats-accordion {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.nk-mnc-acc {
    border-radius: 10px;
    overflow: hidden;
    background: var(--soft, #F2F4F7);
    margin-bottom: 0;
}

.nk-mnc-toggle {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 12px 12px;
    min-height: 46px;
    background: transparent;
    border: 0;
    color: var(--ink-2, #344054);
    font-family: inherit;
    font-size: 13px;
    font-weight: 600;
    text-align: right;
    cursor: pointer;
    transition: background .18s ease, color .18s ease;
}
.nk-mnc-toggle:hover {
    background: var(--brand-primary-soft, #E6F2F6);
    color: var(--brand-primary-text, #0E7490);
}
.nk-mnc-toggle.is-open {
    color: var(--brand-primary-text, #0E7490);
    background: var(--brand-primary-soft, #E6F2F6);
}
.nk-mnc-toggle svg {
    flex-shrink: 0;
    color: var(--brand-primary, #0E7490);
}
.nk-mnc-toggle > span:first-of-type {
    flex: 1;
    min-width: 0;
    text-align: right;
}

.nk-mnc-arrow {
    transition: transform .25s cubic-bezier(.4, 0, .2, 1);
    flex-shrink: 0;
    color: var(--muted, #98A2B3);
}
.nk-mnc-toggle.is-open .nk-mnc-arrow {
    transform: rotate(180deg);
}

.nk-mnc-body {
    display: none;
    padding: 4px 8px 10px;
    background: #fff;
    border-radius: 0 0 10px 10px;
}
.nk-mnc-body.is-open {
    display: block;
}
.nk-mnc-body a {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 9px 10px;
    min-height: 40px;
    font-size: 12.5px;
    color: var(--ink-2, #344054);
    border-radius: 8px;
    text-decoration: none;
    transition: background .15s ease, color .15s ease;
}
.nk-mnc-body a:hover {
    background: var(--soft, #F2F4F7);
    color: var(--brand-primary-text, #0E7490);
}
.nk-mnc-all {
    font-weight: 700;
    color: var(--brand-primary-text, #0E7490) !important;
    border-bottom: 1px dashed var(--line, #E4E7EC);
    margin-bottom: 4px;
    border-radius: 0 !important;
}

.nk-mnc-single {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 12px;
    min-height: 46px;
    background: var(--soft, #F2F4F7);
    border-radius: 10px;
    color: var(--ink-2, #344054);
    font-size: 13px;
    font-weight: 600;
    text-decoration: none;
    transition: background .18s ease, color .18s ease;
}
.nk-mnc-single:hover {
    background: var(--brand-primary-soft, #E6F2F6);
    color: var(--brand-primary-text, #0E7490);
}
.nk-mnc-single svg {
    flex-shrink: 0;
    color: var(--brand-primary, #0E7490);
}

/* Dark mode */
[data-theme="dark"] .nk-mnc-acc { background: var(--soft, #1a2338); }
[data-theme="dark"] .nk-mnc-body { background: var(--card, #111a2b); }
[data-theme="dark"] .nk-mnc-toggle:hover,
[data-theme="dark"] .nk-mnc-toggle.is-open { background: rgba(14, 116, 144, .18); }
[data-theme="dark"] .nk-mnc-body a:hover { background: rgba(255,255,255,.04); }
[data-theme="dark"] .nk-mnc-single { background: var(--soft, #1a2338); }
[data-theme="dark"] .nk-mnc-single:hover { background: rgba(14, 116, 144, .18); }

/* ═════════════════════════════════════════════════════════════════
   3) Image Skeleton / Shimmer
   ═════════════════════════════════════════════════════════════════ */

@keyframes yt-shimmer {
    0%   { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

/* تصویر جدید تا لود شدن مخفی */
.product-media img,
.nk-cat-circle-img img,
.nk-brand-logo-wrap img,
.article-tile-cover img,
.nk-bs-img img,
.nk-rv-image img {
    transition: opacity .35s ease;
}

/* Skeleton shimmer برای کانتینرها تا زمان is-loaded */
.product-media:not(.is-loaded),
.nk-cat-circle-img:not(.is-loaded),
.nk-brand-logo-wrap:not(.is-loaded),
.article-tile-cover:not(.is-loaded),
.nk-bs-img:not(.is-loaded) {
    background: linear-gradient(
        90deg,
        var(--soft, #F2F4F7) 0%,
        var(--soft-2, #EAECF0) 50%,
        var(--soft, #F2F4F7) 100%
    ) !important;
    background-size: 200% 100% !important;
    animation: yt-shimmer 1.4s linear infinite !important;
}

/* وقتی لود شد، پس‌زمینه سفید */
.product-media.is-loaded,
.nk-cat-circle-img.is-loaded,
.nk-brand-logo-wrap.is-loaded,
.article-tile-cover.is-loaded,
.nk-bs-img.is-loaded {
    background: #fff;
    animation: none;
}

/* کاهش motion */
@media (prefers-reduced-motion: reduce) {
    .product-media:not(.is-loaded),
    .nk-cat-circle-img:not(.is-loaded),
    .nk-brand-logo-wrap:not(.is-loaded),
    .article-tile-cover:not(.is-loaded),
    .nk-bs-img:not(.is-loaded) {
        animation: none !important;
    }
}

/* ═════════════════════════════════════════════════════════════════
   4) Recent Viewed — «بازدیدهای اخیر شما»
   ═════════════════════════════════════════════════════════════════ */
.nk-recent-viewed {
    padding: 32px 0;
    background: #fff;
    border-top: 1px solid var(--line, #E4E7EC);
    display: none; /* تا وقتی محتوا نبود نمایش داده نشه */
}
.nk-recent-viewed.is-visible {
    display: block;
}

.nk-recent-viewed h2 {
    font-size: 1.15rem;
    font-weight: 800;
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0 0 18px;
    padding-inline-start: 0;
    color: var(--ink, #101828);
}
.nk-recent-viewed h2::before {
    content: '';
    width: 4px;
    height: 20px;
    background: var(--brand-primary, #0E7490);
    border-radius: 3px;
    flex-shrink: 0;
}

.nk-rv-track {
    display: flex;
    gap: 12px;
    overflow-x: auto;
    overflow-y: hidden;
    scroll-snap-type: x mandatory;
    scroll-behavior: smooth;
    scrollbar-width: none;
    -ms-overflow-style: none;
    -webkit-overflow-scrolling: touch;
    padding: 4px 2px 12px;
}
.nk-rv-track::-webkit-scrollbar { display: none; }

.nk-rv-item {
    flex: 0 0 auto;
    scroll-snap-align: start;
    width: 168px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 10px;
    background: #fff;
    border: 1px solid var(--line, #E4E7EC);
    border-radius: 12px;
    text-decoration: none;
    color: inherit;
    transition: all .2s ease;
}
.nk-rv-item:hover {
    border-color: var(--brand-primary, #0E7490);
    transform: translateY(-2px);
    box-shadow: 0 8px 20px -6px rgba(var(--brand-primary-rgb, 14,116,144), .2);
}

.nk-rv-image {
    aspect-ratio: 1;
    background: var(--soft, #F2F4F7);
    border-radius: 8px;
    display: grid;
    place-items: center;
    overflow: hidden;
}
.nk-rv-image img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    padding: 8px;
}

.nk-rv-title {
    font-size: 12.5px;
    font-weight: 600;
    line-height: 1.5;
    margin: 0;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    min-height: 36px;
    color: var(--ink, #101828);
}

.nk-rv-price {
    font-family: var(--font-mono, monospace);
    font-size: 12px;
    font-weight: 700;
    color: var(--brand-primary-text, #0E7490);
}

@media (max-width: 640px) {
    .nk-recent-viewed { padding: 22px 0; }
    .nk-rv-item { width: 138px; padding: 8px; }
    .nk-rv-title { font-size: 11.5px; min-height: 32px; }
    .nk-rv-price { font-size: 11px; }
}

[data-theme="dark"] .nk-recent-viewed {
    background: var(--card, #111a2b);
    border-top-color: var(--line, #1f2a3d);
}
[data-theme="dark"] .nk-rv-item {
    background: var(--card, #111a2b);
    border-color: var(--line, #1f2a3d);
}
[data-theme="dark"] .nk-rv-image {
    background: var(--soft, #1a2338);
}