/* MOBILE FAB (Bottom Right) */
.mobile-fab {
    display: none;
    position: fixed;
    bottom: 25px;
    right: 25px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent-start), var(--accent-end));
    color: white;
    border: none;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.6);
    z-index: 9990;
    cursor: pointer;
    align-items: center;
    justify-content: center;
    font-size: 1.8rem;
    transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275), opacity 0.2s;
}

.mobile-fab:active {
    transform: scale(0.9);
}

/* Hide FAB when any modal is open */
body.modal-open .mobile-fab {
    display: none !important;
    opacity: 0;
    pointer-events: none;
}

/* MENU BACKDROP */
body.menu-open::after {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    z-index: 9980;
    opacity: 0;
    animation: fadeInOverlay 0.3s forwards;
    pointer-events: none;
}

@keyframes fadeInOverlay {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

/* DRAG HANDLE */
.mobile-menu-handle {
    display: none;
    width: 100%;
    height: 25px;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    margin: 0;
}

.mobile-menu-handle::after {
    content: '';
    width: 40px;
    height: 5px;
    background: #444;
    border-radius: 10px;
}

/* MEDIA QUERIES */
@media (max-width: 768px) {

    /* --- FIXED TOPBAR FIXES --- */
    .sticky-toolbar-container.dashboard-topbar {
        display: flex !important;
        position: sticky;
        top: 0;
        z-index: 1000;
        background: #08080a;
        height: 60px;
        /* Increased height for better clearance */
        justify-content: center;
        border-bottom: 1px solid var(--card-border);
        box-shadow: 0 4px 15px rgba(0, 0, 0, 0.5);
    }

    .injector-panel {
        display: flex !important;
        height: 100%;
        padding: 0 5px !important;
        border: none !important;
        align-items: center;
        width: 100%;
    }

    .injector-center {
        flex: 1 !important;
        display: flex !important;
        justify-content: center !important;
        margin: 0 !important;
        width: 100%;
    }

    /* --- PAGINATION WRAPPING FIX --- */
    .pagination-bar {
        background: transparent !important;
        border: none !important;
        padding: 0 !important;
        gap: 4px !important;
        flex-wrap: nowrap !important;
        /* Prevents "Next" from dropping down */
        width: 100%;
        justify-content: center;
    }

    .pg-numbers {
        gap: 3px !important;
    }

    .pg-btn {
        min-width: 32px !important;
        /* Slightly smaller for mobile width */
        height: 34px !important;
        padding: 0 6px !important;
        font-size: 0.75rem !important;
        border-radius: 6px !important;
    }

    .pg-btn.pg-nav {
        min-width: 55px !important;
        /* Ensure Prev/Next fit */
        font-size: 0.7rem !important;
    }

    /* --- CONTENT OVERLAP FIX --- */
    .pages-container {
        padding: 0 !important;
    }

    .page {
        padding: 15px 8px 120px 8px !important;
        /* Increased top padding to clear header */
        margin-top: 0 !important;
    }

    /* Side search container inside the menu drawer */
    .sidebar-search-container {
        display: block !important;
        margin-top: 10px;
    }

    .db-grid,
    .guide-grid {
        grid-template-columns: 1fr;
        gap: 10px;
    }

    .header-toggle-strip,
    #sticky-sentinel {
        display: none !important;
    }

    .unit-hotbar {
        display: none !important;
    }

    .mobile-fab {
        display: flex !important;
    }

    .mobile-menu-handle {
        display: flex;
    }

    /* Unit Card Mobile Polish */
    .unit-banner {
        padding: 0 12px;
        gap: 10px;
        height: 85px;
    }

    .unit-avatar {
        width: 54px;
        height: 54px;
    }

    .unit-title h2 {
        font-size: 1.15rem;
        line-height: 1.2;
    }

    .unit-title span {
        font-size: 0.65rem;
    }

    .banner-badges {
        top: 6px;
        left: 12px;
        right: auto;
        gap: 4px;
    }

    .placement-badge {
        font-size: 0.62rem;
        padding: 2px 6px;
        border-radius: 4px;
    }

    /* Mobile Menu Buttons */
    .nav-toggle-label {
        display: flex;
        justify-content: space-between;
        padding: 15px;
        margin: 0;
        background: rgba(0, 0, 0, 0.4);
        border: 1px solid #333;
        font-size: 0.9rem;
    }

    .mobile-switch-visual {
        position: relative;
        width: 40px;
        height: 20px;
        background: #333;
        border-radius: 20px;
        transition: 0.3s;
    }

    .mobile-switch-visual::after {
        content: '';
        position: absolute;
        top: 2px;
        left: 2px;
        width: 16px;
        height: 16px;
        background: #fff;
        border-radius: 50%;
        transition: 0.3s;
    }

    input[type="checkbox"]:checked~.mobile-switch-visual {
        background: var(--success);
    }

    input[type="checkbox"]:checked~.mobile-switch-visual::after {
        transform: translateX(20px);
    }
}