/* ==========================================
   MOBILE BOTTOM NAVIGATION - FIXED & STABLE
   ========================================== */

html {
    overscroll-behavior-x: none;
}
body {
    overflow-x: clip;
    overscroll-behavior-x: none;
}

.mobile-menu-overlay {
    pointer-events: none;
}

/* ===== Bottom Navigation Container ===== */
.mobile-bottom-nav {
    position: fixed;
    bottom: 10px;
    left: 52px;
    right: 52px;
    border-radius: 32px;
    z-index: 9999;
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--border-light);
    box-shadow: 0 2px 16px rgba(0,0,0,0.08);
    display: none;
}

/* ===== محتوى الشريط ===== */
.mobile-nav-content {
    display: flex;
    justify-content: space-around;
    align-items: center;
    height: 52px;
    padding: 0 4px;
}

/* ===== عناصر الـ Nav ===== */
.mobile-nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    color: #94A3B8;
    position: relative;
    padding: 6px 4px;
    min-width: 0;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    border-radius: 16px;
    transition: color 0.15s, background 0.15s, transform 0.15s;
}
.mobile-nav-item:active {
    transform: scale(0.92);
}

.mobile-nav-item i {
    font-size: 1.08rem;
    line-height: 1;
}

.mobile-nav-item > span:not(.mobile-nav-badge) {
    display: none;
}

/* ===== Active State ===== */
.mobile-nav-item.active {
    color: #4F46E5;
    background: #EEF2FF;
}

/* ===== صورة الملف الشخصي ===== */
.mobile-nav-profile {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: 2px solid #E0E7FF;
    object-fit: cover;
}

.mobile-nav-item.active .mobile-nav-profile {
    border-color: #4F46E5;
}

