/**
 * قائمة التطبيق الجانبية - للموبايل والشاشات الصغيرة فقط
 * لا يطبق أي تغيير على سطح المكتب (أكبر من 768px)
 */
@media (min-width: 769px) {
    .app-drawer-toggle,
    .app-drawer-overlay,
    .app-drawer {
        display: none !important;
    }
}

@media (max-width: 768px) {
    /* عكس اتجاه التوب بار: الزر في اليمين واللوجو واسم المنصة في اليسار */
    .navbar .nav-container {
        flex-direction: row;
    }

    /* زر فتح القائمة في التوب بار - يظهر فقط على الموبايل (في اليمين) */
    .app-drawer-toggle {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 44px;
        height: 44px;
        padding: 0;
        margin: 0;
        border: none;
        border-radius: var(--radius-sm, 8px);
        background: rgba(255, 255, 255, 0.12);
        color: #fff;
        cursor: pointer;
        transition: background 0.2s ease, color 0.2s ease;
        -webkit-tap-highlight-color: transparent;
        flex-shrink: 0;
    }
    .app-drawer-toggle:hover,
    .app-drawer-toggle:focus {
        background: rgba(255, 255, 255, 0.2);
        color: #fff;
    }
    .app-drawer-toggle:focus-visible {
        outline: 2px solid #4a90e2;
        outline-offset: 2px;
    }
    .app-drawer-toggle svg {
        width: 24px;
        height: 24px;
    }

    /* إخفاء روابط التوب بار الأصلية على الموبايل (تظهر داخل القائمة فقط) */
    .navbar .nav-container .nav-links {
        display: none !important;
    }

    /* الستار الخلفي - الارتفاع يُحدَّث من JS بـ visualViewport لضمان تغطية كاملة على الموبايل */
    .app-drawer-overlay {
        display: block;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        width: 100%;
        min-height: 100vh;
        min-height: 100dvh;
        background: rgba(0, 0, 0, 0.5);
        z-index: 9998;
        opacity: 0;
        visibility: hidden;
        transition: opacity 0.25s ease, visibility 0.25s ease;
        -webkit-tap-highlight-color: transparent;
    }
    .app-drawer-overlay.active {
        opacity: 1;
        visibility: visible;
    }
    body.app-drawer-open {
        overflow: hidden;
        touch-action: none;
    }

    /* القائمة الجانبية - الارتفاع يُحدَّث من JS بـ visualViewport لضمان تغطية كاملة عند التمرير */
    .app-drawer {
        box-sizing: border-box;
        display: flex;
        flex-direction: column;
        position: fixed;
        top: 0;
        right: 0;
        left: auto;
        width: min(320px, 85vw);
        max-width: 320px;
        height: 100vh;
        max-height: 100vh;
        background: linear-gradient(180deg, #1a2332 0%, #243447 100%);
        box-shadow: -4px 0 24px rgba(0, 0, 0, 0.35);
        z-index: 9999;
        transform: translateX(100%);
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        overflow-y: hidden;  
      }
    .app-drawer.open {
        transform: translateX(0);
    }

    /* منطقة التبويبات - قابلة للتمرير عند الحاجة */
    .app-drawer-tabs {
        flex: 1;
        overflow-y: auto;
        padding: 1.25rem 0;
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    }
    .app-drawer-tabs .app-drawer-link {
        display: flex;
        align-items: center;
        gap: 10px;
        width: 100%;
        padding: 12px 1.25rem;
        color: rgba(255, 255, 255, 0.85);
        text-decoration: none;
        font-weight: 600;
        font-size: 0.95rem;
        transition: background 0.2s ease, color 0.2s ease;
        border: none;
        background: transparent;
        cursor: pointer;
        text-align: right;
        font-family: inherit;
    }
    .app-drawer-tabs .app-drawer-link:hover {
        background: rgba(255, 255, 255, 0.08);
        color: #fff;
    }
    .app-drawer-tabs .app-drawer-link.active {
        background: rgba(74, 144, 226, 0.25);
        color: #fff;
        border-right: 3px solid #4a90e2;
    }
    .app-drawer-tabs .app-drawer-link i {
        font-size: 1.2rem;
        opacity: 0.9;
    }

    /* بطاقة التعريف في نهاية القائمة - رابط للملف الشخصي */
    .app-drawer-user-card {
        flex: 0 0 auto;
        padding: 1.25rem;
        margin: 0;
        background: rgba(255, 255, 255, 0.06);
        border-top: 1px solid rgba(255, 255, 255, 0.1);
        text-decoration: none;
        color: inherit;
        display: block;
        cursor: pointer;
        -webkit-tap-highlight-color: transparent;
    }
    a.app-drawer-user-card:hover {
        background: rgba(255, 255, 255, 0.1);
    }
    .app-drawer-user-card .app-drawer-user-avatar {
        width: 52px;
        height: 52px;
        border-radius: 50%;
        background: rgba(74, 144, 226, 0.3);
        color: #fff;
        display: flex;
        align-items: center;
        justify-content: center;
        margin: 0 auto 12px;
        font-size: 1.5rem;
    }
    .app-drawer-user-card .app-drawer-user-name {
        color: #fff;
        font-weight: 700;
        font-size: 1rem;
        text-align: center;
        margin: 0 0 6px;
        word-break: break-word;
    }
    .app-drawer-user-card .app-drawer-user-id {
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 6px;
        color: rgba(255, 255, 255, 0.75);
        font-size: 0.85rem;
        direction: ltr;
    }
    .app-drawer-user-card .app-drawer-user-id .id-label {
        font-weight: 600;
        color: rgba(255, 255, 255, 0.6);
    }

    .app-drawer-user-card,
.app-drawer-logout-wrap {
    flex-shrink: 0;
}

    /* زر تسجيل الخروج في النهاية */
    .app-drawer-logout-wrap {
        flex: 0 0 auto;
        padding: 1rem 1.25rem 1.5rem;
    }
    .app-drawer-logout {
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 8px;
        width: 100%;
        padding: 12px 1rem;
        border: none;
        border-radius: var(--radius-sm, 8px);
        background: rgba(255, 255, 255, 0.1);
        color: #fff;
        font-weight: 600;
        font-size: 0.95rem;
        cursor: pointer;
        transition: background 0.2s ease;
        font-family: inherit;
        text-align: center;
    }
    .app-drawer-logout:hover {
        background: rgba(255, 107, 107, 0.25);
        color: #fff;
    }
    .app-drawer-logout i {
        font-size: 1.1rem;
    }
}
