/* =========================================================
   Responsive — Mobile First نسبت به شکست‌های استاندارد
   Laptop ≤ 1200 | Tablet ≤ 992 | Mobile ≤ 768 | Small ≤ 560
   ========================================================= */

/* ---------- کاهش فاصله‌ها در کل ---------- */
@media (max-width: 1200px) {
    .hero-inner { gap: 2rem; }
    .shops-grid { grid-template-columns: repeat(2, 1fr); }
    .search-layout { grid-template-columns: 265px 1fr; }
    .shop-layout { grid-template-columns: 1fr 300px; }
    .stat-cards { grid-template-columns: repeat(2, 1fr); }
    .footer-grid { grid-template-columns: repeat(2, 1fr); }
}

/* =========================================================
   Tablet — لپ‌تاپ کوچک / تبلت
   ========================================================= */
@media (max-width: 992px) {
    :root { --header-h: 66px; }

    .section { padding: 3.2rem 0; }

    /* --- Nav تبدیل به همبرگر --- */
    .nav-toggle { display: inline-flex; }

    .main-nav {
        position: fixed;
        top: 0;
        inset-inline-end: 0;
        z-index: 130;
        flex-direction: column;
        align-items: stretch;
        justify-content: flex-start;
        gap: 1.2rem;
        width: min(320px, 86vw);
        height: 100vh;
        padding: 1.4rem 1.3rem 2rem;
        background: var(--surface);
        border-inline-start: 1px solid var(--border);
        box-shadow: var(--shadow-lg);
        transform: translateX(100%);
        transition: transform .28s cubic-bezier(.4, 0, .2, 1);
        overflow-y: auto;
    }
    [dir="rtl"] .main-nav { transform: translateX(-100%); }
    .main-nav.is-open { transform: translateX(0) !important; }

    .nav-list { flex-direction: column; align-items: stretch; gap: .25rem; }
    .nav-link { display: block; padding: .85rem 1rem; font-size: .97rem; }
    .nav-actions { flex-direction: column; align-items: stretch; }
    .nav-actions .btn { width: 100%; }

    .nav-overlay {
        display: block;
        position: fixed;
        inset: 0;
        z-index: 120;
        background: rgba(28, 25, 23, .5);
        backdrop-filter: blur(2px);
    }
    .nav-overlay[hidden] { display: none; }

    /* --- Hero --- */
    .hero { padding: 3.2rem 0 3.6rem; }
    .hero-inner { grid-template-columns: 1fr; gap: 2.2rem; }
    .hero-art { display: none; }
    .search-box--hero { grid-template-columns: 1fr 1fr; }
    .search-box--hero .search-submit { grid-column: 1 / -1; width: 100%; }

    /* --- Categories / stats --- */
    .category-grid { grid-template-columns: repeat(2, 1fr); }
    .stats-band { grid-template-columns: repeat(2, 1fr); gap: .5rem; padding: 1.4rem; }
    .steps { grid-template-columns: 1fr; }

    /* --- Search page --- */
    .search-layout { grid-template-columns: 1fr; padding-top: 1.4rem; }

    .filters {
        position: static;
        order: -1;
    }
    .filters-toggle {
        display: inline-flex;
        align-items: center;
        gap: .4rem;
        padding: .5rem .85rem;
        border: 1px solid var(--border);
        border-radius: 10px;
        background: var(--surface);
        color: var(--text);
        font-size: .84rem;
        font-weight: 700;
        cursor: pointer;
    }
    .filters-body { display: none; }
    .filters.is-open .filters-body { display: flex; animation: fadeIn .2s ease; }

    .results-bar { order: -1; }

    /* --- Shop profile --- */
    .shop-layout { grid-template-columns: 1fr; }
    .shop-cover { height: 220px; }
    .shop-profile-head { flex-wrap: wrap; gap: 1rem; margin-top: -54px; }
    .shop-logo { width: 104px; height: 104px; }
    .shop-head-actions { width: 100%; padding-bottom: 0; }
    .shop-head-actions .btn { flex: 1 1 auto; }

    /* --- Auth --- */
    .auth-wrap { grid-template-columns: 1fr; }
    .auth-aside { display: none; }

    /* --- Dashboard --- */
    .dashboard { grid-template-columns: 1fr; }

    .dash-sidebar {
        position: fixed;
        top: 0;
        inset-inline-end: 0;
        z-index: 130;
        width: min(280px, 85vw);
        height: 100vh;
        overflow-y: auto;
        transform: translateX(100%);
        transition: transform .28s cubic-bezier(.4, 0, .2, 1);
        box-shadow: var(--shadow-lg);
    }
    [dir="rtl"] .dash-sidebar { transform: translateX(-100%); }
    .dash-sidebar.is-open { transform: translateX(0) !important; }

    .dash-sidebar-toggle { display: inline-flex; }
    .dash-main { padding: 1.3rem 1.1rem; }
    .dash-grid { grid-template-columns: 1fr; }
}

