/* ═══════════════════════════════════════════
   تصميم Bottom Navbar - Sliding Tab Style
   ═══════════════════════════════════════════ */

/* إخفاء البوتوم ناف في الشاشات الكبيرة */
@media (min-width: 769px) {
    .bottom-navbar {
        display: none !important;
    }
}

/* الناف بار السفلي - الشاشات الصغيرة فقط */
@media (max-width: 768px) {
    /* ═══════════════════════════════════════════
       الحاوية الرئيسية للـ Bottom Navbar
       ═══════════════════════════════════════════ */
    .bottom-navbar {
        position: fixed;
        bottom: 12px;
        left: 12px;
        right: 12px;
        
        /* التصميم الأساسي */
        background: linear-gradient(135deg, rgba(155, 89, 182, 0.98), rgba(142, 68, 173, 0.98));
        backdrop-filter: blur(20px);
        border-radius: 50px;
        border: 1px solid rgba(255, 255, 255, 0.2);
        box-shadow: 0 15px 50px rgba(155, 89, 182, 0.3);
        
        z-index: 1000;
        padding: 6px 8px;
        
        /* دعم الهواتف الحديثة (iPhone Notch) */
        padding-bottom: max(6px, env(safe-area-inset-bottom));
    }

    /* ═══════════════════════════════════════════
       حاوية العناصر
       ═══════════════════════════════════════════ */
    .navbar-container {
        display: flex;
        justify-content: space-around;
        align-items: center;
        max-width: 100%;
        margin: 0 auto;
        gap: 2px;
    }

    /* ═══════════════════════════════════════════
       عنصر الناف (Nav Item) - التصميم الرئيسي
       ═══════════════════════════════════════════ */
    .nav-item {
        display: flex;
        flex-direction: row;
        align-items: center;
        justify-content: center;
        gap: 6px;
        
        /* الخصائص الأساسية */
        text-decoration: none;
        color: rgba(255, 255, 255, 0.7);
        transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
        position: relative;
        
        /* الحشوة والحجم */
        padding: 8px 12px;
        border-radius: 25px;
        cursor: pointer;
        flex: 0 0 auto;
        min-height: 48px;
        white-space: nowrap;
        
        /* الخط */
        font-size: 0.75rem;
        font-weight: 600;
    }

    /* ═══════════════════════════════════════════
       النص (Label) - مخفي بشكل افتراضي
       ═══════════════════════════════════════════ */
    .nav-label {
        max-width: 0;
        opacity: 0;
        overflow: hidden;
        transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
        font-size: 0.7rem;
        font-weight: 600;
        white-space: nowrap;
    }

    /* ═══════════════════════════════════════════
       غلاف الأيقونة
       ═══════════════════════════════════════════ */
    .nav-icon-wrapper {
        width: 32px;
        height: 32px;
        display: flex;
        align-items: center;
        justify-content: center;
        background: rgba(255, 255, 255, 0.15);
        border-radius: 50%;
        transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
        position: relative;
        overflow: hidden;
        flex-shrink: 0;
    }

    /* ═══════════════════════════════════════════
       الأيقونة
       ═══════════════════════════════════════════ */
    .nav-icon {
        width: 18px;
        height: 18px;
        fill: currentColor;
        transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    }

    /* ═══════════════════════════════════════════
       حالة التحويم (Hover)
       ═══════════════════════════════════════════ */
    .nav-item:hover {
        color: #ffffff;
        background: rgba(255, 255, 255, 0.12);
        padding: 8px 16px;
    }

    .nav-item:hover .nav-icon-wrapper {
        background: rgba(248, 180, 217, 0.3);
        transform: scale(1.05);
    }

    .nav-item:hover .nav-label {
        max-width: 100px;
        opacity: 1;
        margin-left: 2px;
    }

    /* ═══════════════════════════════════════════
       الحالة النشطة (Active)
       ═══════════════════════════════════════════ */
    .nav-item.active {
        color: #ffffff;
        background: rgba(248, 180, 217, 0.25);
        padding: 8px 18px;
        box-shadow: 0 8px 20px rgba(155, 89, 182, 0.3);
    }

    .nav-item.active .nav-icon-wrapper {
        background: linear-gradient(135deg, rgba(248, 180, 217, 0.5), rgba(232, 213, 242, 0.5));
        transform: scale(1.1);
        box-shadow: 0 4px 15px rgba(248, 180, 217, 0.4);
    }

    .nav-item.active .nav-label {
        max-width: 100px;
        opacity: 1;
        margin-left: 4px;
        font-weight: 700;
    }

    /* ═══════════════════════════════════════════
       الأنيميشنات
       ═══════════════════════════════════════════ */
    @keyframes iconDance {
        0%, 100% { transform: translateY(0) scale(1); }
        50% { transform: translateY(-3px) scale(1.05); }
    }

    .nav-item:hover .nav-icon {
        animation: iconDance 0.6s ease-in-out;
    }

    @keyframes paperPlaneFly {
        0%, 100% { transform: translateY(0) rotate(0deg); }
        50% { transform: translateY(-8px) rotate(-8deg); }
    }

    .nav-item:nth-child(4):hover .nav-icon {
        animation: paperPlaneFly 0.8s ease-in-out infinite;
    }

    /* ═══════════════════════════════════════════
       عنصر المستخدم (User Item)
       ═══════════════════════════════════════════ */
    .nav-user-item {
        position: relative;
    }

    .user-icon-wrapper {
        background: rgba(248, 180, 217, 0.2);
    }

    .nav-user-item:hover .user-icon-wrapper {
        background: rgba(248, 180, 217, 0.4);
    }

    /* ═══════════════════════════════════════════
       القائمة المنسدلة للمستخدم
       ═══════════════════════════════════════════ */
    .user-menu-dropdown {
        position: absolute;
        bottom: calc(100% + 12px);
        right: 50%;
        transform: translateX(50%) translateY(10px);
        
        background: linear-gradient(135deg, rgba(155, 89, 182, 0.98), rgba(142, 68, 173, 0.98));
        backdrop-filter: blur(20px);
        border-radius: 20px;
        padding: 8px 0;
        min-width: 160px;
        
        opacity: 0;
        visibility: hidden;
        transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
        border: 1px solid rgba(255, 255, 255, 0.2);
        box-shadow: 0 10px 30px rgba(155, 89, 182, 0.3);
    }

    .nav-user-item:hover .user-menu-dropdown {
        opacity: 1;
        visibility: visible;
        transform: translateX(50%) translateY(0);
    }

    /* ═══════════════════════════════════════════
       عناصر القائمة المنسدلة
       ═══════════════════════════════════════════ */
    .dropdown-item {
        display: flex;
        align-items: center;
        gap: 10px;
        padding: 12px 16px;
        color: rgba(255, 255, 255, 0.9);
        text-decoration: none;
        font-size: 0.85rem;
        transition: all 0.3s ease;
        cursor: pointer;
    }

    .dropdown-item:hover {
        background: rgba(255, 255, 255, 0.1);
        color: #ffffff;
        padding-right: 20px;
    }

    .dropdown-item i {
        width: 16px;
        text-align: center;
    }

    /* ═══════════════════════════════════════════
       تعديل المسافة السفلية للجسم
       ═══════════════════════════════════════════ */
    body {
        padding-bottom: 75px;
    }

    /* ═══════════════════════════════════════════
       ضمان عدم تداخل عناصر الصوت مع القائمة السفلية
       ═══════════════════════════════════════════ */
    .audio-player-container {
        margin-bottom: 20px;
    }

    .story-display-container audio {
        width: 100%;
        max-width: 100%;
        height: 44px;
        display: block;
    }

    /* ═══════════════════════════════════════════
       تحسين الاستجابة على أحجام مختلفة
       ═══════════════════════════════════════════ */
    @media (max-width: 480px) {
        .bottom-navbar {
            bottom: 8px;
            left: 8px;
            right: 8px;
            padding: 4px 6px;
        }

        .navbar-container {
            gap: 0;
        }

        .nav-item {
            padding: 6px 10px;
            min-height: 44px;
        }

        .nav-icon-wrapper {
            width: 28px;
            height: 28px;
        }

        .nav-icon {
            width: 16px;
            height: 16px;
        }

        .nav-label {
            font-size: 0.65rem;
        }

        body {
            padding-bottom: 70px;
        }
    }

    /* ═══════════════════════════════════════════
       تحسين للشاشات الأكبر قليلاً
       ═══════════════════════════════════════════ */
    @media (min-width: 481px) and (max-width: 768px) {
        .nav-item {
            padding: 8px 14px;
        }

        .nav-icon-wrapper {
            width: 34px;
            height: 34px;
        }

        .nav-icon {
            width: 19px;
            height: 19px;
        }
    }
}

/* ═══════════════════════════════════════════
   دعم الوضع الليلي (Dark Mode) - اختياري
   ═══════════════════════════════════════════ */
@media (prefers-color-scheme: dark) {
    @media (max-width: 768px) {
        .bottom-navbar {
            background: linear-gradient(135deg, rgba(155, 89, 182, 0.95), rgba(142, 68, 173, 0.95));
        }

        .user-menu-dropdown {
            background: linear-gradient(135deg, rgba(155, 89, 182, 0.95), rgba(142, 68, 173, 0.95));
        }
    }
}