/* ===== PNB Icons (Notif + Avatar) ===== */
.pnb-icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    color: #9CA3AF;
    text-decoration: none;
    font-size: 0.95rem;
    position: relative;
    transition: background 0.14s, color 0.14s;
    flex-shrink: 0;
    -webkit-tap-highlight-color: transparent;
}
.pnb-icon-btn:active { background: #F3F4F6; }
.pnb-icon-active { color: #4F46E5; background: #EEF2FF; }
.pnb-icon-badge {
    position: absolute;
    top: 2px;
    left: 2px;
    background: #EF4444;
    color: white;
    font-size: 0.48rem;
    font-weight: 700;
    min-width: 13px;
    height: 13px;
    border-radius: 99px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 3px;
    border: 1.5px solid white;
    line-height: 1;
}
.pnb-avatar {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid #E0E7FF;
}
.pnb-icon-active .pnb-avatar { border-color: #4F46E5; }

html[data-theme="dark"] .pnb-icon-btn { color: #6B7280; }
html[data-theme="dark"] .pnb-icon-btn:active { background: #1E293B; }
html[data-theme="dark"] .pnb-icon-active { color: #818CF8; background: #1E1E40; }
html[data-theme="dark"] .pnb-icon-badge { border-color: rgba(17,19,24,.97); }

/* ===== Notification Badge ===== */
.mobile-nav-badge {
    position: absolute;
    top: 4px;
    right: calc(50% - 18px);
    background: #EF4444;
    color: white;
    font-size: 0.55rem;
    font-weight: 700;
    min-width: 14px;
    height: 14px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 3px;
    border: 2px solid #ffffff;
    line-height: 1;
}

/* ===== Desktop Nav ===== */
.desktop-nav {
    display: flex;
}

/* ==========================================
   RESPONSIVE RULES
   ========================================== */

@media (max-width: 768px) {
    /* إظهار الـ Bottom Nav */
    .mobile-bottom-nav {
        display: block;
    }

    /* إخفاء الـ Desktop Nav */
    .desktop-nav {
        display: none !important;
    }

    body {
        padding-bottom: calc(62px + env(safe-area-inset-bottom, 0px)) !important;
        overscroll-behavior-y: contain;
    }

    /* الـ navbar العادي على الموبايل */
    .navbar {
        padding: 0.75rem 1rem !important;
    }

    .navbar .logo {
        font-size: 1.25rem !important;
    }
}

/* Tablet - إخفاء الـ Bottom Nav */
@media (min-width: 769px) {
    .mobile-bottom-nav {
        display: none !important;
    }

    .desktop-nav {
        display: flex;
    }
}

/* ==========================================
   MOBILE MENU DRAWER — Redesigned
   ========================================== */

.mobile-menu-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    z-index: 10000;
    transform: translateZ(0);
    will-change: opacity;
    pointer-events: none;
}
.mobile-menu-overlay.active { opacity: 1; visibility: visible; pointer-events: auto; touch-action: none; }

.mobile-menu-drawer {
    position: fixed;
    top: 0;
    right: 0;
    width: min(300px, 88vw);
    height: 100vh;
    height: 100dvh;
    background: linear-gradient(165deg, #312E81 0%, #4C1D95 50%, #581C87 100%);
    color: white;
    box-shadow: -6px 0 40px rgba(0, 0, 0, 0.35);
    transition: transform 0.32s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 10001;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: none;
    touch-action: pan-y;
    padding-bottom: env(safe-area-inset-bottom, 16px);
    transform: translateX(100%);
    will-change: transform;
    display: none;
    flex-direction: column;
}
.mobile-menu-drawer::before {
    content: '';
    position: fixed;
    top: -100vh;
    right: 0;
    width: min(300px, 88vw);
    height: 100vh;
    background: #312E81;
    z-index: -1;
    pointer-events: none;
}
.mobile-menu-drawer::after {
    content: '';
    position: fixed;
    bottom: -100vh;
    right: 0;
    width: min(300px, 88vw);
    height: 100vh;
    background: #581C87;
    z-index: -1;
    pointer-events: none;
}
.mobile-menu-drawer.active { transform: translateX(0); }

.mmd-header {
    background: rgba(49, 46, 129, 0.95);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    color: white;
    padding: 1.1rem 1.1rem 1.4rem;
    position: sticky;
    top: 0;
    z-index: 2;
    flex-shrink: 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}
.mmd-close {
    display: flex; align-items: center; justify-content: center;
    width: 32px; height: 32px;
    background: rgba(255, 255, 255, 0.12);
    border: none; border-radius: 50%;
    color: white; font-size: 0.85rem;
    cursor: pointer; margin-bottom: 1rem;
    transition: background 0.2s;
    -webkit-tap-highlight-color: transparent;
}
.mmd-close:active { background: rgba(255, 255, 255, 0.25); }

.mmd-profile { display: flex; align-items: center; gap: 0.8rem; }
.mmd-avatar {
    width: 52px; height: 52px;
    border-radius: 50%;
    border: 2.5px solid rgba(255, 255, 255, 0.4);
    object-fit: cover; flex-shrink: 0;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.3);
}
.mmd-profile-info { flex: 1; min-width: 0; }
.mmd-profile-info strong {
    display: block; font-size: 0.95rem; font-weight: 700;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    max-width: 100%;
}
.mmd-username {
    display: block; font-size: 0.78rem; opacity: 0.6;
    direction: ltr; text-align: left;
}
.mmd-view-btn {
    display: flex; align-items: center; justify-content: center;
    gap: 0.4rem;
    margin-top: 0.9rem;
    padding: 0.5rem 1rem;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 10px;
    font-size: 0.8rem; font-weight: 600;
    color: white; text-decoration: none;
    transition: background 0.2s;
}
.mmd-view-btn:active { background: rgba(255, 255, 255, 0.2); color: white; }

.mmd-label {
    font-size: 0.68rem; font-weight: 700;
    color: rgba(255, 255, 255, 0.45);
    letter-spacing: 0.07em; text-transform: uppercase;
    padding: 1rem 1.1rem 0.45rem;
}

.mmd-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.55rem;
    padding: 0 0.875rem;
}
.mmd-grid-item {
    display: flex; flex-direction: column; align-items: center;
    gap: 0.45rem; padding: 0.85rem 0.5rem;
    background: rgba(255, 255, 255, 0.07);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border-radius: 14px;
    text-decoration: none;
    color: rgba(255, 255, 255, 0.9);
    font-size: 0.82rem; font-weight: 600;
    transition: all 0.18s;
    border: 1px solid rgba(255, 255, 255, 0.1);
    text-align: center;
    -webkit-tap-highlight-color: transparent;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
}
.mmd-grid-item:active,
.mmd-grid-item.active {
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.28);
    color: white;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
}
.mmd-grid-icon {
    width: 42px; height: 42px; border-radius: 11px;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.15rem;
    background: rgba(255, 255, 255, 0.1) !important;
}
.mmd-grid-icon i {
    color: white !important;
    opacity: 0.9;
}

.mmd-list { padding: 0 0.55rem; }
.mmd-list-item {
    display: flex; align-items: center; gap: 0.75rem;
    padding: 0.72rem 0.6rem;
    color: rgba(255, 255, 255, 0.85);
    text-decoration: none;
    border-radius: 12px; font-weight: 500; font-size: 0.88rem;
    transition: all 0.18s; position: relative;
    -webkit-tap-highlight-color: transparent;
}
.mmd-list-item:active,
.mmd-list-item.active {
    background: rgba(255, 255, 255, 0.1);
    color: white;
}
.mmd-list-icon {
    width: 36px; height: 36px; border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    font-size: 0.95rem; flex-shrink: 0;
    background: rgba(255, 255, 255, 0.1) !important;
}
.mmd-list-icon i {
    color: white !important;
    opacity: 0.85;
}
.mmd-list-arrow { margin-right: auto; color: rgba(255, 255, 255, 0.25); font-size: 0.7rem; }

.mmd-divider { height: 1px; background: rgba(255, 255, 255, 0.08); margin: 0.6rem 1.1rem; }

.mmd-logout {
    display: flex; align-items: center; gap: 0.75rem;
    margin: 0.5rem 0.875rem 1rem;
    padding: 0.8rem 1rem;
    background: rgba(239, 68, 68, 0.12) !important;
    border: 1px solid rgba(239, 68, 68, 0.2);
    border-radius: 12px;
    color: #FCA5A5; text-decoration: none;
    font-weight: 600; font-size: 0.88rem;
    transition: background 0.2s;
    -webkit-tap-highlight-color: transparent;
}
.mmd-logout:active { background: rgba(239, 68, 68, 0.22) !important; }

@keyframes mmd-fadeUp {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}
.mobile-menu-drawer.active .mmd-grid-item {
    animation: mmd-fadeUp 0.3s ease-out both;
}
.mobile-menu-drawer.active .mmd-grid-item:nth-child(1) { animation-delay: 0.04s; }
.mobile-menu-drawer.active .mmd-grid-item:nth-child(2) { animation-delay: 0.08s; }
.mobile-menu-drawer.active .mmd-grid-item:nth-child(3) { animation-delay: 0.12s; }
.mobile-menu-drawer.active .mmd-grid-item:nth-child(4) { animation-delay: 0.16s; }
.mobile-menu-drawer.active .mmd-grid-item:nth-child(5) { animation-delay: 0.20s; }
.mobile-menu-drawer.active .mmd-grid-item:nth-child(6) { animation-delay: 0.24s; }

.mobile-nav-item:active:not(.active){background:#F1F5F9;color:#6366F1}
.more-dot{width:3.5px;height:3.5px;border-radius:50%;background:currentColor;display:block}
.more-popup-ov{position:fixed;inset:0;z-index:10998;display:none;-webkit-tap-highlight-color:transparent}
.more-popup-ov.open{display:block}
.more-popup{position:fixed;bottom:calc(62px + env(safe-area-inset-bottom,0px));right:calc(52px + 0.35rem);width:min(252px,88vw);background:white;border-radius:18px;box-shadow:0 12px 48px rgba(0,0,0,0.18),0 2px 8px rgba(0,0,0,0.08);z-index:10999;transform:scale(0.88) translateY(12px);transform-origin:bottom right;opacity:0;transition:transform 0.22s cubic-bezier(0.4,0,0.2,1),opacity 0.22s;pointer-events:none;max-height:74vh;overflow-y:auto;overscroll-behavior:contain}
.more-popup.open{transform:scale(1) translateY(0);opacity:1;pointer-events:auto}
.more-popup-sec{font-size:0.58rem;font-weight:700;color:#94A3B8;letter-spacing:0.08em;text-transform:uppercase;padding:0.65rem 0.85rem 0.22rem}
.more-popup-item{display:flex;align-items:center;gap:0.5rem;padding:0.5rem 0.58rem;cursor:pointer;text-decoration:none;transition:background 0.12s;border-radius:10px;margin:0 0.3rem;-webkit-tap-highlight-color:transparent}
.more-popup-item:active{background:#F1F5F9}
.more-popup-item.active .mpi-text{color:#4F46E5;font-weight:700}
.more-popup-ic{width:28px;height:28px;border-radius:8px;display:flex;align-items:center;justify-content:center;font-size:0.75rem;flex-shrink:0}
.mpi-text{font-size:0.7rem;font-weight:600;color:#1E293B;flex:1}
.mpi-badge{background:#EF4444;color:white;font-size:0.55rem;font-weight:700;min-width:16px;height:16px;border-radius:8px;display:flex;align-items:center;justify-content:center;padding:0 3px}
.more-popup-divider{height:1px;background:#F1F5F9;margin:0.28rem 0.65rem}
.more-popup-theme-row{display:flex;align-items:center;gap:0.5rem;padding:0.5rem 0.58rem;cursor:pointer;border-radius:10px;margin:0 0.3rem;transition:background 0.12s;-webkit-tap-highlight-color:transparent}
.more-popup-theme-row:active{background:#F1F5F9}
.more-popup-logout-btn{display:flex;align-items:center;gap:0.5rem;padding:0.5rem 0.58rem;cursor:pointer;border-radius:10px;margin:0.15rem 0.3rem 0.55rem;background:rgba(239,68,68,0.06);border:none;font-family:inherit;width:calc(100% - 0.6rem);-webkit-tap-highlight-color:transparent}
.more-popup-logout-btn .mpi-text{color:#EF4444}
html[data-theme="dark"] .more-popup{background:#1E293B;box-shadow:0 12px 48px rgba(0,0,0,0.5)}
html[data-theme="dark"] .more-popup-item:active,html[data-theme="dark"] .more-popup-theme-row:active{background:#334155}
html[data-theme="dark"] .mpi-text{color:#F1F5F9}
html[data-theme="dark"] .more-popup-divider{background:#334155}
html[data-theme="dark"] .more-popup-sec{color:#64748B}
html[data-theme="dark"] .more-popup-logout-btn{background:rgba(239,68,68,0.1)}
html[data-theme="dark"] .more-popup-logout-btn .mpi-text{color:#FCA5A5}
