/* =========================================================
   Responsive.css – طراحی موبایل مطابق تصویر مرجع
   ========================================================= */

/* ============= نسخه دسکتاپ کوچک ============= */
@media (max-width: 1280px) {
    .stats-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
    .dashboard-row { grid-template-columns: 1fr 320px; }
    .tweet-card { grid-template-columns: 240px 1fr; }
}

@media (max-width: 1100px) {
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .dashboard-row { grid-template-columns: 1fr; }
    .tweet-card { grid-template-columns: 200px 1fr; }
    .form-grid { grid-template-columns: 1fr; }
}

/* ============= تبلت ============= */
@media (max-width: 900px) {
    .search-form { grid-template-columns: 1fr; }
    .tweet-card { grid-template-columns: 1fr; }
    .tweet-actions .btn { min-width: 100%; }
}

/* =========================================================
   موبایل  ≤ 768px  → طراحی کاملاً متفاوت (شبیه App)
   ========================================================= */
@media (max-width: 768px) {

    body { padding-bottom: calc(var(--bottom-nav-h) + 16px); }

    /* مخفی کردن دسکتاپ */
    .d-topbar,
    .d-sidebar { display: none !important; }

    /* در موبایل، هشتگ‌ها و پیج‌های ذخیره‌شده در داشبورد نمایش داده نمی‌شوند
       (از طریق منو قابل دسترسی هستند) */
    .dashboard-quick { display: none !important; }

    .is-desktop .app-main,
    .is-mobile  .app-main {
        margin: 0 !important;
        padding: 12px 14px 16px !important;
    }

    /* نمایش موبایل */
    .m-header {
        display: flex !important;
        align-items: center;
        justify-content: space-between;
        gap: 12px;
        padding: 14px 16px 12px;
        position: sticky;
        top: 0;
        z-index: 60;
        background: linear-gradient(to bottom, var(--bg-1) 70%, transparent);
    }
    .m-menu-btn {
        display: grid; place-items: center;
        width: 40px; height: 40px;
        border-radius: 12px;
        color: var(--text);
    }
    .m-menu-btn svg { width: 22px; height: 22px; }
    .m-header-title { text-align: center; flex: 1; }
    .m-header-title h1 { margin: 0; font-size: 16px; font-weight: 700; }
    .m-header-title p { margin: 2px 0 0; font-size: 11px; color: var(--text-muted); }
    .m-avatar {
        position: relative;
        width: 40px; height: 40px;
        border-radius: 50%;
        overflow: hidden;
        background: var(--surface-2);
        flex-shrink: 0;
        border: 2px solid var(--border);
    }
    .m-avatar img { width: 100%; height: 100%; object-fit: cover; }
    .m-avatar-status {
        position: absolute;
        bottom: 1px;
        right: 1px;
        width: 10px; height: 10px;
        background: var(--green);
        border-radius: 50%;
        border: 2px solid var(--bg-1);
    }

    /* Bottom Nav موبایل */
    .m-bottom-nav {
        display: flex !important;
        justify-content: space-around;
        align-items: stretch;
        position: fixed;
        bottom: 0; left: 0; right: 0;
        height: var(--bottom-nav-h);
        background: rgba(14, 22, 40, 0.95);
        backdrop-filter: blur(14px);
        border-top: 1px solid var(--border-soft);
        z-index: 70;
        padding-bottom: env(safe-area-inset-bottom);
    }
    .m-bottom-nav a {
        flex: 1;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        color: var(--text-soft);
        gap: 2px;
        font-size: 10px;
        transition: color .15s;
        padding: 8px 4px;
    }
    .m-bottom-nav a.active { color: var(--purple-2); }
    .m-bottom-nav a.active .m-nav-icon::before {
        content: '';
        position: absolute;
        top: -8px; left: 50%;
        transform: translateX(-50%);
        width: 4px; height: 4px;
        background: var(--purple);
        border-radius: 50%;
    }
    .m-nav-icon { position: relative; display: grid; place-items: center; }
    .m-nav-icon svg { width: 22px; height: 22px; }
    .m-nav-label { font-size: 10px; }

    /* Drawer */
    .m-drawer-backdrop {
        display: block;
        position: fixed; inset: 0;
        background: rgba(0,0,0,0.5);
        z-index: 80;
        opacity: 0;
        pointer-events: none;
        transition: opacity .25s;
    }
    .m-drawer-backdrop.show { opacity: 1; pointer-events: auto; }
    .m-drawer {
        display: block;
        position: fixed;
        top: 0; bottom: 0;
        width: 80%;
        max-width: 320px;
        background: var(--surface);
        border-left: 1px solid var(--border);
        z-index: 90;
        padding: 18px;
        transition: transform .25s ease;
        overflow-y: auto;
    }
    [dir="rtl"] .m-drawer { right: 0; transform: translateX(100%); }
    [dir="ltr"] .m-drawer { left: 0; transform: translateX(-100%); }
    .m-drawer.show { transform: translateX(0) !important; }
    .m-drawer-header {
        display: flex;
        align-items: center;
        justify-content: space-between;
        margin-bottom: 14px;
    }
    .m-drawer-header h3 { margin: 0; font-size: 16px; }
    .m-drawer-close {
        width: 30px; height: 30px;
        border-radius: 8px;
        background: rgba(255,255,255,0.06);
        font-size: 22px;
        display: grid; place-items: center;
        line-height: 1;
    }
    .m-drawer-nav {
        display: flex;
        flex-direction: column;
        gap: 4px;
    }
    .m-drawer-nav a {
        padding: 12px 14px;
        border-radius: 12px;
        color: var(--text-muted);
        font-size: 14px;
    }
    .m-drawer-nav a:hover { background: rgba(255,255,255,0.04); color: var(--text); }
    .m-drawer-logout {
        margin-top: 16px;
        background: rgba(255, 70, 100, 0.10);
        color: #ff7d97 !important;
    }

    /* آمار 2x2 فشرده در موبایل */
    .stats-grid {
        grid-template-columns: 1fr 1fr;
        gap: 10px;
        margin-bottom: 14px;
    }
    .stat-card {
        flex-direction: row;
        align-items: center;
        gap: 10px;
        background: var(--surface) !important;
        border: 1px solid var(--border);
        color: var(--text);
        padding: 11px 12px;
        min-height: 0;
        position: relative;
    }
    .stat-card::after {
        content: '';
        position: absolute;
        top: 0; left: 0; right: 0; height: 100%;
        border-radius: var(--radius-lg);
        opacity: 0.0;
        pointer-events: none;
    }
    .stat-card .stat-icon {
        width: 36px; height: 36px;
        border-radius: 11px;
        background: transparent !important;
        order: 2;
    }
    .stat-card .stat-body { order: 1; }
    .stat-card.green  .stat-icon { background: var(--green-grad)  !important; box-shadow: 0 4px 12px rgba(16,201,126,0.35); }
    .stat-card.blue   .stat-icon { background: var(--blue-grad)   !important; box-shadow: 0 4px 12px rgba(46,163,242,0.35); }
    .stat-card.purple .stat-icon { background: var(--purple-grad) !important; box-shadow: 0 4px 12px rgba(138,76,255,0.35); }
    .stat-card.orange .stat-icon { background: var(--orange-grad) !important; box-shadow: 0 4px 12px rgba(255,154,60,0.35); }
    .stat-card .stat-icon svg { width: 18px; height: 18px; }

    .stat-title { color: var(--text-muted); margin-bottom: 2px; font-size: 11px; line-height: 1.3; }
    .stat-card.green  .stat-title { color: #2ee0a3; }
    .stat-card.blue   .stat-title { color: #5fc0ff; }
    .stat-card.purple .stat-title { color: #b78cff; }
    .stat-card.orange .stat-title { color: #ffb55a; }
    .stat-value { font-size: 20px; margin-bottom: 0; }
    .stat-meta { display: none; }
    .stat-spark { display: none; }

    /* فرم جستجوی موبایل (تک ستونی) */
    .search-form { grid-template-columns: 1fr; gap: 10px; }
    .field input, .field select {
        background: var(--bg-2);
        border-radius: 14px;
        padding: 14px 16px;
    }
    .search-form button.btn { padding: 14px; font-size: 14px; border-radius: 14px; }

    .card { padding: 14px; border-radius: 18px; }
    .card-title { font-size: 14px; }

    /* تک ستونی */
    .dashboard-row { grid-template-columns: 1fr; }

    /* کارت توییت موبایل */
    .tweet-card {
        grid-template-columns: 1fr;
        gap: 14px;
        padding: 14px;
        border-radius: 18px;
    }
    .tweet-card .tweet-body { order: 1; }
    .tweet-card .tweet-media { order: 2; min-height: 160px; }
    .tweet-actions { gap: 8px; }
    .tweet-actions .btn { min-width: 0; flex: 1; padding: 10px 8px; font-size: 11px; }
    .tweet-actions .btn svg { width: 14px; height: 14px; }
    .tweet-stats { font-size: 11px; gap: 14px; flex-wrap: wrap; }

    /* فرم گرید موبایل */
    .form-grid { grid-template-columns: 1fr; gap: 12px; }

    /* Modal موبایل */
    .modal-dialog { max-width: 100%; max-height: 95vh; border-radius: 22px 22px 0 0; }
    .modal { align-items: flex-end; padding: 0; }

    .footer-credit { display: none; }

    .table { font-size: 12px; }
    .table th, .table td { padding: 9px 10px; }
}

/* ============= خیلی کوچک ============= */
@media (max-width: 360px) {
    .stat-value { font-size: 18px; }
    .stat-card .stat-icon { width: 32px; height: 32px; border-radius: 10px; }
    .stat-card .stat-icon svg { width: 16px; height: 16px; }
    .stat-title { font-size: 10px; }
    .m-bottom-nav a .m-nav-label { font-size: 9px; }
}