/* =========================================================
   Mobile
   ========================================================= */
@media (max-width: 768px) {
    body { font-size: 15px; }

    .brand-text small { display: none; }
    .header-dashboard { display: none; }

    .section { padding: 2.6rem 0; }
    .section-head { flex-direction: column; align-items: flex-start; gap: .8rem; margin-bottom: 1.6rem; }

    /* --- جستجو عمودی می‌شود --- */
    .search-box--hero,
    .search-box--compact { grid-template-columns: 1fr; }
    .search-box--hero .search-submit,
    .search-box--compact .search-submit { grid-column: auto; width: 100%; }

    /* --- کارت‌ها تک‌ستونه --- */
    .shops-grid,
    .grid-2,
    .grid-3,
    .grid-4 { grid-template-columns: 1fr; }

    .category-grid { grid-template-columns: 1fr 1fr; gap: .7rem; }
    .category-card { padding: .85rem; gap: .6rem; }
    .category-icon { width: 42px; height: 42px; border-radius: 12px; }
    .category-arrow { display: none; }

    .stats-band { grid-template-columns: 1fr 1fr; border-radius: var(--radius); }

    .shop-card--list { flex-direction: column; }
    .shop-card--list .shop-card-media { width: 100%; flex: none; aspect-ratio: 16 / 10; }

    .cta-band { flex-direction: column; align-items: flex-start; padding: 1.7rem; }
    .cta-actions { width: 100%; flex-direction: column; }
    .cta-actions .btn { width: 100%; }

    /* --- صفحات --- */
    .page-head { padding: 1.6rem 0 1.2rem; }
    .form-card { padding: 1.4rem 1.1rem; }
    .form-row { grid-template-columns: 1fr; gap: 0; }

    .map-placeholder { height: 260px; }
    .map-pin-label { display: none; }

    .gallery-grid { grid-template-columns: repeat(2, 1fr); }

    .tabs { border-radius: var(--radius-sm); }
    .tab-btn { flex: 0 0 auto; }

    .shop-head-actions { flex-wrap: wrap; }
    .shop-head-actions .btn { min-width: calc(50% - .3rem); }

    /* --- Dashboard --- */
    .stat-cards { grid-template-columns: 1fr 1fr; gap: .8rem; }
    .stat-card { padding: .9rem; gap: .7rem; }
    .stat-card-icon { width: 42px; height: 42px; }
    .stat-card strong { font-size: 1.25rem; }
    .dash-topbar h1 { font-size: 1.15rem; }

    .table th, .table td { padding: .7rem; font-size: .82rem; }

    .footer-grid { grid-template-columns: 1fr; gap: 1.6rem; }
    .footer-bottom { justify-content: center; text-align: center; }
}

/* =========================================================
   Small mobile
   ========================================================= */
@media (max-width: 560px) {
    .container { padding-inline: 1rem; }

    .category-grid { grid-template-columns: 1fr; }
    .stats-band { grid-template-columns: 1fr; }
    .stat-cards { grid-template-columns: 1fr; }

    .hero h1 { font-size: 1.55rem; }
    .hero-points { flex-direction: column; gap: .55rem; }

    .shop-card-footer { flex-direction: column; }
    .shop-profile-head { flex-direction: column; align-items: flex-start; }
    .shop-logo { width: 88px; height: 88px; }
    .shop-head-actions { flex-direction: column; }
    .shop-head-actions .btn { width: 100%; min-width: 0; }

    .results-bar { flex-direction: column; align-items: stretch; }
    .sort-select { width: 100%; }

    .gallery-grid { grid-template-columns: 1fr; }

    .dash-topbar { flex-direction: column; align-items: flex-start; }
}

/* ---------- جلوگیری کامل از Horizontal Overflow ---------- */
html, body { max-width: 100%; overflow-x: hidden; }
img, svg, video { max-width: 100%; }
pre, table { max-width: 100%; overflow-x: auto; }

/* ---------- حالت عرض کم ---------- */
@media (max-width: 380px) {
    .brand-text strong { font-size: .98rem; }
    .btn { padding-inline: 1rem; }
}

/* ---------- کاهش حرکت (Accessibility) ---------- */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: .01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: .01ms !important;
        scroll-behavior: auto !important;
    }
}

/* ---------- چاپ ---------- */
@media print {
    .site-header, .site-footer, .filters, .shop-head-actions { display: none !important; }
    body { background: #fff; }
}
