/* ─── تبلت ─── */
@media (max-width: 992px) {
    .view-container {
        gap: 16px;
        --card-size: 210px;
    }

    .top-header {
        padding: 16px 24px;
    }

    .content-area {
        padding: 0 24px 24px;
    }

    .view-container.list-mode .item-meta {
        width: auto;
        min-width: 120px;
    }
}

/* ─── موبایل ─── */
@media (max-width: 768px) {
    :root {
        --border-px: 1px;
    }

    html, body {
        height: 100%;
        overflow: hidden;
    }

    .app-container {
        flex-direction: column;
        height: 100%;
        overflow: hidden;
    }

    /* ── sidebar در موبایل مخفی ── */
    .sidebar {
        display: none !important;
    }

    /* ── main content ── */
    .main-content {
        flex: 1;
        overflow: hidden;
        display: flex;
        flex-direction: column;
    }

    /* ── top-header موبایل (فقط در پوشه‌ها نمایش داده می‌شود) ── */
    .top-header {
        display: flex;
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
        padding: 12px 16px;
        position: sticky;
        top: 0;
        z-index: 90;
        background: var(--bg-card);
        border-bottom: 1px solid var(--border);
        flex-wrap: nowrap;
        min-height: 56px;
    }

    /* نام درس در هدر موبایل */
    .header-course-title {
        font-size: 15px;
        font-weight: 700;
        color: var(--text-main);
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        max-width: 75%;
    }

    /* دکمه بازگشت موبایل (هول داده شده به سمت چپ) */
    .mobile-back-btn {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 38px;
        height: 38px;
        border: none;
        background: var(--bg-hover);
        border-radius: 12px;
        color: var(--text-main);
        cursor: pointer;
        text-decoration: none;
        flex-shrink: 0;
        margin-right: auto; 
    }

    .mobile-back-btn svg {
        width: 20px;
        height: 20px;
    }

    /* content area */
    .content-area {
        padding: 8px 8px 8px 8px;
        overflow-y: auto;
        flex: 1;
        padding-bottom: 72px;
    }

    /* ══════════════════════════════
       Bottom Navbar
    ══════════════════════════════ */
    .bottom-navbar {
        display: flex;
        position: fixed;
        bottom: 16px;
        left: 50%;
        transform: translateX(-50%);
        z-index: 1000;

        background: var(--bg-card);
        border: var(--border-px) solid var(--border);
        border-radius: 32px;
        padding: 8px 12px;
        gap: 4px;

        box-shadow:
            0 8px 32px rgba(0, 0, 0, 0.12),
            0 2px 8px rgba(0, 0, 0, 0.08);

        /* عرض: محتوا کامل نشون بده */
        width: max-content;
    }

    /* مخفی کردن navbar داخل کلاس */
    .bottom-navbar.hidden {
        display: none !important;
    }

    .nav-tab {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 3px;
        padding: 8px 16px;
        border-radius: 24px;
        border: none;
        background: transparent;
        color: var(--text-muted);
        font-size: 11px;
        font-weight: 600;
        cursor: pointer;
        transition: all 0.2s;
        text-decoration: none;
        white-space: nowrap;
        min-width: 60px;
    }

    .nav-tab svg {
        width: 22px;
        height: 22px;
        transition: transform 0.2s;
    }

    .nav-tab.active {
        background: var(--primary-soft);
        color: var(--primary);
    }

    .nav-tab.disabled {
        opacity: 0.35;
        cursor: not-allowed;
        pointer-events: none;
    }

    .nav-tab:active:not(.disabled) {
        transform: scale(0.92);
    }

    /* ── breadcrumb موبایل ── */
    .compact-breadcrumb {
        padding: 4px 4px 8px 4px;
    }

    .mobile-hidden {
        display: none !important;
    }

    /* ── Grid موبایل ── */
    /* .view-container {
        grid-template-columns: 1fr !important;
        gap: 10px;
    }

    .item-card.card-folder,
    .item-card.card-file {
        flex-direction: row;
        padding: 6px;
        align-items: center;
    }

    .item-card:hover {
        border-color: var(--border);
        box-shadow: none;
    }

    .item-card.card-folder .item-preview,
    .item-card.card-file .item-preview {
        width: 64px;
        height: 64px;
        border-radius: 10px;
        flex-shrink: 0;
        border-bottom: none;
    }

    .item-card.card-folder .item-info,
    .item-card.card-file .item-info {
        flex-direction: column;
        align-items: flex-start;
        gap: 4px;
        padding: 0 0 0 12px;
        height: auto;
    }

    .item-card.card-folder .item-title,
    .item-card.card-file .item-title {
        margin-bottom: 0;
        font-size: 14px;
    }

    .item-card.card-folder .item-desc,
    .item-card.card-file .item-desc {
        margin-bottom: 0;
        -webkit-line-clamp: 1;
    }

    .item-card.card-folder .item-meta,
    .item-card.card-file .item-meta {
        font-size: 11px;
    } */

        /* =========================================
       Mobile List View Redesign (Native App Feel - PRO)
    ========================================= */
    .view-container {
        grid-template-columns: 1fr;
        gap: 10px;
        padding: 12px 8px; /* اصلاح شماره 3: پدینگ کمتر (8px) برای عرض بیشتر کارت‌ها */
    }

    /* استایل پایه کارت‌ها در موبایل (باکس‌های مدرن و جدا از هم) */
    .item-card:not(.course-card) {
        display: flex;
        flex-direction: row;
        align-items: center;
        padding: 14px 12px;
        border-radius: 16px;
        border: 1px solid var(--border, #eaeaea);
        background: var(--bg-card, #ffffff);
        height: auto;
        gap: 12px;
        box-shadow: 0 2px 10px rgba(0,0,0,0.03);
        transition: transform 0.15s ease, background 0.2s;
    }

    /* افکت فشردگی هنگام لمس کارت */
    .item-card:not(.course-card):active {
        background: var(--bg-hover, rgba(0, 0, 0, 0.02));
        transform: scale(0.98);
    }

    .card-file:active {
    background: var(--bg-card) !important;
    transform: scale(1) !important;
}
    /* آیکون سمت راست (فایل/پوشه) */
    .item-card:not(.course-card) .item-preview {
        width: 54px;
        height: 54px;
        min-width: 54px;
        border-radius: 14px;
        margin: 0;
        font-size: 1.6rem;
    }
    .item-card:not(.course-card) .item-preview svg {
        width: 30px;
        height: 30px;
    }

    /* بخش اطلاعات مرکزی (تایتل، توضیحات، حجم و دکمه) */
    .item-card:not(.course-card) .item-info {
        flex: 1;
        min-width: 0;
        display: flex;
        flex-direction: column;
        justify-content: center;
        gap: 4px; /* فاصله بین المان‌های متن */
    }

    /* عنوان */
    .item-card:not(.course-card) .item-title {
        font-size: 15px;
        font-weight: 700;
        margin: 0;
        color: var(--text-main);
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    /* اصلاح شماره 1: نمایش مجدد توضیحات با ظاهر مرتب */
    .item-card:not(.course-card) .item-desc {
        display: -webkit-box; /* برای محدود کردن تعداد خطوط */
        -webkit-line-clamp: 2; /* حداکثر 2 خط نمایش داده شود */
        -webkit-box-orient: vertical;
        overflow: hidden;
        text-overflow: ellipsis;
        font-size: 12.5px;
        color: var(--text-muted);
        margin: 0;
        line-height: 1.4;
        white-space: normal; /* اجازه شکستن خط */
        min-height: 30px;
    }

    /* تنظیمات خط پایین (حجم فایل و دکمه دانلود) */
    .item-card:not(.course-card) .item-meta {
        padding: 0;
        border: none;
        display: flex;
        align-items: center;
        justify-content: space-between; /* دانلود سمت چپ، حجم سمت راست */
        width: 100%;
        margin-top: 6px; /* فاصله از توضیحات */
    }

    /* متن حجم فایل */
    .item-card:not(.course-card) .item-meta span {
        font-size: 12px;
        color: var(--text-muted);
        font-weight: 600;
    }

    /* مخفی کردن متا برای پوشه‌ها */
    .card-folder .item-meta {
        display: none;
    }

    /* ─── اصلاح شماره 2: دکمه دانلود بزرگتر و واضح‌تر در سمت چپ ─── */
    .item-card:not(.course-card) .btn-download, .btn-online {
        background: var(--primary-soft, #eff6ff); 
        color: var(--primary, #3b82f6);
        border: 1px solid rgba(59, 130, 246, 0.15);
        padding: 8px 18px 8px 14px; /* پدینگ بزرگتر برای سایز بیشتر */
        border-radius: 24px;
        font-size: 13.5px; /* فونت بزرگتر */
        font-weight: 700;
        text-decoration: none;
        display: flex;
        align-items: center;
        gap: 8px; /* فاصله بیشتر بین آیکون و کلمه دانلود */
        transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
        box-shadow: 0 2px 6px rgba(59, 130, 246, 0.1);
    }

    /* آیکون دانلود داخل دکمه */
    .item-card:not(.course-card) .btn-download::before {
        content: "";
        display: inline-block;
        width: 18px; /* آیکون بزرگتر */
        height: 18px; /* آیکون بزرگتر */
        background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%233b82f6' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4'/%3E%3Cpolyline points='7 10 12 15 17 10'/%3E%3Cline x1='12' y1='15' x2='12' y2='3'/%3E%3C/svg%3E");
        background-size: contain;
        background-repeat: no-repeat;
    }
    .item-card:not(.course-card) .btn-online::before {
        content: "";
        display: inline-block;
        width: 18px; /* آیکون بزرگتر */
        height: 18px; /* آیکون بزرگتر */
        background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='%233b82f6' viewBox='0 0 24 24' stroke='%233b82f6' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolygon points='5 3 19 12 5 21 5 3'/%3E%3C/svg%3E");
        background-size: contain;
        background-repeat: no-repeat;
    }

    /* تغییر رنگ دکمه در زمان تاچ کردن */
    .item-card:not(.course-card) .btn-download:active {
        background: var(--primary, #3b82f6);
        color: #fff;
        transform: scale(0.95);
        box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
    }
    
    .item-card:not(.course-card) .btn-download:active::before {
         background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%23ffffff' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4'/%3E%3Cpolyline points='7 10 12 15 17 10'/%3E%3Cline x1='12' y1='15' x2='12' y2='3'/%3E%3C/svg%3E");
    }

    /* ─── استایل دکمه‌های ادمین (ویرایش/حذف) در موبایل ─── */
    .item-card:not(.course-card) .card-actions {
        position: absolute;
        left: 10px;
        top: 10px;
        /* top: auto; left: auto; */
        display: flex;
        flex-direction: row;
        gap: 6px;
        opacity: 1;
        background: transparent;
    }

    .item-card:not(.course-card) .card-actions button {
        width: 36px;
        height: 36px;
        border-radius: 12px;
        background: var(--bg-hover, #f3f4f6) !important;
        border: none;
        box-shadow: none;
        color: var(--text-muted);
        display: flex;
        justify-content: center;
        align-items: center;
    }

    .item-card.card-folder .item-meta {
        display: none;
    }

    .dlbtn-container a {
        padding: 2px !important;
    }


    /* =========================================
       Course Header Mobile
    ========================================= */
    .course-header {
        min-height: 220px; /* افزایش ارتفاع بنر برای جذابیت بیشتر در موبایل */
        border-radius: 16px; 
        margin-bottom: 20px;
        margin-top: 16px; /* فاصله نرمال از بالای صفحه گوشی */
        display: flex;
        flex-direction: column;
        justify-content: flex-end; /* هول دادن محتوا و متن‌ها به پایین بنر */
    }

    /* دکمه بازگشت شناور در موبایل روی عکس هدر */
    .course-root-back-btn {
        top: 12px;
        left: 12px;
        width: 34px;
        height: 34px;
        background: rgba(0, 0, 0, 0.4);
        display: flex;
    }

    .course-header-content {
        flex-direction: column; /* چیدن محتوا زیر هم */
        align-items: flex-start;
        padding: 20px 16px;
        gap: 16px;
    }

    .course-info h1 {
        font-size: 20px; /* فونت مناسب موبایل */
    }

    .course-info .course-desc {
        max-width: 100%;
        font-size: 13px;
        -webkit-line-clamp: 2; /* در موبایل ۲ خط بیشتر نشون نده که شلوغ نشه */
    }

    .course-badge {
        font-size: 11px;
        padding: 3px 10px;
        margin-bottom: 8px;
    }

    .course-manage {
        width: 100%;
        display: grid;
        grid-template-columns: 1fr 1fr auto; /* دو دکمه بزرگ و یک دکمه کوچک برای حذف */
        gap: 8px;
    }

    .course-btn {
        padding: 8px 12px;
        font-size: 12px;
        width: 100%; /* دکمه‌ها تمام عرض در سلول خود */
    }

    .modal-container {
        padding: 24px 20px;
        width: calc(100% - 32px);
        max-height: 85vh;
        overflow-y: auto;
        border-radius: 16px;
    }






}
