/* ===================================
   MOBILE NAVIGATION STYLES
   This file MUST load last to override all other styles
   =================================== */

/* FORCE MOBILE TOP BAR STYLES */
@media (max-width: 991.98px) {
    .mobile-top-bar {
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        width: 100% !important;
        z-index: 1030 !important;
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1) !important;
        background-color: #ffffff !important;
        height: 68px !important; /* Match bottom nav height */
    }

    /* Container - extend search to the right edge */
    .mobile-top-bar .container-fluid {
        height: 100% !important;
        display: flex !important;
        align-items: center !important;
        padding-left: 0.5rem !important;
        padding-right: 0.5rem !important; /* Same padding as content cards */
        padding-top: 0 !important;
        padding-bottom: 0 !important;
    }

    /* Remove gap to give more space to search */
    .mobile-top-bar .d-flex.align-items-stretch {
        height: 100% !important;
        align-items: center !important;
        width: 100% !important;
        flex-wrap: nowrap !important;
    }

    .mobile-logo {
        height: 32px !important;
        width: auto !important;
        flex-shrink: 0 !important;
    }

    .mobile-logo-link {
        display: flex !important;
        align-items: center !important;
        flex-shrink: 0 !important;
        height: 100% !important;
        margin-right: 0.5rem !important;
        padding-right: 0 !important;
    }

    /* ==========================================
       MOBILE SEARCH INPUT AND BUTTON
       ========================================== */

    /* Flex container for search - extend fully to the right edge */
    .mobile-top-bar .flex-grow-1 {
        flex: 1 1 auto !important;
        max-width: none !important;
        padding-right: 0 !important;
        margin-right: 0 !important;
        width: 100% !important;
        min-width: 0 !important; /* Allow shrinking */
    }

    /* CRITICAL: Force input-group to stay on one line */
    .mobile-top-bar .input-group {
        height: 38px !important;
        width: 100% !important;
        flex-wrap: nowrap !important; /* Prevent wrapping */
        display: flex !important;
        align-items: stretch !important;
    }

    /* Search input styling - extend fully but allow shrinking */
    .mobile-search-input {
        height: 38px !important;
        min-height: 38px !important;
        padding: 0.375rem 0.75rem !important;
        font-size: 0.95rem !important;
        line-height: 1.5 !important;
        border: 1px solid #dee2e6 !important;
        border-right: none !important;
        border-radius: 0.375rem 0 0 0.375rem !important;
        flex: 1 1 auto !important;
        min-width: 0 !important; /* Allow shrinking below content width */
        width: 100% !important;
    }

    .mobile-search-input:focus {
        border-color: rgba(102, 126, 234, 0.5) !important;
        box-shadow: 0 0 0 0.2rem rgba(102, 126, 234, 0.15) !important;
        z-index: 1 !important;
    }

    /* Search button - keep same size, prevent shrinking */
    .mobile-search-btn {
        height: 38px !important;
        width: 38px !important;
        min-width: 38px !important;
        max-width: 38px !important;
        padding: 0 !important;
        background: linear-gradient(135deg, #667eea 0%, #764ba2 100%) !important;
        border: none !important;
        border-radius: 0 0.375rem 0.375rem 0 !important;
        color: white !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        flex-shrink: 0 !important; /* Never shrink the button */
        flex-grow: 0 !important;
    }

    .mobile-search-btn:hover,
    .mobile-search-btn:focus {
        background: linear-gradient(135deg, #5a6fd6 0%, #6a4190 100%) !important;
        box-shadow: 0 2px 8px rgba(102, 126, 234, 0.4) !important;
    }

    .mobile-search-btn:active {
        transform: scale(0.98) !important;
    }

    /* Search icon - same size as bottom nav icons */
    .mobile-search-btn i {
        font-size: 1rem !important;
        color: white !important;
        width: auto !important;
        height: auto !important;
    }

    /* ==========================================
       MOBILE BOTTOM NAVIGATION - PIXEL PERFECT ALIGNMENT
       ========================================== */
    
    .mobile-bottom-nav {
        position: fixed !important;
        bottom: 0 !important;
        left: 0 !important;
        width: 100% !important;
        z-index: 1030 !important;
        box-shadow: 0 -2px 4px rgba(0, 0, 0, 0.1) !important;
        background-color: #ffffff !important;
        height: 68px !important;
    }

    /* Container - force exact alignment */
    .mobile-bottom-nav .d-flex {
        display: flex !important;
        align-items: center !important;
        justify-content: space-around !important;
        height: 100% !important;
        padding: 0 !important;
        margin: 0 !important;
    }

    /* Base nav item - equal flex distribution */
    .mobile-nav-item {
        flex: 1 !important;
        display: flex !important;
        justify-content: center !important;
        align-items: center !important;
        height: 100% !important;
        padding: 0 !important;
        margin: 0 !important;
    }

    /* CRITICAL: Override all inline classes on links and buttons */
    .mobile-nav-item > a,
    .mobile-nav-item > .dropdown > button,
    .mobile-nav-item > .dropdown > a {
        display: flex !important;
        flex-direction: column !important;
        align-items: center !important;
        justify-content: center !important;
        gap: 5px !important;
        height: auto !important;
        padding: 0 !important;
        margin: 0 !important;
    }

    /* Force override of d-flex and flex-column classes */
    .mobile-nav-item a.d-flex,
    .mobile-nav-item button.d-flex {
        display: flex !important;
        flex-direction: column !important;
        align-items: center !important;
        justify-content: center !important;
        gap: 5px !important;
    }

    /* ALL ICONS - EXACT SAME SIZE AND POSITION */
    .mobile-nav-item i {
        font-size: 1.5rem !important;
        width: 26px !important;
        height: 26px !important;
        line-height: 26px !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        margin: 0 !important;
        padding: 0 !important;
        color: rgba(102, 126, 234, 0.85) !important; /* default purple for all icons */
    }

    /* Override Bootstrap fs-5 */
    .mobile-nav-item .fs-5 {
        font-size: 1.5rem !important;
        width: 26px !important;
        height: 26px !important;
        line-height: 26px !important;
    }

    /* Messages/Home/Categories/Profile - unify color (in case icon classes change) */
    .mobile-nav-item i.bi,
    .mobile-nav-item i.bi-envelope-fill,
    .mobile-nav-item i.bi-chat,
    .mobile-nav-item i.bi-house,
    .mobile-nav-item i.bi-house-fill,
    .mobile-nav-item i.bi-grid,
    .mobile-nav-item i.bi-grid-3x3-gap-fill,
    .mobile-nav-item i.bi-person {
        color: rgba(102, 126, 234, 0.85) !important;
    }

    /* ALL TEXT LABELS - EXACT SAME SIZE */
    .mobile-nav-item small {
        font-size: 0.7rem !important;
        line-height: 1 !important;
        white-space: nowrap !important;
        margin: 0 !important;
        padding: 0 !important;
        display: block !important;
        text-align: center !important;
        height: 0.7rem !important;
    }

    /* CRITICAL: Force override mt-1 class */
    .mobile-nav-item small.mt-1,
    .mobile-nav-item .mt-1 {
        margin-top: 0 !important;
    }

    /* Avatar same size as icons */
    .mobile-avatar {
        width: 26px !important;
        height: 26px !important;
        border-radius: 50% !important;
        object-fit: cover !important;
        margin: 0 !important;
        padding: 0 !important;
    }

    /* CRITICAL: Fix position-relative wrapper that causes offset */
    .mobile-nav-item .position-relative {
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        position: relative !important;
        width: 26px !important;
        height: 26px !important;
        margin: 0 !important;
        padding: 0 !important;
    }

    .mobile-nav-item .position-relative i {
        position: static !important;
    }

    /* Remove button styling */
    .mobile-nav-item .btn-link {
        border: none !important;
        text-decoration: none !important;
        background: transparent !important;
        box-shadow: none !important;
        outline: none !important;
        padding: 0 !important;
    }

    .mobile-nav-item .btn-link:hover,
    .mobile-nav-item .btn-link:focus,
    .mobile-nav-item .btn-link:active {
        border: none !important;
        background: transparent !important;
        box-shadow: none !important;
    }

    /* Force p-0 override */
    .mobile-nav-item .p-0 {
        padding: 0 !important;
    }

    /* ADD BUTTON - Softer Purple Gradient */
    .mobile-add-btn {
        flex: 1 !important;
        display: flex !important;
        justify-content: center !important;
        align-items: center !important;
        height: 100% !important;
        padding: 0 !important;
        margin: 0 !important;
        position: relative !important;
        top: -4px !important; /* align with the rest of the icons */
    }

    .add-article-circle {
        width: 45px !important;
        height: 45px !important;
        border-radius: 50% !important;
        background: linear-gradient(135deg, #667eea 0%, #764ba2 100%) !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        box-shadow: 0 3px 10px rgba(102, 126, 234, 0.3) !important;
        transition: transform 0.2s ease, box-shadow 0.2s ease !important;
        margin: 0 !important;
        padding: 0 !important;
    }

    .add-article-circle:hover {
        transform: scale(1.05) !important;
        box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4) !important;
    }

    .add-article-circle:active {
        transform: scale(0.95) !important;
    }

    /* Plus Icon - Force White Color + move slightly down */
    .add-article-circle i {
        font-size: 1.75rem !important;
        width: auto !important;
        height: auto !important;
        color: white !important;
        transform: translateY(1px) !important;
    }

    /* Override any text-white class conflicts */
    .add-article-circle i.text-white {
        color: white !important;
    }

    /* ==========================================
       MOBILE DROPDOWN MENUS - PURPLE THEME
       ========================================== */
    
    /* All dropdown menus from bottom nav */
    .mobile-bottom-nav .dropdown-menu {
        position: fixed !important;
        bottom: 78px !important; /* Above the nav bar */
        left: 50% !important;
        transform: translateX(-50%) !important;
        top: auto !important;
        width: calc(100vw - 2rem) !important;
        max-width: 400px !important;
        max-height: calc(100vh - 150px) !important;
        overflow-y: auto !important;
        margin: 0 !important;
        padding: 0.5rem !important;
        border-radius: 12px !important;
        box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.12) !important;
        border: 1px solid rgba(102, 126, 234, 0.15) !important;
    }

    /* Dropdown items styling - PURPLE THEME */
    .mobile-bottom-nav .dropdown-menu .dropdown-item {
        padding: 0.5rem 0.75rem !important;
        border-radius: 8px !important;
        margin-bottom: 0.15rem !important;
        font-size: 0.95rem !important;
        transition: all 0.2s ease !important;
        display: flex !important;
        align-items: center !important;
        gap: 0.5rem !important;
        color: #2d3748 !important;
    }

    /* Hover State - Purple Gradient */
    .mobile-bottom-nav .dropdown-menu .dropdown-item:hover {
        background: linear-gradient(135deg, #667eea 0%, #764ba2 100%) !important;
        color: white !important;
    }

    /* Active/Focus State - Purple Gradient */
    .mobile-bottom-nav .dropdown-menu .dropdown-item:active,
    .mobile-bottom-nav .dropdown-menu .dropdown-item:focus {
        background: linear-gradient(135deg, #667eea 0%, #764ba2 100%) !important;
        color: white !important;
    }

    /* Icons in dropdown - Turn white on hover/active */
    .mobile-bottom-nav .dropdown-menu .dropdown-item i {
        width: 20px !important;
        height: 20px !important;
        font-size: 1.1rem !important;
        margin: 0 !important;
        flex-shrink: 0 !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        transition: color 0.2s ease !important;
    }

    .mobile-bottom-nav .dropdown-menu .dropdown-item:hover i,
    .mobile-bottom-nav .dropdown-menu .dropdown-item:active i,
    .mobile-bottom-nav .dropdown-menu .dropdown-item:focus i {
        color: white !important;
    }

    /* Remove me-2 class effect */
    .mobile-bottom-nav .dropdown-menu .dropdown-item i.me-2 {
        margin-right: 0 !important;
    }

    /* Divider */
    .mobile-bottom-nav .dropdown-menu .dropdown-divider {
        margin: 0.35rem 0 !important;
        opacity: 0.1 !important;
    }

    /* Categories dropdown - specific positioning */
    .mobile-bottom-nav .categories-dropdown {
        left: 1rem !important;
        right: 1rem !important;
        transform: none !important;
        width: auto !important;
        max-width: none !important;
    }

    /* Content padding - updated for taller top bar */
    .layout-root {
        padding-top: 68px !important; /* Match top bar height */
        padding-bottom: 78px !important;
    }
    
    /* Hide desktop elements */
    .search-bar-container.d-none.d-lg-block {
        display: none !important;
    }
    
    .quick-categories-bar.d-none.d-md-block {
        display: none !important;
    }

    /* ==========================================
       HIDE FOOTER ON USERMESSAGES PAGE (MOBILE)
       ========================================== */
    .messages-page-container ~ footer,
    .messages-page-wrapper footer,
    body:has(.messages-page) footer {
        display: none !important;
    }

    /* ==========================================
       HIDE FOOTER ON FORUM PAGE (MOBILE)
       ========================================== */
    .forum-page ~ footer,
    .forum-page footer,
    body:has(.forum-page) footer,
    .layout-root:has(.forum-page) footer,
    .layout-root:has(.forum-page) .footer-component,
    .main-layout:has(.forum-page) footer,
    .content-host:has(.forum-page) ~ footer {
        display: none !important;
    }
}

/* ==========================================
   HIDE FOOTER ON USERMESSAGES PAGE (ALL SCREENS)
   ========================================== */

/* When messages page is present, hide footer */
.layout-root:has(.messages-page) footer,
.layout-root:has(.messages-page) .footer-component,
.main-layout:has(.messages-page) footer,
.content-host:has(.messages-page) ~ footer {
    display: none !important;
}
